summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2015-02-21 22:02:27 -0500
committerKyle Meyer <kyle@kyleam.com>2015-02-28 00:29:49 -0500
commit9b06d2b0c5edc3feffc13da89a28b7b48ac55d3c (patch)
treeec7355125d6f916cce474e15d5fab1fd865a0d8d
parent61ebb6dc8f450b98a8ab16727a81459edcf7a0b7 (diff)
downloademacs.d-9b06d2b0c5edc3feffc13da89a28b7b48ac55d3c.tar.gz
Rewrite org-refile-dwim-target-file
-rw-r--r--lisp/init-org.el19
1 files changed, 10 insertions, 9 deletions
diff --git a/lisp/init-org.el b/lisp/init-org.el
index 8bc7d55..6aa5944 100644
--- a/lisp/init-org.el
+++ b/lisp/init-org.el
@@ -464,6 +464,8 @@ displayed in the agenda."
"Exclude DONE state from refile targets."
(not (member (nth 2 (org-heading-components)) org-done-keywords)))
+(defvar km/org-refile-dwim-maxlevel 2)
+
(defun km/org-refile-dwim ()
"Rebind `org-refile-targets' if next window is an Org buffer.
A target is determined by `km/org-refile-dwim-target-file'."
@@ -479,15 +481,14 @@ A target is determined by `km/org-refile-dwim-target-file'."
(defun km/org-refile-dwim-target-file ()
"Return next window that is an Org buffer."
- (let ((from-buffer (current-buffer)))
- (--when-let (get-window-with-predicate
- (lambda (w)
- (with-current-buffer (window-buffer w)
- (and (eq major-mode 'org-mode)
- (not (eq from-buffer (current-buffer)))))))
- (buffer-file-name (window-buffer it)))))
-
-(defvar km/org-refile-dwim-maxlevel 2)
+ (let* ((from-buffer (current-buffer))
+ (other-win (get-window-with-predicate
+ (lambda (w)
+ (with-current-buffer (window-buffer w)
+ (and (derived-mode-p 'org-mode)
+ (not (eq from-buffer (current-buffer)))))))))
+ (and other-win
+ (buffer-file-name (window-buffer other-win)))))
(defun km/org-refile-to-other-file (file &optional maxlevel)
"Refile with `org-refile-targets' set to FILE.