all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#16816: 24.3.50; erroneous docstring in with-temp-buffer-window
@ 2014-02-19 21:29 Nicolas Richard
  2014-02-21 13:08 ` martin rudalics
  2014-02-28 10:59 ` martin rudalics
  0 siblings, 2 replies; 11+ messages in thread
From: Nicolas Richard @ 2014-02-19 21:29 UTC (permalink / raw)
  To: 16816

The docstring of `with-temp-buffer-window' contains :

   It does not make the buffer current for BODY.

(2nd sentence of 2nd paragraph).

But I think that is wrong, because :
(with-temp-buffer-window
        (get-buffer-create "foo")
        nil
        nil
        (message "curbuf: %s"
                 (current-buffer)))

outputs "curbuf: foo"

If this is a docbug, here's a suggestion :

--- a/lisp/window.el
+++ b/lisp/window.el
@@ -149,10 +149,9 @@ BUFFER-OR-NAME must specify either a live buffer, or the name of a
 buffer (if it does not exist, this macro creates it).
 
 This construct makes buffer BUFFER-OR-NAME empty before running BODY.
-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.
+It makes the buffer current for BODY and 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 the specified buffer unmodified and
 read-only, and displays it in a window (but does not select it, or make



-- 
Nico.





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#16816: 24.3.50; erroneous docstring in with-temp-buffer-window
  2014-02-19 21:29 bug#16816: 24.3.50; erroneous docstring in with-temp-buffer-window Nicolas Richard
@ 2014-02-21 13:08 ` martin rudalics
  2014-02-27 15:32   ` Juanma Barranquero
  2014-02-28 10:59 ` martin rudalics
  1 sibling, 1 reply; 11+ messages in thread
From: martin rudalics @ 2014-02-21 13:08 UTC (permalink / raw)
  To: Nicolas Richard; +Cc: 16816

 > The docstring of `with-temp-buffer-window' contains :
 >
 >    It does not make the buffer current for BODY.
 >
 > (2nd sentence of 2nd paragraph).
 >
 > But I think that is wrong, because :
 > (with-temp-buffer-window
 >         (get-buffer-create "foo")
 >         nil
 >         nil
 >         (message "curbuf: %s"
 >                  (current-buffer)))
 >
 > outputs "curbuf: foo"
 >
 > If this is a docbug, here's a suggestion :
 >
 > --- a/lisp/window.el
 > +++ b/lisp/window.el
 > @@ -149,10 +149,9 @@ BUFFER-OR-NAME must specify either a live buffer, or the name of a
 >  buffer (if it does not exist, this macro creates it).
 >
 >  This construct makes buffer BUFFER-OR-NAME empty before running BODY.
 > -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.
 > +It makes the buffer current for BODY and 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 the specified buffer unmodified and
 >  read-only, and displays it in a window (but does not select it, or make

`with-temp-buffer-window' should behave as `with-output-to-temp-buffer'
in this regard (at least I hope so).  So in revision 116509 I moved the
evaluation of BODY out of the scope of `with-current-buffer'.  If this
causes problems, I will revert and use your patch.

Thanks, martin





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#16816: 24.3.50; erroneous docstring in with-temp-buffer-window
  2014-02-21 13:08 ` martin rudalics
@ 2014-02-27 15:32   ` Juanma Barranquero
  2014-02-27 18:44     ` martin rudalics
  2014-03-16 10:00     ` martin rudalics
  0 siblings, 2 replies; 11+ messages in thread
From: Juanma Barranquero @ 2014-02-27 15:32 UTC (permalink / raw)
  To: martin rudalics; +Cc: Nicolas Richard, 16816

reopen 16816
quit

On Fri, Feb 21, 2014 at 2:08 PM, martin rudalics <rudalics@gmx.at> wrote:

> `with-temp-buffer-window' should behave as `with-output-to-temp-buffer'
> in this regard (at least I hope so).  So in revision 116509 I moved the
> evaluation of BODY out of the scope of `with-current-buffer'.  If this
> causes problems, I will revert and use your patch.

This breaks with-help-window. Try

 emacs -Q
 C-x C-h

the help output is inserted in the current buffer (*scratch*, in this case).

This patch fixes it.

=== modified file 'lisp/help.el'
--- lisp/help.el 2014-02-10 01:34:22 +0000
+++ lisp/help.el 2014-02-27 15:29:05 +0000
@@ -1207,7 +1207,8 @@
    (temp-buffer-window-show-hook
     (cons 'help-mode-finish temp-buffer-window-show-hook)))
        (with-temp-buffer-window
- ,buffer-name nil 'help-window-setup (progn ,@body)))))
+ ,buffer-name nil 'help-window-setup
+ (with-current-buffer ,buffer-name ,@body)))))

 ;; Called from C, on encountering `help-char' when reading a char.
 ;; Don't print to *Help*; that would clobber Help history.





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#16816: 24.3.50; erroneous docstring in with-temp-buffer-window
  2014-02-27 15:32   ` Juanma Barranquero
@ 2014-02-27 18:44     ` martin rudalics
  2014-02-27 18:55       ` Juanma Barranquero
  2014-03-16 10:00     ` martin rudalics
  1 sibling, 1 reply; 11+ messages in thread
