GNU bug report logs - #17109
24.4.50; REGRESSION: `with-output-to-temp-buffer' is broken

Previous Next

Package: emacs;

Reported by: Drew Adams <drew.adams <at> oracle.com>

Date: Wed, 26 Mar 2014 20:09:01 UTC

Severity: normal

Tags: confirmed

Merged with 16038, 17966

Found in versions 24.3, 24.4.50

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 17109 in the body.
You can then email your comments to 17109 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#17109; Package emacs. (Wed, 26 Mar 2014 20:09:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Drew Adams <drew.adams <at> oracle.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 26 Mar 2014 20:09:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.4.50; REGRESSION: `with-output-to-temp-buffer' is broken
Date: Wed, 26 Mar 2014 13:08:25 -0700 (PDT)
In a build as recent as this one there was no such problem:

In GNU Emacs 24.4.50.1 (i686-pc-mingw32)
 of 2014-03-21 on ODIEONE
Bzr revision: 116829 dancol <at> dancol.org-20140321121023-5tjxtiws6qa4qyod
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --prefix=/c/Devel/emacs/snapshot/trunk
 --enable-checking=yes,glyphs 'CFLAGS=-O0 -g3' 'CPPFLAGS=-DGC_MCHECK=1
 -Ic:/Devel/emacs/include' LDFLAGS=-Lc:/Devel/emacs/lib'

The problem exists in this build:

In GNU Emacs 24.4.50.1 (i686-pc-mingw32)
 of 2014-03-23 on ODIEONE
Bzr revision: 116869 yamaoka <at> jpl.org-20140324004210-m3ek4k40qwamyabx
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --prefix=/c/Devel/emacs/snapshot/trunk
 --enable-checking=yes,glyphs 'CFLAGS=-O0 -g3'
 LDFLAGS=-Lc:/Devel/emacs/lib 'CPPFLAGS=-DGC_MCHECK=1
 -Ic:/Devel/emacs/include''

Recipe:

emacs -Q

Evaluate this:


