From: Stefan Monnier Date: Fri, 4 Oct 2019 12:56:18 +0000 (-0400) Subject: * lisp/subr.el (generate-new-buffer): Move (from files.el) before first use X-Git-Tag: emacs-27.0.90~1290 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f1d9e41ab022358c5086227d5b267f3f35d27666;p=emacs.git * 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. --- 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))