summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2016-02-23 22:06:33 -0500
committerKyle Meyer <kyle@kyleam.com>2016-02-23 22:06:33 -0500
commit8ed6fcda8f5161b6e8fb964ef6870d4c4b177970 (patch)
tree35a155dd8a921e35aa08c21a84796b2142c924c1
parentfb2f7d29677534a500bdda3625b53868515ce860 (diff)
downloademacs.d-8ed6fcda8f5161b6e8fb964ef6870d4c4b177970.tar.gz
Add variant of org-goto that widens
-rw-r--r--init.el1
-rw-r--r--lisp/km-org.el13
2 files changed, 14 insertions, 0 deletions
diff --git a/init.el b/init.el
index c421b8e..1a0864c 100644
--- a/init.el
+++ b/init.el
@@ -301,6 +301,7 @@
(define-key org-mode-map [remap org-tree-to-indirect-buffer]
#'km/org-tree-to-indirect-buffer)
(define-key org-mode-map [remap org-refile] #'km/org-refile-dwim)
+ (define-key org-mode-map [remap org-goto] #'km/org-goto)
(add-to-list 'org-speed-commands-user '("o" . km/org-open-at-point-stay))
(add-to-list 'org-speed-commands-user '("w" . km/org-refile-dwim))
diff --git a/lisp/km-org.el b/lisp/km-org.el
index 7f4d5da..a778502 100644
--- a/lisp/km-org.el
+++ b/lisp/km-org.el
@@ -300,6 +300,19 @@ called through the speed command interface."
(save-excursion
(call-interactively #'org-open-at-point)))
+(defun km/org-goto ()
+ "Like `org-goto', but act on widened buffer.
+If point ends up outside the previously narrowed region, leave
+the buffer widened."
+ (interactive)
+ (pcase-let ((`(,beg . ,end) (and (buffer-narrowed-p)
+ (cons (point-min) (point-max)))))
+ (widen)
+ (unwind-protect
+ (call-interactively #'org-goto)
+ (when (and beg (<= beg (point) end))
+ (narrow-to-region beg end)))))
+
;;; Agenda