From: Nicolas Richard <theonewiththeevillook@yahoo.fr>
To: Bastien <bzg@gnu.org>
Cc: Nicolas Richard <theonewiththeevillook@yahoo.fr>, emacs-orgmode@gnu.org
Subject: Re: 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/)]
Date: Wed, 30 Jul 2014 16:51:35 +0200 [thread overview]
Message-ID: <87fvhi5288.fsf@yahoo.fr> (raw)
In-Reply-To: <87mwbtxuob.fsf@bzg.ath.cx> (Bastien's message of "Mon, 28 Jul 2014 16:18:10 +0200")
Hello Bastien,
Bastien <bzg@gnu.org> writes:
> I think it's fine to bind `org-narrow-to-subtree' in narrow-map.
> It's basically to enjoy the `C-x n prefix', which is natural here.
I agree, but it is not compatible with keeping it only for org-mode
buffers while using something else for some other modes, which is what
you suggest next :
> I applied your patch, but a good continuation would be to have
> C-h n s bound to `outline-narrow-to-subtree' in outline-mode and
> to `org-narrow-to-subtree' in org-mode, instead of just relying
> on one single function.
> This requires simplifying `org-narrow-to-subtree' and creating
> `outline-narrow-to-subtree' in emacs.
>
> What do you think?
I think backporting narrow-to-subtree to outline is a very good move.
(Other things would be cool in outline, e.g. why does it not have
outline-cycle ? But that's a longer story, I guess.)
Another possibility : wouldn't it make sense to hijack narrow-to-defun
for this ? In fact, it used to be that way, but then it was changed in
76fa979225a2a31f7be6d366c48750d4f7abe458 (and then reverted, and then
the revert was reverted, and I have no idea why).
Looking more closely, the current behaviour is partly buggy, e.g. with a
file like :
* one
** two
** three
* four
When point is on the second line and C-M-e is used, we end up on the
first line ! I see two reasons for this or similar failures :
- One is a bug in org-forward-heading-same-level (I provide a patch
below).
- The other is because org-backward-element doesn't fully satisfy the
"beginning-of-defun usual protocol" since it sometimes signals an error.
Here's a test for catching the bug in org-forward-heading-same-level:
(org-test-with-temp-text "\
* one
* two
"
(goto-line 2)
(org-forward-heading-same-level -1)
(should (bobp)))
And here's the patch for org-forward-heading-same-level.
Modified lisp/org.el
diff --git a/lisp/org.el b/lisp/org.el
index 0e15710..741c9b5 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -23328,9 +23333,10 @@ non-nil it will also look at invisible ones."
're-search-forward))
(count (if arg (abs arg) 1))
(result (point)))
- (while (and (prog1 (> count 0)
- (forward-char (if (and arg (< arg 0)) -1 1)))
- (funcall f org-outline-regexp-bol nil 'move))
+ (while (and (> count 0)
+ (progn
+ (forward-char (if (and arg (< arg 0)) -1 1))
+ (funcall f org-outline-regexp-bol nil 'move)))
(let ((l (- (match-end 0) (match-beginning 0) 1)))
(cond ((< l level) (setq count 0))
((and (= l level)
Want a git-format-patch one ?
Also, here's a test where I don't know what should happen (currently
signals a user-error) :
(org-test-with-temp-text "\
one
* two
"
(goto-line 2)
(org-backward-element)
(should t))
--
Nico.
next prev parent reply other threads:[~2014-07-30 14:51 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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=87fvhi5288.fsf@yahoo.fr \
--to=theonewiththeevillook@yahoo.fr \
--cc=bzg@gnu.org \
--cc=emacs-orgmode@gnu.org \
/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).