diff options
| author | Martin Rudalics | 2012-09-22 18:28:46 +0200 |
|---|---|---|
| committer | Martin Rudalics | 2012-09-22 18:28:46 +0200 |
| commit | 43bf5e8e4de7e2e45069f3fe591c658a61126378 (patch) | |
| tree | 8e92d5da5610c86f3c61156f6219e3861400abd5 | |
| parent | 3171e30301313fc2d22c0d2eca79d7be95f8c576 (diff) | |
| download | emacs-43bf5e8e4de7e2e45069f3fe591c658a61126378.tar.gz emacs-43bf5e8e4de7e2e45069f3fe591c658a61126378.zip | |
Implement temp-output-buffer-show in subr.el.
* subr.el (temp-output-buffer-show): New function.
(with-output-to-temp-buffer): Call temp-output-buffer-show
instead of internal-temp-output-buffer-show.
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/subr.el | 41 |
2 files changed, 46 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9278c778636..754eafc81a3 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2012-09-22 Martin Rudalics <rudalics@gmx.at> | ||
| 2 | |||
| 3 | * subr.el (temp-output-buffer-show): New function. | ||
| 4 | (with-output-to-temp-buffer): Call temp-output-buffer-show | ||
| 5 | instead of internal-temp-output-buffer-show. | ||
| 6 | |||
| 1 | 2012-09-22 Chong Yidong <cyd@gnu.org> | 7 | 2012-09-22 Chong Yidong <cyd@gnu.org> |
| 2 | 8 | ||
| 3 | * files.el (ctl-x-map): Bind C-x C-q to read-only-mode | 9 | * files.el (ctl-x-map): Bind C-x C-q to read-only-mode |
diff --git a/lisp/subr.el b/lisp/subr.el index 13516419b6f..b9b8e627672 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -3138,6 +3138,45 @@ in which case `save-window-excursion' cannot help." | |||
| 3138 | (unwind-protect (progn ,@body) | 3138 | (unwind-protect (progn ,@body) |
| 3139 | (set-window-configuration ,c))))) | 3139 | (set-window-configuration ,c))))) |
| 3140 | 3140 | ||
| 3141 | (defun temp-output-buffer-show (buffer) | ||
| 3142 | "Internal function for `with-output-to-temp-buffer'." | ||
| 3143 | (with-current-buffer buffer | ||
| 3144 | (set-buffer-modified-p nil) | ||
| 3145 | (goto-char (point-min))) | ||
| 3146 | |||
| 3147 | (if temp-buffer-show-function | ||
| 3148 | (funcall temp-buffer-show-function buffer) | ||
| 3149 | (with-current-buffer buffer | ||
| 3150 | (let* ((window | ||
| 3151 | (let ((window-combination-limit | ||
| 3152 | ;; When `window-combination-limit' equals | ||
| 3153 | ;; `temp-buffer' or `temp-buffer-resize' and | ||
| 3154 | ;; `temp-buffer-resize-mode' is enabled in this | ||
| 3155 | ;; buffer bind it to t so resizing steals space | ||
| 3156 | ;; preferably from the window that was split. | ||
| 3157 | (if (or (eq window-combination-limit 'temp-buffer) | ||
| 3158 | (and (eq window-combination-limit | ||
| 3159 | 'temp-buffer-resize) | ||
| 3160 | temp-buffer-resize-mode)) | ||
| 3161 | t | ||
| 3162 | window-combination-limit))) | ||
| 3163 | (display-buffer buffer))) | ||
| 3164 | (frame (and window (window-frame window)))) | ||
| 3165 | (when window | ||
| 3166 | (unless (eq frame (selected-frame)) | ||
| 3167 | (make-frame-visible frame)) | ||
| 3168 | (setq minibuffer-scroll-window window) | ||
| 3169 | (set-window-hscroll window 0) | ||
| 3170 | ;; Don't try this with NOFORCE non-nil! | ||
| 3171 | (set-window-start window (point-min) t) | ||
| 3172 | ;; This hould not be necessary. | ||
| 3173 | (set-window-point window (point-min)) | ||
| 3174 | ;; Run `temp-buffer-show-hook', with the chosen window selected. | ||
| 3175 | (with-selected-window window | ||
| 3176 | (run-hooks 'temp-buffer-show-hook)))))) | ||
| 3177 | ;; Return nil. | ||
| 3178 | nil) | ||
| 3179 | |||
| 3141 | (defmacro with-output-to-temp-buffer (bufname &rest body) | 3180 | (defmacro with-output-to-temp-buffer (bufname &rest body) |
| 3142 | "Bind `standard-output' to buffer BUFNAME, eval BODY, then show that buffer. | 3181 | "Bind `standard-output' to buffer BUFNAME, eval BODY, then show that buffer. |
| 3143 | 3182 | ||
| @@ -3183,7 +3222,7 @@ if it uses `temp-buffer-show-function'." | |||
| 3183 | (run-hooks 'temp-buffer-setup-hook))))) | 3222 | (run-hooks 'temp-buffer-setup-hook))))) |
| 3184 | (standard-output ,buf)) | 3223 | (standard-output ,buf)) |
| 3185 | (prog1 (progn ,@body) | 3224 | (prog1 (progn ,@body) |
| 3186 | (internal-temp-output-buffer-show ,buf))))) | 3225 | (temp-output-buffer-show ,buf))))) |
| 3187 | 3226 | ||
| 3188 | (defmacro with-temp-file (file &rest body) | 3227 | (defmacro with-temp-file (file &rest body) |
| 3189 | "Create a new buffer, evaluate BODY there, and write the buffer to FILE. | 3228 | "Create a new buffer, evaluate BODY there, and write the buffer to FILE. |