(defun describe-keymap (keymap)         ; Bound to `C-h M-k'
  "Describe bindings in KEYMAP, a variable whose value is a keymap.
Completion is available for the keymap name."
  (interactive
   (list (intern
          (completing-read
           "Keymap: " obarray
           (lambda (m) (and (boundp m)
                       (keymapp (symbol-value m))))
           t nil 'variable-name-history))))
  (unless (and (symbolp keymap)  (boundp keymap)
               (keymapp (symbol-value keymap)))
    (error "`%S' is not a keymapp" keymap))
  (let ((name  (symbol-name keymap))
        (doc   (documentation-property
                keymap 'variable-documentation)))
    (help-setup-xref
     (list #'describe-keymap keymap)
     (called-interactively-p 'interactive))
    (with-output-to-temp-buffer "*Help*" ; NO GOOD with this
      ;; (with-help-window "*Help*" ; <======== OK with this
      (princ name) (terpri)
      (princ (make-string (length name) ?-))
      (terpri) (terpri)
      (when doc
        (princ doc) (terpri) (terpri))
      (with-current-buffer "*Help*"
        (insert (substitute-command-keys
                 (concat "\\{" name "}")))))))

M-x describe-keymap RET ctl-x-map RET

Buffer *Help* is not in Help mode, as it should be.
It is in Fundamental mode.

Change `with-output-to-temp-buffer' to `with-help-window' and the
problem goes away.

This does not seem right.  We should not have to replace the former with
the latter everywhere.  And the former still exists.  It just does not
do the right thing anymore.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17109; Package emacs. (Thu, 27 Mar 2014 00:06:01 GMT) Full text and rfc822 format available.

Message #8 received at 17109 <at> debbugs.gnu.org (full text, mbox):

From: Leo Liu <sdl.web <at> gmail.com>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 17109 <at> debbugs.gnu.org
Subject: Re: bug#17109: 24.4.50;
 REGRESSION: `with-output-to-temp-buffer' is broken
Date: Thu, 27 Mar 2014 08:05:24 +0800
On 2014-03-27 04:08 +0800, Drew Adams wrote:
> In a build as recent as this one there was no such problem:

See bug#16038 on why with-output-to-temp-buffer is no longer associated
with help mode. You can use any major mode.

Leo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17109; Package emacs. (Thu, 27 Mar 2014 01:54:01 GMT) Full text and rfc822 format available.

Message #11 received at 17109 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Leo Liu <sdl.web <at> gmail.com>
Cc: 17109 <at> debbugs.gnu.org
Subject: RE: bug#17109: 24.4.50; REGRESSION: `with-output-to-temp-buffer' is
 broken
Date: Wed, 26 Mar 2014 18:52:54 -0700 (PDT)
> > In a build as recent as this one there was no such problem:
> 
> See bug#16038 on why with-output-to-temp-buffer is no longer 
> associated with help mode.  You can use any major mode.

It should still be associated with help mode.  That's how you
preserve its behavior.  If you want to give it additional,
alternative, optional behavior then add that, but do not change
the default behavior.  It has been "associated with help mode"
for 30 years.  That's what it does.  That's what it's for (yes,
in spite of its poor name).

Please revert this incompatible change.

From your own post to the #16038 thread: "We are trying to
consolidate the features of the two macros into one
so no feature is lost."
^^^^^^^^^^^^^^^^^^^^^

Well bug #17109 shows that you've changed
`with-output-to-temp-buffer' in an incompatible way, which
contradicts your claim of not losing its behavior.

If you want new, incompatible behavior, come up with a
different, new macro.  Why screw `with-output-to-temp-buffer'?
There is no reason to change its behavior - ESPECIALLY if you
want to eventually make it obsolete.

This just gets worse and worse.  Emacs has already added
`with-help-window'.  Fine.  Add another one if you need it.
But why must you mess with existing behavior like this?

Create as many new functions and macros as you like, but do you
need to be introducing incompatible behavior changes like this to
existing functions & macros?

Martin said: "`with-help-window' does some things differently
which I could not put into `with-output-to-temp-buffer' due to
compatibility issues."

And so what has now happened to this precious
`with-output-to-temp-buffer' compatibility?  Out the window!

You persisted: "The more interesting question is is it possible
to merge these two macros?"  That is not "the more interesting
question".  Just misguided.

In the #16038 thread, I said, "Incorporate whatever you feel
you need to into `with-output-to-temp-buffer', as long as
"no feature is lost" from it."  And now it is broken.

What should have happened, to start with, is to fix bug #8368.

And you have still NOT deprecated `with-output-to-temp-buffer'.
As I said in the #16038 thread:

  If `with-output-to-temp-buffer' is deprecated, we should
  learn in the NEWS that this is the case AND what it is
  replaced by. IOW, tell users how to update their code.
  Likewise for the misnamed hooks etc.

  Instead, at least so far, NEWS has only this: 

    *** New macro `with-temp-buffer-window', similar to
    `with-output-to-temp-buffer'.

And I said:

  If `with-temp-buffer-window' is supposed to be the replacement
  for `with-output-to-temp-buffer' then that needs to be stated
  clearly in the NEWS.

  Including a spec of what the replacement should be for different
  `with-output-to-temp-buffer' input patterns (formal parameters).
  And including hook use (correspondences).  With any significant
  differences and limitations pointed out.

  That is how to help users transition from the old to the new.
  I imagine that you are well aware of that, but it's perhaps
  better not to guess.

And:

  What `with-output-to-temp-buffer' patterns map to what
  `with-temp-buffer-window' patterns?   What about the various
  hooks?

So you feel fine just breaking the behavior of
`with-output-to-temp-buffer' and not deprecating it.  And not
telling users how to get the equivalent of the old behavior,
IOW how to fix their code that you've now broken by changing
what `with-output-to-temp-buffer' does.

This is madness.  Leave `with-output-to-temp-buffer' alone.
Use new code however you like.  But don't gratuitously break
the old code that you want to eventually make obsolete.

Can you imagine if a company did that to paying customers
with existing code?  Emacs users don't pay you for their
software, but that shouldn't make you feel free to screw
them and just make gratuitous changes willy nilly.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17109; Package emacs. (Thu, 27 Mar 2014 09:56:01 GMT) Full text and rfc822 format available.

Message #14 received at 17109 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Richard <theonewiththeevillook <at> yahoo.fr>
To: Leo Liu <sdl.web <at> gmail.com>
Cc: 17109 <at> debbugs.gnu.org, Drew Adams <drew.adams <at> oracle.com>
Subject: Re: bug#17109: 24.4.50;
 REGRESSION: `with-output-to-temp-buffer' is broken
Date: Thu, 27 Mar 2014 10:55:57 +0100
Leo Liu <sdl.web <at> gmail.com> writes:

> On 2014-03-27 04:08 +0800, Drew Adams wrote:
>> In a build as recent as this one there was no such problem:
>
> See bug#16038 on why with-output-to-temp-buffer is no longer associated
> with help mode. You can use any major mode.

(Bug#16816, Bug#17007) are also relevant. See lisp/ChangeLog for the log
of the various changes and reversions.

-- 
Nico.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17109; Package emacs. (Thu, 27 Mar 2014 15:10:01 GMT) Full text and rfc822 format available.

Message #17 received at 17109 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Nicolas Richard <theonewiththeevillook <at> yahoo.fr>, Leo Liu
 <sdl.web <at> gmail.com>
Cc: 17109 <at> debbugs.gnu.org
Subject: RE: bug#17109: 24.4.50; REGRESSION: `with-output-to-temp-buffer' is
 broken
Date: Thu, 27 Mar 2014 08:09:23 -0700 (PDT)
> >> In a build as recent as this one there was no such problem:
> >
> > See bug#16038 on why with-output-to-temp-buffer is no longer associated
> > with help mode. You can use any major mode.
> 
> (Bug#16816, Bug#17007) are also relevant. See lisp/ChangeLog for the log
> of the various changes and reversions.

Well, those are apparently relevant to the various changes that have
been made, but they are not so relevant to *this* bug report.

This is the point:

1. `with-output-to-temp-buffer' is poorly named.  No question about
that.  I was among the first to mention it.

2. That is NOT a reason to change its *behavior*.

3. Create a better-named alias for it, expressing what it really
does, which concerns the *Help* buffer (not just any old temporary
buffer).

You can even *deprecate* the old name (continuing to support it,
of course) in favor of the more accurate name.

4. You can also create one or more new macros with different
behavior, which you prefer, and use those in vanilla Emacs code in
place of `with-output-to-temp-buffer`, adapting the surrounding code
to fit the different behavior of the new macro(s).

That would all be OK.  And it has all been discussed in the various
bug threads cited.

5. What you must NOT do is change the behavior of the existing macro,
so that any code that uses it breaks.

It is not because the macro does not live up to its unfortunate name
that you should change the behavior, including changing it to better
reflect the name.  Far from it.

And that is just what you've done: change the behavior. That is the
regression that *this* bug report is about.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17109; Package emacs. (Fri, 28 Mar 2014 21:46:01 GMT) Full text and rfc822 format available.

Message #20 received at 17109 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Nicolas Richard <theonewiththeevillook <at> yahoo.fr>, Leo Liu
 <sdl.web <at> gmail.com>
Cc: 17109 <at> debbugs.gnu.org
Subject: RE: bug#17109: 24.4.50; REGRESSION: `with-output-to-temp-buffer' is
 broken
Date: Fri, 28 Mar 2014 14:45:35 -0700 (PDT)
> 5. What you must NOT do is change the behavior of the existing macro,
> so that any code that uses it breaks.

I *really* hope that someone please takes this regression seriously.

I have lots of code that defines help functions of different kinds,
and it all uses `with-output-to-temp-buffer'.  And it all needs to
work across multiple Emacs versions.

For example, Bookmark+ has a command `bmkp-describe-bookmark'.
It does various things, but the first thing it does is this:

(with-output-to-temp-buffer "*Help*" (princ help-text))

That's a standard Emacs idiom, and has been so for decades.

Now it is broken.  Buffer *Help* ends up in Fundamental mode.
This should not be so.

I do not understand why anyone would change the behavior of
a macro such as `with-output-to-temp-buffer'.  There are plenty
of other ways to get whatever new behavior you want, without
doing that.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17109; Package emacs. (Sat, 29 Mar 2014 01:00:03 GMT) Full text and rfc822 format available.

Message #23 received at 17109 <at> debbugs.gnu.org (full text, mbox):

From: Leo Liu <sdl.web <at> gmail.com>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: Nicolas Richard <theonewiththeevillook <at> yahoo.fr>, 17109 <at> debbugs.gnu.org
Subject: Re: bug#17109: 24.4.50;
 REGRESSION: `with-output-to-temp-buffer' is broken
Date: Sat, 29 Mar 2014 08:58:40 +0800
On 2014-03-29 05:45 +0800, Drew Adams wrote:
> (with-output-to-temp-buffer "*Help*" (princ help-text))

Does (with-help-window (help-buffer) (princ help-text)) work for you?

Leo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17109; Package emacs. (Sat, 29 Mar 2014 01:40:02 GMT) Full text and rfc822 format available.

Message #26 received at 17109 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Leo Liu <sdl.web <at> gmail.com>
Cc: Nicolas Richard <theonewiththeevillook <at> yahoo.fr>, 17109 <at> debbugs.gnu.org
Subject: RE: bug#17109: 24.4.50; REGRESSION: `with-output-to-temp-buffer' is
 broken
Date: Fri, 28 Mar 2014 18:39:17 -0700 (PDT)
> > (with-output-to-temp-buffer "*Help*" (princ help-text))
> 
> Does (with-help-window (help-buffer) (princ help-text)) work for you?

Which part of "regression" and "it needs to work across multiple
Emacs versions" do you not understand?

I have lots of occurrences of `with-output-to-temp-buffer', and
I am only one maintainer of some 3rd-party code.

And `with-output-to-temp-buffer' is not even deprecated.  And
even if it were deprecated now, it should still be supported as is
until desupported.  And support does not mean changing its behavior
so code that uses it no longer works.  And desupport does not mean
keeping it around but with a broken behavior.

There is _no_ scenario in which it should be broken.

Emacs can reasonably come up with and use new, different macros.
What it cannot reasonably do is break this macro.  IIUC, Emacs
code does not even need to use this macro anymore.  Why on Earth
gratuitously break code that does use it?

This should be a no-brainer.




Forcibly Merged 16038 17109 17966. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 09 Aug 2014 20:31:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 07 Sep 2014 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 282 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.