Commit c16c78f75add

Vincent Demeester <vincent+git@demeester.fr>
2014-04-21 18:29:39
Update org-mode configuration
1 parent fe22c46
Changed files (1)
.emacs.d
.emacs.d/org.conf.el
@@ -41,6 +41,40 @@
   )
 (add-hook 'org-mode-hook 'my-org-mode-hook)
 
+;; Speed commmands
+(defun ded/org-show-next-heading-tidily ()
+  "Show next entry, keeping other entries closed."
+  (if (save-excursion (end-of-line) (outline-invisible-p))
+      (progn (org-show-entry) (show-children))
+    (outline-next-heading)
+    (unless (and (bolp) (org-on-heading-p))
+      (org-up-heading-safe)
+      (hide-subtree)
+      (error "Boundary reached"))
+    (org-overview)
+    (org-reveal t)
+    (org-show-entry)
+    (show-children)))
+
+(defun ded/org-show-previous-heading-tidily ()
+  "Show previous entry, keeping other entries closed."
+  (let ((pos (point)))
+    (outline-previous-heading)
+    (unless (and (< (point) pos) (bolp) (org-on-heading-p))
+      (goto-char pos)
+      (hide-subtree)
+      (error "Boundary reached"))
+    (org-overview)
+    (org-reveal t)
+    (org-show-entry)
+    (show-children)))
+
+(setq org-use-speed-commands t)
+(add-to-list 'org-speed-commands-user
+             '("n" ded/org-show-next-heading-tidily))
+(add-to-list 'org-speed-commands-user
+             '("p" ded/org-show-previous-heading-tidily))
+
 ;; Use bullets
 (require 'org-bullets)
 (add-hook 'org-mode-hook