First check for major mode when update Org item headline

This commit is contained in:
Daniel Borchmann 2021-11-29 17:39:33 +01:00
parent 5c36dba12c
commit 159c8c0eb6
No known key found for this signature in database
GPG Key ID: 1C7071A75BB72D64
1 changed files with 8 additions and 3 deletions

View File

@ -620,15 +620,20 @@ query for it."
(insert body)
(org-update-statistics-cookies nil)))
(defun db/org-update-headline-log-note (new-headline)
(defun db/org-update-headline-log-note (&optional new-headline)
"Replace headline of item at point with NEW-HEADLINE.
Interactively query for HEADLINE when not provided."
(interactive "sNew Headline: ")
;; We should check this before asking the user for the new headline, but how?
(unless (derived-mode-p 'org-mode 'org-agenda-mode)
(user-error "Neither in an Org mode nor Org agenda buffer, aborting"))
(unless new-headline
(setq new-headline (read-string "New Headline: ")))
(unless (stringp new-headline)
(user-error "New headline must be string"))
(when (string-match-p "\n" new-headline)
(user-error "New headline contains newlines, aborting"))