emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bastien <bzg@altern.org>
To: Leo <sdl.web@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: C-x n s no longer works in outline mode
Date: Mon, 15 Aug 2011 15:43:50 +0200	[thread overview]
Message-ID: <87wree3i3t.fsf@gnu.org> (raw)
In-Reply-To: <m1bow7q57q.fsf@gmail.com> (Leo's message of "Tue, 02 Aug 2011 22:05:13 +0800")

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

Hi Leo,

Leo <sdl.web@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. 


[-- 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: 14 bytes --]


-- 
 Bastien

      parent reply	other threads:[~2011-08-15 13:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-02 14:05 C-x n s no longer works in outline mode Leo
2011-08-05 16:24 ` Leo
2011-08-15 13:43 ` Bastien [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wree3i3t.fsf@gnu.org \
    --to=bzg@altern.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=sdl.web@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).