From: martin rudalics @ 2014-02-27 18:44 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: Nicolas Richard, 16816

 > This breaks with-help-window. Try
 >
 >  emacs -Q
 >  C-x C-h
 >
 > the help output is inserted in the current buffer (*scratch*, in this case).

Yes.  A lousy bug.  I introduced it last year relying on the misfeature
that `with-temp-buffer-window' makes the help buffer current.  Does the
following patch fix it?

=== modified file 'lisp/help.el'
--- lisp/help.el	2014-02-10 01:34:22 +0000
+++ lisp/help.el	2014-02-27 18:31:30 +0000
@@ -498,7 +498,8 @@
  then we display only bindings that start with that prefix."
    (let ((buf (current-buffer)))
      (with-help-window (help-buffer)
-      (describe-buffer-bindings buf prefix menus))))
+      (with-current-buffer (help-buffer)
+	(describe-buffer-bindings buf prefix menus)))))

  (defun where-is (definition &optional insert)
    "Print message listing key sequences that invoke the command DEFINITION.

 > This patch fixes it.
 >
 > === modified file 'lisp/help.el'
 > --- lisp/help.el 2014-02-10 01:34:22 +0000
 > +++ lisp/help.el 2014-02-27 15:29:05 +0000
 > @@ -1207,7 +1207,8 @@
 >     (temp-buffer-window-show-hook
 >      (cons 'help-mode-finish temp-buffer-window-show-hook)))
 >         (with-temp-buffer-window
 > - ,buffer-name nil 'help-window-setup (progn ,@body)))))
 > + ,buffer-name nil 'help-window-setup
 > + (with-current-buffer ,buffer-name ,@body)))))
 >
 >  ;; Called from C, on encountering `help-char' when reading a char.
 >  ;; Don't print to *Help*; that would clobber Help history.
 >

This would restore what we had till now: BODY would get evaluated in the
help buffer and not in the original buffer.  I doubt this could have any
serious consequences (Emacs 24.3 runs this already for quite some time)
but it's inherently disturbing.

martin





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#16816: 24.3.50; erroneous docstring in with-temp-buffer-window
  2014-02-27 18:44     ` martin rudalics
@ 2014-02-27 18:55       ` Juanma Barranquero
  2014-02-27 20:00         ` martin rudalics
  2014-02-28 10:58         ` martin rudalics
  0 siblings, 2 replies; 11+ messages in thread
From: Juanma Barranquero @ 2014-02-27 18:55 UTC (permalink / raw)
  To: martin rudalics; +Cc: Nicolas Richard, 16816

On Thu, Feb 27, 2014 at 7:44 PM, martin rudalics <rudalics@gmx.at> wrote:

> Does the following patch fix it?

Yes.

> This would restore what we had till now: BODY would get evaluated in the
> help buffer and not in the original buffer.  I doubt this could have any
> serious consequences (Emacs 24.3 runs this already for quite some time)
> but it's inherently disturbing.

You're right, I suppose.

BTW, the docstring of with-help-window isn't exactly clear to me...

  Display buffer with name BUFFER-NAME in a help window evaluating BODY.

Evaluating BODY in a help window? What does this mean?

     J





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#16816: 24.3.50; erroneous docstring in with-temp-buffer-window
  2014-02-27 18:55       ` Juanma Barranquero
@ 2014-02-27 20:00         ` martin rudalics
  2014-02-27 21:04           ` Drew Adams
  2014-02-28 10:58         ` martin rudalics
  1 sibling, 1 reply; 11+ messages in thread
From: martin rudalics @ 2014-02-27 20:00 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: Nicolas Richard, 16816

 > BTW, the docstring of with-help-window isn't exactly clear to me...
 >
 >   Display buffer with name BUFFER-NAME in a help window evaluating BODY.
 >
 > Evaluating BODY in a help window? What does this mean?

Drew's getting old.  Such an awful doc-string and he apparently never
complained ...

I'll have to fix the info entry too.  It doesn't even say that the
buffer gets displayed.

