diff --git a/lisp/org-capture.el b/lisp/org-capture.el index 90a950f69..4ef5fea95 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -1831,12 +1831,7 @@ Expansion occurs in a temporary Org mode buffer." (setq org-capture--prompt-history (gethash prompt org-capture--prompt-history-table)) (push (org-completing-read - ;; `format-prompt' is new in Emacs 28.1. - (if (fboundp 'format-prompt) - (format-prompt (or prompt "Enter string") default) - (concat (or prompt "Enter string") - (and default (format " [%s]" default)) - ": ")) + (org-format-prompt (or prompt "Enter string") default) completions nil nil nil 'org-capture--prompt-history default) strings) diff --git a/lisp/org-compat.el b/lisp/org-compat.el index b8ed3ddc3..53fe56ab9 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -171,6 +171,26 @@ removed." (string-trim (replace-regexp-in-string blank " " string t t) blank blank)))) +(if (fboundp 'format-prompt) + (defalias 'org-format-prompt #'format-prompt) + ;; From Emacs minibuffer.el, inlining + ;; `minibuffer-default-prompt-format' value and replacing `length<' + ;; (both new in Emacs 28.1). + (defun org-format-prompt (prompt default &rest format-args) + "Compatibility substitute for `format-prompt'." + (concat + (if (null format-args) + prompt + (apply #'format prompt format-args)) + (and default + (or (not (stringp default)) + (> (length default) 0)) + (format " (default %s)" + (if (consp default) + (car default) + default))) + ": "))) + ;;; Emacs < 27.1 compatibility diff --git a/lisp/org-refile.el b/lisp/org-refile.el index fdedd3822..edab0b225 100644 --- a/lisp/org-refile.el +++ b/lisp/org-refile.el @@ -645,10 +645,7 @@ this function appends the default value from (prompt (let ((default (or (car org-refile-history) (and (assoc cbnex tbl) (setq cdef cbnex) cbnex)))) - ;; `format-prompt' is new in Emacs 28.1. - (if (fboundp 'format-prompt) - (format-prompt prompt default) - (concat prompt " (default " default ": ")))) + (org-format-prompt prompt default))) pa answ parent-target child parent old-hist) (setq old-hist org-refile-history) (setq answ (funcall cfunc prompt tbl nil (not new-nodes)