Hi Leo,

Leo <sdl....@gmail.com> writes:

> I have been using this outside of org-mode for many years but it is
> broken in 7.7.

I suggest using this (new) outline function instead:

#+begin_src emacs-lisp
(defun outline-narrow-to-subtree ()
  "Narrow buffer to the current subtree."
  (interactive)
  (save-excursion
    (save-match-data
      (narrow-to-region
       (progn (outline-back-to-heading t) (point))
       (progn (outline-end-of-subtree)
              (if (and (outline-on-heading-p t) (not (eobp))) 
                  (backward-char 1))
              (point))))))
#+end_src

You can patch outline.el with the attached patch to bind this command to
C-c @ C-s in outline-mode or outline-minor-mode.

I will submit this patch to Emacs developers. 

--- lisp/outline.el	2011-04-19 13:44:55 +0000
+++ lisp/outline.el	2011-08-15 13:41:50 +0000
@@ -83,6 +83,7 @@
     (define-key map "\C-k" 'show-branches)
     (define-key map "\C-q" 'hide-sublevels)
     (define-key map "\C-o" 'hide-other)
+    (define-key map "\C-s" 'outline-narrow-to-subtree)
     (define-key map "\C-^" 'outline-move-subtree-up)
     (define-key map "\C-v" 'outline-move-subtree-down)
     (define-key map [(control ?<)] 'outline-promote)
@@ -1116,6 +1117,18 @@
 		    (insert "\n\n"))))))
 	  (kill-new (buffer-string)))))))
 
+(defun outline-narrow-to-subtree ()
+  "Narrow buffer to the current subtree."
+  (interactive)
+  (save-excursion
+    (save-match-data
+      (narrow-to-region
+       (progn (outline-back-to-heading t) (point))
+       (progn (outline-end-of-subtree)
+	      (if (and (outline-on-heading-p t) (not (eobp))) 
+		  (backward-char 1))
+	      (point))))))
+
 (provide 'outline)
 (provide 'noutline)
 
-- 
 Bastien

Reply via email to