bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#17809: 24.4.50; Completions display


From: Juri Linkov
Subject: bug#17809: 24.4.50; Completions display
Date: Mon, 07 Jul 2014 02:32:51 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu)

>> +(defmacro with-displayed-buffer-window (buffer-or-name action quit-function 
>> &rest body)
>
> That looks OK.  Two details, tho:
>
>> +     (setq ,window (temp-buffer-window-show ,buffer ,action)))
> [...]
>> +       (when (functionp (cdr (assq 'window-height (cdr ,action))))
>
> Let's not evaluate `action' twice.  I.e. we need a (macroexp-let2 ..)
> wrapper for it.

I added this now in the next patch.

>> +       (if (functionp ,quit-function)
>> +       (funcall ,quit-function ,window ,value)
>
> Same for quit-function, and additionally, we want to make sure we
> evaluate `quit-function' before `body'.

`quit-function' is used in `dired-mark-pop-up' to activate the minibuffer,
so it should be the final thing after displaying the *Marked Files* buffer.
Maybe `quit-function' is not an appropriate name for such action?

=== modified file 'lisp/window.el'
--- lisp/window.el      2014-06-18 07:57:27 +0000
+++ lisp/window.el      2014-07-06 23:32:27 +0000
@@ -185,6 +185,7 @@ (defmacro with-temp-buffer-window (buffe
   (let ((buffer (make-symbol "buffer"))
        (window (make-symbol "window"))
        (value (make-symbol "value")))
+    (macroexp-let2 macroexp-copyable-p vquit-function quit-function
     `(let* ((,buffer (temp-buffer-window-setup ,buffer-or-name))
            (standard-output ,buffer)
            ,window ,value)
@@ -192,9 +193,9 @@ (defmacro with-temp-buffer-window (buffe
        (with-current-buffer ,buffer
         (setq ,window (temp-buffer-window-show ,buffer ,action)))
 
-       (if (functionp ,quit-function)
-          (funcall ,quit-function ,window ,value)
-        ,value))))
+        (if (functionp ,vquit-function)
+            (funcall ,vquit-function ,window ,value)
+          ,value)))))
 
 (defmacro with-current-buffer-window (buffer-or-name action quit-function 
&rest body)
   "Evaluate BODY with a buffer BUFFER-OR-NAME current and show that buffer.
@@ -205,6 +206,7 @@ (defmacro with-current-buffer-window (bu
   (let ((buffer (make-symbol "buffer"))
        (window (make-symbol "window"))
        (value (make-symbol "value")))
+    (macroexp-let2 macroexp-copyable-p vquit-function quit-function
     `(let* ((,buffer (temp-buffer-window-setup ,buffer-or-name))
            (standard-output ,buffer)
            ,window ,value)
@@ -212,9 +214,40 @@ (defmacro with-current-buffer-window (bu
         (setq ,value (progn ,@body))
         (setq ,window (temp-buffer-window-show ,buffer ,action)))
 
-       (if (functionp ,quit-function)
-          (funcall ,quit-function ,window ,value)
-        ,value))))
+        (if (functionp ,vquit-function)
+            (funcall ,vquit-function ,window ,value)
+          ,value)))))
+
+(defmacro with-displayed-buffer-window (buffer-or-name action quit-function 
&rest body)
+  "Show a buffer BUFFER-OR-NAME and evaluate BODY in that buffer.
+This construct is like `with-current-buffer-window' but unlike that
+displays the buffer specified by BUFFER-OR-NAME before running BODY."
+  (declare (debug t))
+  (let ((buffer (make-symbol "buffer"))
+       (window (make-symbol "window"))
+       (value (make-symbol "value")))
+    (macroexp-let2 macroexp-copyable-p vaction action
+      (macroexp-let2 macroexp-copyable-p vquit-function quit-function
+       `(let* ((,buffer (temp-buffer-window-setup ,buffer-or-name))
+               (standard-output ,buffer)
+               ,window ,value)
+          (with-current-buffer ,buffer
+            (setq ,window (temp-buffer-window-show ,buffer ,vaction)))
+
+          (let ((inhibit-read-only t)
+                (inhibit-modification-hooks t))
+            (setq ,value (progn ,@body)))
+
+          (with-selected-window ,window
+            (goto-char (point-min)))
+
+          (when (functionp (cdr (assq 'window-height (cdr ,vaction))))
+            (ignore-errors
+              (funcall (cdr (assq 'window-height (cdr ,vaction))) ,window)))
+
+          (if (functionp ,vquit-function)
+              (funcall ,vquit-function ,window ,value)
+            ,value))))))
 
 ;; The following two functions are like `window-next-sibling' and
 ;; `window-prev-sibling' but the WINDOW argument is _not_ optional (so






reply via email to

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