emacs-orgmode
[Top][All Lists]
Advanced

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

[PATCH] Bug: Indenting empty description list item leaves point at begin


From: Ihor Radchenko
Subject: [PATCH] Bug: Indenting empty description list item leaves point at beginning of line [9.4.4]
Date: Sat, 02 Oct 2021 18:47:35 +0800

Bodertz <bodertz@gmail.com> writes:

> As you can see, point is at the beginning of the line.  I think it
> should be after the dash, as is the case when indenting plain list
> items.

The fix is attached.

Best,
Ihor

>From 63870bec28e59732cbbdf8b2534f6ece96e2d5d8 Mon Sep 17 00:00:00 2001
Message-Id: 
<63870bec28e59732cbbdf8b2534f6ece96e2d5d8.1633171544.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Sat, 2 Oct 2021 18:32:34 +0800
Subject: [PATCH] org-list: Do not move point when promoting/demoting items

* lisp/org-list.el (org-list-struct-apply-struct): Make sure the
origin marker is not moved to bol when promoting/demoting item in
special case:
- item
- <point> ::

* testing/lisp/test-org-list.el (test-org-list/indent-item): Add test

Fixes https://orgmode.org/list/87o88hlkvv.fsf@gmail.com
---
 lisp/org-list.el              |  5 ++++-
 testing/lisp/test-org-list.el | 10 +++++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/lisp/org-list.el b/lisp/org-list.el
index 2bd9dc4d9..b6ab14f84 100644
--- a/lisp/org-list.el
+++ b/lisp/org-list.el
@@ -1866,7 +1866,10 @@ (defun org-list-struct-apply-struct (struct old-struct)
              (looking-at org-list-full-item-re)
              ;; a.  Replace bullet
              (unless (equal old-bul new-bul)
-               (replace-match new-bul nil nil nil 1))
+                (save-excursion
+                  (replace-match "" nil nil nil 1)
+                  (goto-char (match-end 1))
+                  (insert-before-markers new-bul)))
              ;; b.  Replace checkbox.
              (cond
               ((equal (match-string 3) new-box))
diff --git a/testing/lisp/test-org-list.el b/testing/lisp/test-org-list.el
index 3689a172f..e3d904b1e 100644
--- a/testing/lisp/test-org-list.el
+++ b/testing/lisp/test-org-list.el
@@ -298,7 +298,15 @@ (ert-deftest test-org-list/indent-item ()
            (push-mark (point) t t)
            (goto-char (point-max))
            (let (org-list-demote-modify-bullet) (org-indent-item))
-           (buffer-string)))))
+           (buffer-string))))
+  ;; When point is right after empty item, do not move point.
+  (should
+   (= 13
+      (org-test-with-temp-text "
+- item
+- <point> ::"
+        (org-indent-item)
+        (point)))))
 
 (ert-deftest test-org-list/indent-item-tree ()
   "Test `org-indent-item-tree' specifications."
-- 
2.32.0


reply via email to

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