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

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

Re: Using key q to quit temporary buffer window


From: Jean Louis
Subject: Re: Using key q to quit temporary buffer window
Date: Wed, 24 Aug 2022 13:41:47 +0300
User-agent: Mutt/+ () (2022-06-11)

* uzibalqa <uzibalqa@proton.me> [2022-08-24 10:21]:
> I have reverted back to using `with-output-to-temp-buffer' but taking out
> `pop-to-buffer' from inside `with-output-to-temp-buffer'.  Then hitting
> `q' gets me to quit the buffer and its window.
> 
> Here is the updated function
> 
> (defun help-show (buf msg)
>   "Display the output of MSG"
> 
>   (when (stringp msg)
>     (with-output-to-temp-buffer buf
>       (princ msg))
>     (pop-to-buffer buf)))

If you review description of the function `with-output-to-temp-buffer'
it will tell you:

,----
| It does not make the buffer current for BODY.  Instead it binds
| ‘standard-output’ to that buffer, so that output generated with
| ‘prin1’ and similar functions in BODY goes into the buffer.
| 
| At the end of BODY, this marks buffer BUFNAME unmodified and displays
| it in a window, but does not select it.
`----

That means it is for some kind of messages, but not to put the buffer
at front.

I am using similar function here below `rcd-message', as I want
messages from my programs not only in the default message buffer but
in my own, with date and time of message.

(defcustom rcd-message-active t
  "Utilize `rcd-message-buffer' if TRUE."
  :group 'rcd
  :type 'boolean)

(defvar rcd-message-buffer "*RCD Message Buffer*"
  "Default RCD Utilities message buffer.")

(defun rcd-message (format-string &rest message)
  (let ((current (current-buffer))
        (format-string (concat (rcd-timestamp) " " format-string)))
    (when rcd-message-active
      (get-buffer-create rcd-message-buffer)
      (switch-to-buffer rcd-message-buffer)
      (goto-char (point-max))
      (insert 
       (apply 'format format-string message)
       "\n")
      (goto-char (point-max))
      (switch-to-buffer current))
    (apply 'message format-string message)))

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



reply via email to

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