mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-06-14 04:21:24 +00:00
Call format-spec substitution functions in current buffer
* lisp/format-spec.el (format-spec): Call format-spec substitution functions in current buffer. I.e., in the same buffer in which substitution expressions are evaluated. Previously functions were instead called in the temporary buffer used to deal with FORMAT.
This commit is contained in:
parent
1538090889
commit
046db64044
1 changed files with 60 additions and 56 deletions
|
|
@ -87,6 +87,7 @@ any occurrences of \"%%\" in FORMAT verbatim in the result.
|
|||
|
||||
If SPLIT, instead of returning a single string, a list of strings
|
||||
is returned, where each format spec is its own element."
|
||||
(let ((orig-buffer (current-buffer)))
|
||||
(with-temp-buffer
|
||||
(let ((split-start (point-min))
|
||||
(split-result nil))
|
||||
|
|
@ -110,7 +111,10 @@ is returned, where each format spec is its own element."
|
|||
(trunc (match-string 3))
|
||||
(char (string-to-char (match-string 4)))
|
||||
(text (let ((res (cdr (assq char specification))))
|
||||
(if (functionp res) (funcall res) res))))
|
||||
(if (functionp res)
|
||||
(with-current-buffer orig-buffer
|
||||
(funcall res))
|
||||
res))))
|
||||
(when (and split
|
||||
(not (= (1- beg) split-start)))
|
||||
(push (buffer-substring split-start (1- beg)) split-result))
|
||||
|
|
@ -142,7 +146,7 @@ is returned, where each format spec is its own element."
|
|||
(buffer-string)
|
||||
(unless (= split-start (point-max))
|
||||
(push (buffer-substring split-start (point-max)) split-result))
|
||||
(nreverse split-result)))))
|
||||
(nreverse split-result))))))
|
||||
|
||||
(defun format-spec--do-flags (str flags width trunc)
|
||||
"Return STR formatted according to FLAGS, WIDTH, and TRUNC.
|
||||
|
|
|
|||
Loading…
Reference in a new issue