~bzg/org-mode

ba8c4686347a0411ab84e89232b64e3ee1ef10f9 — Ihor Radchenko 3 months ago 661a98f
org-insert-todo-heading-respect-content: Fix regression in b4e41b

* lisp/org.el (org-insert-todo-heading-respect-content): Do not force
first TODO keyword in the inserted heading.  Instead, accept prefix
arguments and pass them directly to `org-insert-todo-heading'.
* etc/ORG-NEWS (~org-insert-todo-heading-respect-content~ now accepts
prefix arguments): Document the change.
*
testing/lisp/test-org.el (test-org/insert-todo-heading-respect-content):
Add tests.

Reported-by: Xuan Wang <xuan.public@gmail.com>
Link: https://orgmode.org/list/CALjN2yehOVYZuU+tURes+mJ5XyTrRY1O0UG1ijH-6TjJ=W0ibw@mail.gmail.com
3 files changed, 27 insertions(+), 5 deletions(-)

M etc/ORG-NEWS
M lisp/org.el
M testing/lisp/test-org.el
M etc/ORG-NEWS => etc/ORG-NEWS +4 -0
@@ 189,6 189,10 @@ publishing" in the ~org-export-dispatch~ UI to be customized,
respectively.

** New features
*** ~org-insert-todo-heading-respect-content~ now accepts prefix arguments

The prefix arguments are passed to ~org-insert-todo-heading~.

*** Add support for ~logind~ idle time in ~org-user-idle-seconds~

When Emacs is built with =dbus= support and

M lisp/org.el => lisp/org.el +6 -4
@@ 6512,11 6512,13 @@ Set it to HEADING when provided."
  (interactive)
  (org-insert-heading '(4) invisible-ok))

(defun org-insert-todo-heading-respect-content (&optional _)
  "Insert TODO heading with `org-insert-heading-respect-content' set to t."
  (interactive)
(defun org-insert-todo-heading-respect-content (&optional arg)
  "Call `org-insert-todo-heading', inserting after current subtree.
ARG is passed to `org-insert-todo-heading'.
This command temporarily sets `org-insert-heading-respect-content' to t."
  (interactive "P")
  (let ((org-insert-heading-respect-content t))
    (org-insert-todo-heading '(4) t)))
    (org-insert-todo-heading arg t)))

(defun org-insert-todo-heading (arg &optional force-heading)
  "Insert a new heading with the same level and TODO state as current heading.

M testing/lisp/test-org.el => testing/lisp/test-org.el +17 -1
@@ 2025,7 2025,23 @@ CLOCK: [2022-09-17 sam. 11:00]--[2022-09-17 sam. 11:46] =>  0:46"
    "* TODO \n"
    (org-test-with-temp-text "* TODO\n** WAITING\n"
      (org-insert-todo-heading-respect-content)
      (buffer-substring-no-properties (line-beginning-position) (point-max))))))
      (buffer-substring-no-properties (line-beginning-position) (point-max)))))
  (should
   (equal
    "* TODO \n"
    (let ((org-todo-keywords '((sequence "FIRST" "TODO" "|" "DONE"))))
      (org-test-with-temp-text "* TODO\n** WAITING\n"
        (org-insert-todo-heading-respect-content)
        (buffer-substring-no-properties (line-beginning-position) (point-max))))))
  ;; Pass prefix argument.
  (should
   (equal
    "* FIRST \n"
    (let ((org-todo-keywords '((sequence "FIRST" "TODO" "|" "DONE"))))
      (org-test-with-temp-text "* TODO\n** WAITING\n"
        (org-insert-todo-heading-respect-content '(4))
        (buffer-substring-no-properties (line-beginning-position) (point-max))))))
  )

(ert-deftest test-org/clone-with-time-shift ()
  "Test `org-clone-subtree-with-time-shift'."