From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rafael =?utf-8?Q?Laboissi=C3=A8re?= Subject: [PATCH] test-org/fuzzy-links Date: Wed, 12 Apr 2017 22:33:54 +0200 Message-ID: <20170412203354.gnfpxtvqq5ykdsog@laboissiere.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="7o4nsnovw7g62jly" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35258) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cyOxj-0002GT-LS for emacs-orgmode@gnu.org; Wed, 12 Apr 2017 16:34:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cyOxg-0007ZS-I1 for emacs-orgmode@gnu.org; Wed, 12 Apr 2017 16:33:59 -0400 Received: from laboissiere.net ([46.101.243.132]:43364) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cyOxg-0007YW-9A for emacs-orgmode@gnu.org; Wed, 12 Apr 2017 16:33:56 -0400 Content-Disposition: inline List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Org Mode --7o4nsnovw7g62jly Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline 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 --7o4nsnovw7g62jly Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0001-Do-not-fail-when-heading-is-at-the-beginning-of-the-.patch" >From ff792a00e28b7b0ca4fde98f72611ef8079daf04 Mon Sep 17 00:00:00 2001 From: Rafael Laboissiere 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 --7o4nsnovw7g62jly--