summaryrefslogtreecommitdiff
path: root/lisp/init-org.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2014-11-03 01:04:19 -0500
committerKyle Meyer <kyle@kyleam.com>2014-11-03 01:04:19 -0500
commit790f5a2d94a34c3196e870b10b086edd74cb5721 (patch)
treeb1a0407ced01c051b9a8441e9b544e20b0e80958 /lisp/init-org.el
parent5cbc46bb0bc0757f374a2e6ea03f9e67411ee5f4 (diff)
downloademacs.d-790f5a2d94a34c3196e870b10b086edd74cb5721.tar.gz
Use hooks, not advice, to modify org-store-link
Previously (4af0bf7), I used advice for org-store-link to make it store notmuch links when called from Gnus buffers for local mail. This now doesn't work because org-called-interactively-p returns nil if org-store-link is advised. I'm assuming this is due to the nadvice package, new with Emacs 24.4, which says FIXME: This Major Ugly Hack won't handle calls to called-interactively-p done from the advised function if the deepest advice is an around advice! In other cases (calls from an advice or calls from the advised function when the deepest advice is not an around advice), it should hopefully get it right. Instead of using advice, create a separate function that will run a hook before interactively calling org-store-link.
Diffstat (limited to 'lisp/init-org.el')
-rw-r--r--lisp/init-org.el15
1 files changed, 14 insertions, 1 deletions
diff --git a/lisp/init-org.el b/lisp/init-org.el
index 92c033a..af9dc2d 100644
--- a/lisp/init-org.el
+++ b/lisp/init-org.el
@@ -85,7 +85,20 @@
(define-prefix-command 'km/global-org-map)
(global-set-key (kbd "C-c o") 'km/global-org-map)
-(define-key km/global-org-map "l" 'org-store-link)
+(defvar km/org-store-link-hook nil
+ "Hook run before by `km/org-store-link-hook'.
+These are run within a `save-window-excursion' block.")
+
+(defun km/org-store-link ()
+ "Run `km/org-store-link-hook' before `org-store-link'.
+The hook functions and `org-store-link' are called within a
+`save-window-excursion' block."
+ (interactive)
+ (save-window-excursion
+ (run-hooks 'km/org-store-link-hook)
+ (call-interactively 'org-store-link)))
+
+(define-key km/global-org-map "l" 'km/org-store-link)
(define-key km/global-org-map "o" 'org-open-at-point-global)
(define-key km/global-org-map "a" 'org-agenda)
(define-key km/global-org-map "b" 'org-iswitchb)