unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 17809@debbugs.gnu.org
Subject: bug#17809: 24.4.50; Completions display
Date: Mon, 07 Jul 2014 09:49:18 +0300	[thread overview]
Message-ID: <877g3p64up.fsf@mail.jurta.org> (raw)
In-Reply-To: <jwv4myux8r2.fsf-monnier+emacsbugs@gnu.org> (Stefan Monnier's message of "Sun, 06 Jul 2014 21:24:27 -0400")

> That looks right, except it means that `quit-function' is
> evaluated before `buffer-or-name', which is contrary to the expectation
> that arguments are usually evaluated left-to-right.

I believe all your concerns are addressed in this patch
unless I have more misunderstandings.

=== modified file 'lisp/window.el'
--- lisp/window.el	2014-06-18 07:57:27 +0000
+++ lisp/window.el	2014-07-07 06:49:07 +0000
@@ -185,16 +185,19 @@ (defmacro with-temp-buffer-window (buffe
   (let ((buffer (make-symbol "buffer"))
 	(window (make-symbol "window"))
 	(value (make-symbol "value")))
-    `(let* ((,buffer (temp-buffer-window-setup ,buffer-or-name))
+    (macroexp-let2 nil vbuffer-or-name buffer-or-name
+      (macroexp-let2 nil vaction action
+	(macroexp-let2 nil vquit-function quit-function
+	  `(let* ((,buffer (temp-buffer-window-setup ,vbuffer-or-name))
 	    (standard-output ,buffer)
 	    ,window ,value)
        (setq ,value (progn ,@body))
        (with-current-buffer ,buffer
-	 (setq ,window (temp-buffer-window-show ,buffer ,action)))
+	       (setq ,window (temp-buffer-window-show ,buffer ,vaction)))
 
-       (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,16 +208,51 @@ (defmacro with-current-buffer-window (bu
   (let ((buffer (make-symbol "buffer"))
 	(window (make-symbol "window"))
 	(value (make-symbol "value")))
-    `(let* ((,buffer (temp-buffer-window-setup ,buffer-or-name))
+    (macroexp-let2 nil vbuffer-or-name buffer-or-name
+      (macroexp-let2 nil vaction action
+	(macroexp-let2 nil vquit-function quit-function
+	  `(let* ((,buffer (temp-buffer-window-setup ,vbuffer-or-name))
 	    (standard-output ,buffer)
 	    ,window ,value)
        (with-current-buffer ,buffer
 	 (setq ,value (progn ,@body))
-	 (setq ,window (temp-buffer-window-show ,buffer ,action)))
+	       (setq ,window (temp-buffer-window-show ,buffer ,vaction)))
 
-       (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 nil vbuffer-or-name buffer-or-name
+      (macroexp-let2 nil vaction action
+	(macroexp-let2 nil vquit-function quit-function
+	  `(let* ((,buffer (temp-buffer-window-setup ,vbuffer-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	other threads:[~2014-07-07  6:49 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-22 13:30 bug#17831: 24.4.50; bad default value for `Man-width' Leo Liu
2014-06-23 12:53 ` Stefan Monnier
2014-06-23 23:17   ` Juri Linkov
2014-06-24  1:26     ` Stefan Monnier
2014-06-24  7:13     ` martin rudalics
2014-06-24 12:53       ` Stefan Monnier
2014-06-24 15:55         ` Eli Zaretskii
2014-06-24 17:33           ` Stefan Monnier
2014-06-24 17:59             ` Eli Zaretskii
2014-06-25  6:54           ` martin rudalics
2014-06-24 15:46       ` Eli Zaretskii
2014-06-24 17:31         ` Stefan Monnier
2014-06-24 17:56           ` Eli Zaretskii
2014-06-24 19:35             ` Stefan Monnier
2014-06-24 20:06               ` Eli Zaretskii
2014-06-24 20:29                 ` Stefan Monnier
2014-06-24 23:48                   ` Juri Linkov
2014-06-25  3:11                     ` Stefan Monnier
2014-06-26 23:49                       ` Juri Linkov
2014-06-27  2:16                         ` Stefan Monnier
2014-06-27 23:45                           ` Juri Linkov
2014-06-28  1:30                             ` Stefan Monnier
2014-06-29 23:42                               ` Juri Linkov
2014-06-30  3:29                                 ` Stefan Monnier
2014-06-24 23:42             ` Juri Linkov
2014-06-25  6:54         ` martin rudalics
2014-06-24 23:44       ` bug#17809: 24.4.50; Completions display Juri Linkov
2014-06-25  6:54         ` martin rudalics
2014-06-26 23:41           ` Juri Linkov
2014-06-27  2:07             ` Stefan Monnier
2014-06-27  6:43               ` martin rudalics
2014-06-27 23:54                 ` Juri Linkov
2014-06-28  8:18                   ` martin rudalics
2014-06-29 23:47                     ` Juri Linkov
2014-07-01 23:30                     ` Juri Linkov
2014-07-04 23:40                     ` Juri Linkov
2014-07-06  4:32                       ` Stefan Monnier
2014-07-06 23:32                         ` Juri Linkov
2014-07-07  1:21                           ` Stefan Monnier
2014-07-07  1:24                           ` Stefan Monnier
2014-07-07  6:49                             ` Juri Linkov [this message]
2014-07-08  3:43                               ` Stefan Monnier
2014-07-08  8:03                                 ` Juri Linkov
2014-06-27  6:43             ` martin rudalics
2014-06-27 23:53               ` Juri Linkov
2014-06-28  8:17                 ` martin rudalics
2014-06-23 23:21   ` bug#17831: 24.4.50; bad default value for `Man-width' Leo Liu
  -- strict thread matches above, loose matches on Subject: below --
2014-06-19  6:57 bug#17809: 24.4.50; Completions display Juri Linkov
2014-06-23 23:53 ` Juri Linkov
2014-10-05 22:02 ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877g3p64up.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=17809@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).