all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Bodertz <bodertz@gmail.com>
Cc: emacs-orgmode@gnu.org
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	[thread overview]
Message-ID: <87y27bwvnc.fsf@localhost> (raw)
In-Reply-To: <87o88hlkvv.fsf@gmail.com>

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

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-list-Do-not-move-point-when-promoting-demoting-i.patch --]
[-- Type: text/x-diff, Size: 2107 bytes --]

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


  parent reply	other threads:[~2021-10-02 10:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-24 21:32 Bug: Indenting empty description list item leaves point at beginning of line [9.4.4] Bodertz
2021-09-27  8:24 ` Bastien
2021-10-02 10:47 ` Ihor Radchenko [this message]
2021-10-25 13:34   ` [PATCH] " Ihor Radchenko
2021-10-25 21:39     ` Bodertz
2022-06-09 13:25       ` [PATCH v2] " Ihor Radchenko
2022-06-11  5:12         ` Bodertz
2022-06-11 12:18           ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y27bwvnc.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=bodertz@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.