aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2019-10-04 08:56:18 -0400
committerStefan Monnier2019-10-04 08:56:18 -0400
commitf1d9e41ab022358c5086227d5b267f3f35d27666 (patch)
tree48e0d577913266ea8e3da03f7271ce9e8d3cfb0b
parent9a3089fea004e83992b6c4d05ecb7517b6c519ba (diff)
downloademacs-f1d9e41ab022358c5086227d5b267f3f35d27666.tar.gz
emacs-f1d9e41ab022358c5086227d5b267f3f35d27666.zip
* 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."
1934 (concat "|" lastname) 1934 (concat "|" lastname)
1935 lastname)))) 1935 lastname))))
1936 1936
1937(defun generate-new-buffer (name)
1938 "Create and return a buffer with a name based on NAME.
1939Choose the buffer's name using `generate-new-buffer-name'."
1940 (get-buffer-create (generate-new-buffer-name name)))
1941
1942(defcustom automount-dir-prefix (purecopy "^/tmp_mnt/") 1937(defcustom automount-dir-prefix (purecopy "^/tmp_mnt/")
1943 "Regexp to match the automounter prefix in a directory name." 1938 "Regexp to match the automounter prefix in a directory name."
1944 :group 'files 1939 :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'."
3415 (when (window-live-p (nth 1 state)) 3415 (when (window-live-p (nth 1 state))
3416 (select-window (nth 1 state) 'norecord))) 3416 (select-window (nth 1 state) 'norecord)))
3417 3417
3418(defun generate-new-buffer (name)
3419 "Create and return a buffer with a name based on NAME.
3420Choose the buffer's name using `generate-new-buffer-name'."
3421 (get-buffer-create (generate-new-buffer-name name)))
3422
3418(defmacro with-selected-window (window &rest body) 3423(defmacro with-selected-window (window &rest body)
3419 "Execute the forms in BODY with WINDOW as the selected window. 3424 "Execute the forms in BODY with WINDOW as the selected window.
3420The value returned is the value of the last form in BODY. 3425The value returned is the value of the last form in BODY.
@@ -3580,8 +3585,7 @@ See also `with-temp-buffer'."
3580 (let ((temp-file (make-symbol "temp-file")) 3585 (let ((temp-file (make-symbol "temp-file"))
3581 (temp-buffer (make-symbol "temp-buffer"))) 3586 (temp-buffer (make-symbol "temp-buffer")))
3582 `(let ((,temp-file ,file) 3587 `(let ((,temp-file ,file)
3583 (,temp-buffer 3588 (,temp-buffer (generate-new-buffer " *temp file*")))
3584 (get-buffer-create (generate-new-buffer-name " *temp file*"))))
3585 (unwind-protect 3589 (unwind-protect
3586 (prog1 3590 (prog1
3587 (with-current-buffer ,temp-buffer 3591 (with-current-buffer ,temp-buffer
@@ -3620,7 +3624,7 @@ See also `with-temp-file' and `with-output-to-string'."
3620 (declare (indent 0) (debug t)) 3624 (declare (indent 0) (debug t))
3621 (let ((temp-buffer (make-symbol "temp-buffer"))) 3625 (let ((temp-buffer (make-symbol "temp-buffer")))
3622 `(let ((,temp-buffer (generate-new-buffer " *temp*"))) 3626 `(let ((,temp-buffer (generate-new-buffer " *temp*")))
3623 ;; FIXME: kill-buffer can change current-buffer in some odd cases. 3627 ;; `kill-buffer' can change current-buffer in some odd cases.
3624 (with-current-buffer ,temp-buffer 3628 (with-current-buffer ,temp-buffer
3625 (unwind-protect 3629 (unwind-protect
3626 (progn ,@body) 3630 (progn ,@body)
@@ -3654,8 +3658,7 @@ of that nature."
3654(defmacro with-output-to-string (&rest body) 3658(defmacro with-output-to-string (&rest body)
3655 "Execute BODY, return the text it sent to `standard-output', as a string." 3659 "Execute BODY, return the text it sent to `standard-output', as a string."
3656 (declare (indent 0) (debug t)) 3660 (declare (indent 0) (debug t))
3657 `(let ((standard-output 3661 `(let ((standard-output (generate-new-buffer " *string-output*")))
3658 (get-buffer-create (generate-new-buffer-name " *string-output*"))))
3659 (unwind-protect 3662 (unwind-protect
3660 (progn 3663 (progn
3661 (let ((standard-output standard-output)) 3664 (let ((standard-output standard-output))