Quellcode durchsuchen

Backport commit 664094222 from Emacs

* lisp/org-capture.el (org-capture-fill-template):
* lisp/org-refile.el (org-refile-get-location): Prefer format-prompt
when it is fboundp.

Use format-prompt for many more prompts
66409422214a0a90e1d2a12ef2c4ebf86f2c01a9
Stefan Kangas
Tue Oct 5 03:44:56 2021 +0200
Stefan Kangas vor 3 Jahren
Ursprung
Commit
c7e1bbfd1c
2 geänderte Dateien mit 14 neuen und 9 gelöschten Zeilen
  1. 7 4
      lisp/org-capture.el
  2. 7 5
      lisp/org-refile.el

+ 7 - 4
lisp/org-capture.el

@@ -1816,10 +1816,13 @@ by their respective `org-store-link-plist' properties if present."
 		     ;; Load history list for current prompt.
 		     (setq org-capture--prompt-history
 			   (gethash prompt org-capture--prompt-history-table))
-		     (push (org-completing-read
-			    (concat (or prompt "Enter string")
-				    (and default (format " [%s]" default))
-				    ": ")
+                     (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))
+                                      ": "))
 			    completions
 			    nil nil nil 'org-capture--prompt-history default)
 			   strings)

+ 7 - 5
lisp/org-refile.el

@@ -640,11 +640,13 @@ this function appends the default value from
 	       org-refile-target-table))
 	 (completion-ignore-case t)
 	 cdef
-	 (prompt (concat prompt
-			 (or (and (car org-refile-history)
-				  (concat " (default " (car org-refile-history) ")"))
-			     (and (assoc cbnex tbl) (setq cdef cbnex)
-				  (concat " (default " cbnex ")"))) ": "))
+         (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 ": "))))
 	 pa answ parent-target child parent old-hist)
     (setq old-hist org-refile-history)
     (setq answ (funcall cfunc prompt tbl nil (not new-nodes)