compat: Add compatibility wrapper for format-prompt
* lisp/org-compat.el (org-format-prompt): New compatibility function. * lisp/org-capture.el (org-capture-fill-template): * lisp/org-refile.el (org-refile-get-location): Use org-format-prompt. Prefer a wrapper to inlining compatibility kludges. This is a follow-up to the port of Emacs's 664094222.
This commit is contained in:
parent
07b6a0e044
commit
95a4c59bfe
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue