emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Bug: [PATCH] Make org-narrow-to-subtree usable out of Org mode [


From: Nicolas Richard
Subject: Re: [O] 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
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.92 (gnu/linux)

Hello Bastien,

Bastien <address@hidden> 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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]