unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] New command `outline-narrow-to-subtree'
@ 2011-08-15 13:46 Bastien
  2011-08-15 14:11 ` Leo
  0 siblings, 1 reply; 5+ messages in thread
From: Bastien @ 2011-08-15 13:46 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 379 bytes --]

Attached is a patch to outline.el defining a new command
`outline-narrow-to-subtree' (bound to `C-c @ C-s').

Let me know if this is okay to apply this patch: before 
Org 7.7, people could use `org-narrow-to-subtree' in buffers
with outline-mode or outline-minor-mode, so this patch can
be considered a fix rather than a new functionality.  But 
maybe it's borderline.

Thanks,


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: outline.el.patch --]
[-- Type: text/x-patch, Size: 951 bytes --]

--- 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)
 

[-- Attachment #3: Type: text/plain, Size: 15 bytes --]



-- 
 Bastien

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-08-19 12:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-15 13:46 [PATCH] New command `outline-narrow-to-subtree' Bastien
2011-08-15 14:11 ` Leo
2011-08-15 14:47   ` Bastien
2011-08-19  7:31     ` Leo
2011-08-19 12:59       ` Bastien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).