[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Re: [BUG] Adding note to heading without newline at the end
From: |
Ihor Radchenko |
Subject: |
[PATCH] Re: [BUG] Adding note to heading without newline at the end |
Date: |
Tue, 21 Jun 2022 10:24:39 +0800 |
Tor Kringeland <tor.kringeland@ntnu.no> writes:
> Ihor Radchenko <yantar92@gmail.com> writes:
>
>> Can you reproduce the problem starting from emacs -Q?
>
> I did. The bug only occurs if there is no newline at the end. So for
> example if you open a new buffer and don't save it, the bug should
> occur.
Aha. Not saving is an important piece of information.
(said the person with compulsive saving syndrome)
Can you test the attached patch?
Best,
Ihor
>From 7c40a003166c9ab8f5f034b8bb6d506ed2b8b62f Mon Sep 17 00:00:00 2001
Message-Id:
<7c40a003166c9ab8f5f034b8bb6d506ed2b8b62f.1655778085.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Tue, 21 Jun 2022 10:18:58 +0800
Subject: [PATCH] org-log-beginning: Fix for headline at eob with no trailing
newline
* lisp/org.el (org-log-beginning): Fix edge case when there is a
headline at the end of buffer and that headline does not have a
trailing newline.
Fixes m24k0ffjyd.fsf@ntnu.no">https://orgmode.org/list/m24k0ffjyd.fsf@ntnu.no
---
lisp/org.el | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index 220210992..78f51f9ad 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -10121,12 +10121,17 @@ (defun org-log-beginning (&optional create)
(end-of-line -1))))
(t
(org-end-of-meta-data org-log-state-notes-insert-after-drawers)
- (skip-chars-forward " \t\n")
- (beginning-of-line)
- (unless org-log-states-order-reversed
- (org-skip-over-state-notes)
- (skip-chars-backward " \t\n")
- (beginning-of-line 2)))))
+ (let ((endpos (point)))
+ (skip-chars-forward " \t\n")
+ (beginning-of-line)
+ (unless org-log-states-order-reversed
+ (org-skip-over-state-notes)
+ (skip-chars-backward " \t\n")
+ (beginning-of-line 2))
+ ;; When current headline is at the end of buffer and does not
+ ;; end with trailing newline the above can move to the
+ ;; beginning of the headline.
+ (when (< (point) endpos)) (goto-char endpos)))))
(if (bolp) (point) (line-beginning-position 2))))
(defun org-add-log-setup (&optional purpose state prev-state how extra)
--
2.35.1
- [BUG] Adding note to heading without newline at the end, Tor Kringeland, 2022/06/19
- Re: [BUG] Adding note to heading without newline at the end, Ihor Radchenko, 2022/06/20
- Re: [BUG] Adding note to heading without newline at the end, Tor Kringeland, 2022/06/20
- [PATCH] Re: [BUG] Adding note to heading without newline at the end,
Ihor Radchenko <=
- Re: [PATCH] Re: [BUG] Adding note to heading without newline at the end, Tor Kringeland, 2022/06/21
- Re: [PATCH] Re: [BUG] Adding note to heading without newline at the end, Tim Cross, 2022/06/21
- Re: [PATCH] Re: [BUG] Adding note to heading without newline at the end, Ihor Radchenko, 2022/06/21
- Re: [PATCH] Re: [BUG] Adding note to heading without newline at the end, Tor Kringeland, 2022/06/22
- Re: [PATCH] Re: [BUG] Adding note to heading without newline at the end, Samuel Banya, 2022/06/23
- Re: [PATCH] Re: [BUG] Adding note to heading without newline at the end, Samuel Banya, 2022/06/26
- Re: [PATCH] Re: [BUG] Adding note to heading without newline at the end, Ihor Radchenko, 2022/06/26
- Re: [PATCH] Re: [BUG] Adding note to heading without newline at the end, Samuel Banya, 2022/06/26
- Re: [PATCH] Re: [BUG] Adding note to heading without newline at the end, Ihor Radchenko, 2022/06/27
- Re: [PATCH] Re: [BUG] Adding note to heading without newline at the end, Samuel Banya, 2022/06/27