martin





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#16816: 24.3.50; erroneous docstring in with-temp-buffer-window
  2014-02-27 20:00         ` martin rudalics
@ 2014-02-27 21:04           ` Drew Adams
  0 siblings, 0 replies; 11+ messages in thread
From: Drew Adams @ 2014-02-27 21:04 UTC (permalink / raw)
  To: martin rudalics, Juanma Barranquero; +Cc: Nicolas Richard, 16816

>  > BTW, the docstring of with-help-window isn't exactly clear to me...
>  >   Display buffer with name BUFFER-NAME in a help window evaluating BODY.
>  > Evaluating BODY in a help window? What does this mean?
> 
> Drew's getting old.

Everyone's getting old, from Day Zero on.

> Such an awful doc-string and he apparently never complained ...

So many bugs, so little time.  Fortunately, Juanma is there.





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#16816: 24.3.50; erroneous docstring in with-temp-buffer-window
  2014-02-27 18:55       ` Juanma Barranquero
  2014-02-27 20:00         ` martin rudalics
@ 2014-02-28 10:58         ` martin rudalics
  1 sibling, 0 replies; 11+ messages in thread
From: martin rudalics @ 2014-02-28 10:58 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: Nicolas Richard, 16816

 >> This would restore what we had till now: BODY would get evaluated in the
 >> help buffer and not in the original buffer.  I doubt this could have any
 >> serious consequences (Emacs 24.3 runs this already for quite some time)
 >> but it's inherently disturbing.
 >
 > You're right, I suppose.

I reverted my previous change.  It's too dangerous as the bug you
reported demonstrates.

 > BTW, the docstring of with-help-window isn't exactly clear to me...
 >
 >   Display buffer with name BUFFER-NAME in a help window evaluating BODY.
 >
 > Evaluating BODY in a help window? What does this mean?

I rewrote the doc-strings of `with-temp-buffer-window' and
`with-help-window'.  Please have a look.

martin





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#16816: 24.3.50; erroneous docstring in with-temp-buffer-window
  2014-02-19 21:29 bug#16816: 24.3.50; erroneous docstring in with-temp-buffer-window Nicolas Richard
  2014-02-21 13:08 ` martin rudalics
@ 2014-02-28 10:59 ` martin rudalics
  1 sibling, 0 replies; 11+ messages in thread
From: martin rudalics @ 2014-02-28 10:59 UTC (permalink / raw)
  To: Nicolas Richard; +Cc: 16816

 > If this is a docbug, here's a suggestion :

I made it a docbug now and largely expanded the doc-string based on your
suggestion.

martin





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#16816: 24.3.50; erroneous docstring in with-temp-buffer-window
  2014-02-27 15:32   ` Juanma Barranquero
  2014-02-27 18:44     ` martin rudalics
@ 2014-03-16 10:00     ` martin rudalics
  2014-03-22  5:19       ` Juanma Barranquero
  1 sibling, 1 reply; 11+ messages in thread
From: martin rudalics @ 2014-03-16 10:00 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: Nicolas Richard, 16816

 > This breaks with-help-window. Try
 >
 >  emacs -Q
 >  C-x C-h
 >
 > the help output is inserted in the current buffer (*scratch*, in this case).

Should be now fixed in the way I proposed initially.  Please check.

Thanks, martin





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#16816: 24.3.50; erroneous docstring in with-temp-buffer-window
  2014-03-16 10:00     ` martin rudalics
@ 2014-03-22  5:19       ` Juanma Barranquero
  0 siblings, 0 replies; 11+ messages in thread
From: Juanma Barranquero @ 2014-03-22  5:19 UTC (permalink / raw)
  To: martin rudalics; +Cc: Nicolas Richard, 16816

On Sun, Mar 16, 2014 at 11:00 AM, martin rudalics <rudalics@gmx.at> wrote:

> Should be now fixed in the way I proposed initially.  Please check.

Sorry, I forgot about this one. It works, of course.

Thanks,

   J





^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-03-22  5:19 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-19 21:29 bug#16816: 24.3.50; erroneous docstring in with-temp-buffer-window Nicolas Richard
2014-02-21 13:08 ` martin rudalics
2014-02-27 15:32   ` Juanma Barranquero
2014-02-27 18:44     ` martin rudalics
2014-02-27 18:55       ` Juanma Barranquero
2014-02-27 20:00         ` martin rudalics
2014-02-27 21:04           ` Drew Adams
2014-02-28 10:58         ` martin rudalics
2014-03-16 10:00     ` martin rudalics
2014-03-22  5:19       ` Juanma Barranquero
2014-02-28 10:59 ` martin rudalics

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.