emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] test-org/fuzzy-links
@ 2017-04-12 20:33 Rafael Laboissière
  2017-04-15 14:53 ` Nicolas Goaziou
  0 siblings, 1 reply; 3+ messages in thread
From: Rafael Laboissière @ 2017-04-12 20:33 UTC (permalink / raw)
  To: Org Mode

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

Function org-backward-heading-same-level fails in a specific case. 
Suppose the following org-mode file:

 ==================
 * first
 * second
 * third
 ==================

where '* first' is right at the beginning of the file.

When the cursor is at line '* third' and org-backward-heading-same-level 
is called, we go to the previous line correctly.  However when the cursor 
is at '* second', org-backward-heading-same-level does bring us to the 
first line but emits an error "Beginning of buffer".  It seems that the 
patch attached to this message fixes the problem.

Best,

Rafael

[-- Attachment #2: 0001-Do-not-fail-when-heading-is-at-the-beginning-of-the-.patch --]
[-- Type: text/x-diff, Size: 1017 bytes --]

From ff792a00e28b7b0ca4fde98f72611ef8079daf04 Mon Sep 17 00:00:00 2001
From: Rafael Laboissiere <rafael@laboissiere.net>
Date: Wed, 12 Apr 2017 22:18:54 +0200
Subject: [PATCH] Do not fail when heading is at the beginning of the buffer

* org.el (org-forward-heading-same-level): Do not move backward when
at the beginning of the buffer
---
 lisp/org.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index 17caa3fa6..b46369ad5 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -24071,7 +24071,8 @@ non-nil it will also look at invisible ones."
           (count (if arg (abs arg) 1))
           (result (point)))
       (while (and (prog1 (> count 0)
-		    (forward-char (if (and arg (< arg 0)) -1 1)))
+		    (forward-char (if (and arg (< arg 0))
+				      (if (= (point) 1) 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))
-- 
2.11.0


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

end of thread, other threads:[~2017-04-15 15:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-12 20:33 [PATCH] test-org/fuzzy-links Rafael Laboissière
2017-04-15 14:53 ` Nicolas Goaziou
2017-04-15 15:07   ` Rafael Laboissière

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