emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug: [PATCH] Make org-narrow-to-subtree usable out of Org mode [8.2.7b (release_8.2.7b-6-g07d470 @ /home/youngfrog/sourcetrees/org-mode/lisp/)]
@ 2014-07-22 17:48 Nicolas Richard
  2014-07-24  7:48 ` Nicolas Goaziou
  2014-07-28 14:15 ` Bastien
  0 siblings, 2 replies; 14+ messages in thread
From: Nicolas Richard @ 2014-07-22 17:48 UTC (permalink / raw)
  To: emacs-orgmode

Hello all,

org-narrow-to-subtree is very nice, and I now have C-x n s hard-wired
into my fingers, but it doesn't work when outline-regexp is too
different from org-outline-regexp in Outline-but-non-Org mode buffers.

It looked pretty easy to fix, so here is my suggestion, below. It should
be rather harmless since it only affects non-Org buffers (and might have
the nice side effect of allowing other commands to run in those buffers
-- but I haven't checked.)

From 70ccd90f98d07762d7ae228d67c387d674a69cee Mon Sep 17 00:00:00 2001
From: Nicolas Richard <theonewiththeevillook@yahoo.fr>
Date: Tue, 22 Jul 2014 18:29:00 +0200
Subject: [PATCH] Make org-get-limited-outline-regexp usable outside of org.

This allows org-narrow-to-subtree to function in Outline mode.

* lisp/org-macs.el (org-get-limited-outline-regexp): Use
  outline-regexp instead of org-outline-regexp when not in Org mode.
---
 lisp/org-macs.el | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index 96265ec..78174df 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -352,11 +352,16 @@ point nowhere."
 (defun org-get-limited-outline-regexp ()
   "Return outline-regexp with limited number of levels.
 The number of levels is controlled by `org-inlinetask-min-level'"
-  (if (or (not (derived-mode-p 'org-mode)) (not (featurep 'org-inlinetask)))
-      org-outline-regexp
-    (let* ((limit-level (1- org-inlinetask-min-level))
-	   (nstars (if org-odd-levels-only (1- (* limit-level 2)) limit-level)))
-      (format "\\*\\{1,%d\\} " nstars))))
+  (cond ((not (derived-mode-p 'org-mode))
+	 outline-regexp)
+	((not (featurep 'org-inlinetask))
+	 org-outline-regexp)
+	(t
+	 (let* ((limit-level (1- org-inlinetask-min-level))
+		(nstars (if org-odd-levels-only
+			    (1- (* limit-level 2))
+			  limit-level)))
+	   (format "\\*\\{1,%d\\} " nstars)))))
 
 (defun org-format-seconds (string seconds)
   "Compatibility function replacing format-seconds."
-- 
2.0.2

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

end of thread, other threads:[~2014-07-31  7:58 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-22 17:48 Bug: [PATCH] Make org-narrow-to-subtree usable out of Org mode [8.2.7b (release_8.2.7b-6-g07d470 @ /home/youngfrog/sourcetrees/org-mode/lisp/)] Nicolas Richard
2014-07-24  7:48 ` Nicolas Goaziou
2014-07-24 13:28   ` Nicolas Richard
2014-07-24 14:02     ` Nicolas Goaziou
2014-07-24 14:25       ` Nicolas Richard
2014-07-24 15:00         ` Thorsten Jolitz
2014-07-25  9:13         ` Nicolas Goaziou
2014-07-28 14:18         ` Bastien
2014-07-30 14:51           ` Nicolas Richard
2014-07-30 15:20             ` Thorsten Jolitz
2014-07-30 15:37               ` Nicolas Richard
2014-07-30 16:30                 ` Thorsten Jolitz
2014-07-31  8:00                   ` Nicolas Richard
2014-07-28 14:15 ` Bastien

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