emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r110144: Implement temp-output-buffer


From: martin rudalics
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r110144: Implement temp-output-buffer-show in subr.el.
Date: Sat, 22 Sep 2012 18:28:46 +0200
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 110144
committer: martin rudalics <address@hidden>
branch nick: trunk
timestamp: Sat 2012-09-22 18:28:46 +0200
message:
  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.
modified:
  lisp/ChangeLog
  lisp/subr.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-09-22 15:46:57 +0000
+++ b/lisp/ChangeLog    2012-09-22 16:28:46 +0000
@@ -1,3 +1,9 @@
+2012-09-22  Martin Rudalics  <address@hidden>
+
+       * 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.
+
 2012-09-22  Chong Yidong  <address@hidden>
 
        * files.el (ctl-x-map): Bind C-x C-q to read-only-mode

=== modified file 'lisp/subr.el'
--- a/lisp/subr.el      2012-09-21 03:03:48 +0000
+++ b/lisp/subr.el      2012-09-22 16:28:46 +0000
@@ -3138,6 +3138,45 @@
        (unwind-protect (progn ,@body)
          (set-window-configuration ,c)))))
 
+(defun temp-output-buffer-show (buffer)
+  "Internal function for `with-output-to-temp-buffer'."
+  (with-current-buffer buffer
+    (set-buffer-modified-p nil)
+    (goto-char (point-min)))
+
+  (if temp-buffer-show-function
+      (funcall temp-buffer-show-function buffer)
+    (with-current-buffer buffer
+      (let* ((window
+             (let ((window-combination-limit
+                  ;; When `window-combination-limit' equals
+                  ;; `temp-buffer' or `temp-buffer-resize' and
+                  ;; `temp-buffer-resize-mode' is enabled in this
+                  ;; buffer bind it to t so resizing steals space
+                  ;; preferably from the window that was split.
+                  (if (or (eq window-combination-limit 'temp-buffer)
+                          (and (eq window-combination-limit
+                                   'temp-buffer-resize)
+                               temp-buffer-resize-mode))
+                      t
+                    window-combination-limit)))
+               (display-buffer buffer)))
+            (frame (and window (window-frame window))))
+       (when window
+         (unless (eq frame (selected-frame))
+           (make-frame-visible frame))
+         (setq minibuffer-scroll-window window)
+         (set-window-hscroll window 0)
+         ;; Don't try this with NOFORCE non-nil!
+         (set-window-start window (point-min) t)
+         ;; This hould not be necessary.
+         (set-window-point window (point-min))
+         ;; Run `temp-buffer-show-hook', with the chosen window selected.
+         (with-selected-window window
+           (run-hooks 'temp-buffer-show-hook))))))
+  ;; Return nil.
+  nil)
+
 (defmacro with-output-to-temp-buffer (bufname &rest body)
   "Bind `standard-output' to buffer BUFNAME, eval BODY, then show that buffer.
 
@@ -3183,7 +3222,7 @@
                    (run-hooks 'temp-buffer-setup-hook)))))
             (standard-output ,buf))
        (prog1 (progn ,@body)
-         (internal-temp-output-buffer-show ,buf)))))
+         (temp-output-buffer-show ,buf)))))
 
 (defmacro with-temp-file (file &rest body)
   "Create a new buffer, evaluate BODY there, and write the buffer to FILE.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]