summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2019-10-04 08:56:18 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2019-10-04 08:56:18 -0400
commitf1d9e41ab022358c5086227d5b267f3f35d27666 (patch)
tree48e0d577913266ea8e3da03f7271ce9e8d3cfb0b
parent9a3089fea004e83992b6c4d05ecb7517b6c519ba (diff)
downloademacs-f1d9e41ab022358c5086227d5b267f3f35d27666.tar.gz
* lisp/subr.el (generate-new-buffer): Move (from files.el) before first use
(with-temp-file, with-output-to-string): Use it. * lisp/files.el (generate-new-buffer): Move to subr.el.
-rw-r--r--lisp/files.el5
-rw-r--r--lisp/subr.el13
2 files changed, 8 insertions, 10 deletions
diff --git a/lisp/files.el b/lisp/files.el
index 09180fd5555..20bc204b061 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -1934,11 +1934,6 @@ this function prepends a \"|\" to the final result if necessary."
(concat "|" lastname)
lastname))))
-(defun generate-new-buffer (name)
- "Create and return a buffer with a name based on NAME.
-Choose the buffer's name using `generate-new-buffer-name'."
- (get-buffer-create (generate-new-buffer-name name)))
-
(defcustom automount-dir-prefix (purecopy "^/tmp_mnt/")
"Regexp to match the automounter prefix in a directory name."
:group 'files
diff --git a/lisp/subr.el b/lisp/subr.el
index fcfc396d140..985bdc6b711 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -3415,6 +3415,11 @@ also `with-temp-buffer'."
(when (window-live-p (nth 1 state))
(select-window (nth 1 state) 'norecord)))
+(defun generate-new-buffer (name)
+ "Create and return a buffer with a name based on NAME.
+Choose the buffer's name using `generate-new-buffer-name'."
+ (get-buffer-create (generate-new-buffer-name name)))
+
(defmacro with-selected-window (window &rest body)
"Execute the forms in BODY with WINDOW as the selected window.
The value returned is the value of the last form in BODY.
@@ -3580,8 +3585,7 @@ See also `with-temp-buffer'."
(let ((temp-file (make-symbol "temp-file"))
(temp-buffer (make-symbol "temp-buffer")))
`(let ((,temp-file ,file)
- (,temp-buffer
- (get-buffer-create (generate-new-buffer-name " *temp file*"))))
+ (,temp-buffer (generate-new-buffer " *temp file*")))
(unwind-protect
(prog1
(with-current-buffer ,temp-buffer
@@ -3620,7 +3624,7 @@ See also `with-temp-file' and `with-output-to-string'."
(declare (indent 0) (debug t))
(let ((temp-buffer (make-symbol "temp-buffer")))
`(let ((,temp-buffer (generate-new-buffer " *temp*")))
- ;; FIXME: kill-buffer can change current-buffer in some odd cases.
+ ;; `kill-buffer' can change current-buffer in some odd cases.
(with-current-buffer ,temp-buffer
(unwind-protect
(progn ,@body)
@@ -3654,8 +3658,7 @@ of that nature."
(defmacro with-output-to-string (&rest body)
"Execute BODY, return the text it sent to `standard-output', as a string."
(declare (indent 0) (debug t))
- `(let ((standard-output
- (get-buffer-create (generate-new-buffer-name " *string-output*"))))
+ `(let ((standard-output (generate-new-buffer " *string-output*")))
(unwind-protect
(progn
(let ((standard-output standard-output))