GNU bug report logs - #48798
26.3; `define-minor-mode': Message should name the current buffer where enabled/disabled

Previous Next

Package: emacs;

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

Date: Wed, 2 Jun 2021 19:37:02 UTC

Severity: wishlist

Tags: moreinfo

Found in version 26.3

Done: Lars Ingebrigtsen <larsi <at> gnus.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 48798 in the body.
You can then email your comments to 48798 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#48798; Package emacs. (Wed, 02 Jun 2021 19:37: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, 02 Jun 2021 19:37: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" <bug-gnu-emacs <at> gnu.org>
Subject: 26.3; `define-minor-mode': Message should name the current buffer
 where enabled/disabled
Date: Wed, 2 Jun 2021 19:36:22 +0000
A user can easily think s?he's in one window when another is actually
selected.  Or s?he can think that the buffer in the selected window is a
different one from what it actually is.

The confirmation/status message you get when you toggle a (local) minor
mode just tells you that the mode is enabled or disabled "in the current
buffer".  It should provide more help than that, naming the buffer.
That confirms what you expected or lets you know that you were wrong
about your expectation.

For example, when you use `C-x C-q', it's better to see "Read-Only mode
enabled in buffer `foobar'" than it is to see "Read-Only mode enabled in
current buffer".  Just that bit of information and reassurance can help.

Without bothering with a complete patch, I think this is the only code
change needed, in library `easy-mmode.el':

  (let ((local ,(if globalp "" " in current buffer")))

should be 

  (let ((local ,(if globalp
                    ""
                  '(format " in buffer `%s'" (current-buffer)))))

In GNU Emacs 26.3 (build 1, x86_64-w64-mingw32)
 of 2019-08-29
Repository revision: 96dd0196c28bc36779584e47fffcca433c9309cd
Windowing system distributor `Microsoft Corp.', version 10.0.19041
Configured using:
 `configure --without-dbus --host=x86_64-w64-mingw32
 --without-compress-install 'CFLAGS=-O2 -static -g3''





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48798; Package emacs. (Wed, 02 Jun 2021 21:01:02 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: Drew Adams <drew.adams <at> oracle.com>, "48798 <at> debbugs.gnu.org"
 <48798 <at> debbugs.gnu.org>
Subject: RE: 26.3; `define-minor-mode': Message should name the current buffer
 where enabled/disabled
Date: Wed, 2 Jun 2021 20:59:56 +0000
In case the argument wasn't sufficiently
persuasive, please consider this:

When you load a Lisp file, including when you
just load the file that's visited in the current
buffer (i.e., `M-x load-file RET'), Emacs always
tells you which file was loaded:

 Loading /some/directory/foobar.el (source)...done

Now imagine that Emacs wasn't so helpful, but
just echoed this each time:

  Loading current file...done

or

  Loading file visited in current buffer...done

Emacs can do better for minor-mode toggling also.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48798; Package emacs. (Thu, 03 Jun 2021 08:07:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 48798 <at> debbugs.gnu.org
Subject: Re: bug#48798: 26.3; `define-minor-mode': Message should name the
 current buffer where enabled/disabled
Date: Thu, 03 Jun 2021 10:06:16 +0200
Drew Adams <drew.adams <at> oracle.com> writes:

> Without bothering with a complete patch, I think this is the only code
> change needed, in library `easy-mmode.el':
>
>   (let ((local ,(if globalp "" " in current buffer")))
>
> should be 
>
>   (let ((local ,(if globalp
>                     ""
>                   '(format " in buffer `%s'" (current-buffer)))))

Here's the patch, since Drew couldn't be bothered:

diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
index 0a6d4ec504..4308272e42 100644
--- a/lisp/emacs-lisp/easy-mmode.el
+++ b/lisp/emacs-lisp/easy-mmode.el
@@ -360,7 +360,10 @@ define-minor-mode
                     (unless (and (current-message)
                                  (not (equal ,last-message
                                              (current-message))))
-                      (let ((local ,(if globalp "" " in current buffer")))
+                      (let ((local ,(if globalp
+                                        ""
+                                      '(format " in buffer `%s'"
+                                               (current-buffer)))))
 			(message ,(format "%s %%sabled%%s" pretty-name)
 			         (if ,getter "en" "dis") local)))))
 	      ,@(when after-hook `(,after-hook)))

But after running with this for a few minutes, I'm not sure I like it.
`C-x C-q' then says "Read-Only mode enabled in buffer `foo'" which makes
me wonder, of course, "why?  what happened to foo?  oh, this is that
buffer".

I.e., it's distracting, not useful information.

So I'm leaning towards leaving it the was it was.  Any opinions?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 03 Jun 2021 08:07:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48798; Package emacs. (Thu, 01 Jul 2021 11:46:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 48798 <at> debbugs.gnu.org
Subject: Re: bug#48798: 26.3; `define-minor-mode': Message should name the
 current buffer where enabled/disabled
Date: Thu, 01 Jul 2021 13:45:20 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> I.e., it's distracting, not useful information.
>
> So I'm leaning towards leaving it the was it was.  Any opinions?

Nobody had any in a month, so I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug closed, send any further explanations to 48798 <at> debbugs.gnu.org and Drew Adams <drew.adams <at> oracle.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 01 Jul 2021 11:46:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48798; Package emacs. (Thu, 01 Jul 2021 14:17:01 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: "48798 <at> debbugs.gnu.org" <48798 <at> debbugs.gnu.org>
Subject: RE: [External] : Re: bug#48798: 26.3; `define-minor-mode': Message
 should name the current buffer where enabled/disabled
Date: Thu, 1 Jul 2021 14:16:47 +0000
> > I.e., it's distracting, not useful information.
> >
> > So I'm leaning towards leaving it the was it was.  Any opinions?
> 
> Nobody had any in a month, so I'm closing this bug report.

Too bad.  All you had to do was _add_ the buffer name,
_along with_ "current buffer" which was already there.

With your logic, the message when loading the file of
the current buffer should also _not_ report the file
name.  E.g. `M-x load-file RET' should not tell you
which file was load because (according to you), that
info is just noise and it's obvious which buffer was
current and thus which file was loaded.  Fortunately,
whoever wrote the load-file msg didn't use such logic.

Dommage.








bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 30 Jul 2021 11:24:11 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Drew Adams <drew.adams <at> oracle.com> to control <at> debbugs.gnu.org. (Sat, 16 Oct 2021 21:56:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48798; Package emacs. (Sat, 16 Oct 2021 21:58:02 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: Drew Adams <drew.adams <at> oracle.com>, Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: "33076 <at> debbugs.gnu.org" <33076 <at> debbugs.gnu.org>,
 "48798 <at> debbugs.gnu.org" <48798 <at> debbugs.gnu.org>
Subject: Re: bug#48798: 26.3; `define-minor-mode': Message should name the
 current buffer where enabled/disabled
Date: Sat, 16 Oct 2021 21:57:53 +0000
The same problem persists - bugs #33076 and #48798.

It's quite possible to not notice - or even not be
able to easily see - which buffer is current when
it's changed to/from read-only.  It  just makes
sense to tell users which buffer is involved.

Really hard to believe this isn't obvious and the 
trivial fix wasn't applied.  This just makes life
that much harder for users, with no benefit to Emacs.




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

bug unarchived. Request was from Drew Adams <drew.adams <at> oracle.com> to control <at> debbugs.gnu.org. (Sat, 28 Jan 2023 21:45:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48798; Package emacs. (Sat, 28 Jan 2023 21:57:02 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: "33076 <at> debbugs.gnu.org" <33076 <at> debbugs.gnu.org>,
 "48798 <at> debbugs.gnu.org" <48798 <at> debbugs.gnu.org>
Subject: RE: bug#48798: 26.3; `define-minor-mode': Message should name the
 current buffer where enabled/disabled
Date: Sat, 28 Jan 2023 21:55:54 +0000
> The same problem persists - bugs #33076 and #48798.
> 
> It's quite possible to not notice - or even not be
> able to easily see - which buffer is current when
> it's changed to/from read-only.  It  just makes
> sense to tell users which buffer is involved.
> 
> Really hard to believe this isn't obvious and the
> trivial fix wasn't applied.  This just makes life
> that much harder for users, with no benefit to Emacs.

Perhaps the problem is more noticeable if buffers
are in separate frames.  Especially since Emacs
has messed with frame focus so much (since Emacs
26, at least).  If the buffer you thought was
current with its window selected is not, for some
reason (e.g. gratuitous Emacs frame-focus switch),
then the message doesn't help at all if you have
multiple buffers in separate frames etc.

I'm guessing that this might be why Lars didn't
think this was a real problem.  It might be less
noticeable if you're not a victim of Emacs's
gratuitous frame focus-switching.

But even if that's not the case, I see no reason
why this shouldn't be fixed.  _Whatever_ the
reason might be why someone doesn't know or isn't
sure which buffer had the focus, why not have a
message that tells you what Emacs actually did?

Please reopen this bug and apply the trivial fix.
Thx.  I'd really not like to have to redefine
`define-minor-mode' for my own use, just to fix
this annoyance.  To me, this message improvement
for users should be a no-brainer.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 26 Feb 2023 12:24:14 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Drew Adams <drew.adams <at> oracle.com> to control <at> debbugs.gnu.org. (Tue, 04 Jul 2023 15:23:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48798; Package emacs. (Tue, 04 Jul 2023 15:26:02 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: "48798 <at> debbugs.gnu.org" <48798 <at> debbugs.gnu.org>
Subject: bug#48798: 26.3; `define-minor-mode': Message should name the current
 buffer where enabled/disabled
Date: Tue, 4 Jul 2023 15:25:26 +0000
Guess I have to send this again, after unarchiving this bug (as well as 33076)?  Is it the case that if N bugs were merged then it's not enough to unarchive one of them - you need to unarchive all of them?

> > The same problem persists - bugs #33076 and #48798.
> >
> > It's quite possible to not notice - or even not be
> > able to easily see - which buffer is current when
> > it's changed to/from read-only.  It  just makes
> > sense to tell users which buffer is involved.
> >
> > Really hard to believe this isn't obvious and the
> > trivial fix wasn't applied.  This just makes life
> > that much harder for users, with no benefit to Emacs.
> 
> Perhaps the problem is more noticeable if buffers
> are in separate frames.  Especially since Emacs
> has messed with frame focus so much (since Emacs
> 26, at least).  If the buffer you thought was
> current with its window selected is not, for some
> reason (e.g. gratuitous Emacs frame-focus switch),
> then the message doesn't help at all if you have
> multiple buffers in separate frames etc.
> 
> I'm guessing that this might be why Lars didn't
> think this was a real problem.  It might be less
> noticeable if you're not a victim of Emacs's
> gratuitous frame focus-switching.
> 
> But even if that's not the case, I see no reason
> why this shouldn't be fixed.  _Whatever_ the
> reason might be why someone doesn't know or isn't
> sure which buffer had the focus, why not have a
> message that tells you what Emacs actually did?
> 
> Please reopen this bug and apply the trivial fix.
> Thx.  I'd really not like to have to redefine
> `define-minor-mode' for my own use, just to fix
> this annoyance.  To me, this message improvement
> for users should be a no-brainer.

I'm asking again that this be fixed.  I'm not
asking that such a message be changed for all
modes, i.e., a change in `define-minor-mode'.

Whether that would be appropriate is TBD - a
different question.  It could be asked, but
I'm not asking it here.
 
For this enhancement request I'm asking only
that this be fixed for `read-only-mode'.  In
various situations it can be nonobvious which
buffer's read-only state was changed.

And there's really no good reason why the
buffer name shouldn't be included in the msg.
And no objective reason was given - the only
reason given was that Lars subjectively found
the fix to be "more annoying than informative".

Whether or not the code below is the right
fix is for you to decide.  It gets the job
done and shows what the behavior should be.
I don't care how the fix gets implemented.

(defun ro-echo-buffer ()
  "Echo `buffer-read-only' value, showing buffer name."
  (message "Read-only mode is %s in buffer `%s'"
           (if buffer-read-only 'ON 'OFF)
           (current-buffer)))

(add-hook 'read-only-mode-hook 'ro-echo-buffer)

Please reconsider Emacs not letting users see
this little bit of important info in the msg.

___

As for whether ON/OFF is kosher, vs the more
verbose and less noticeable enabled/disabled:

I think it should be.  In fact, I think it's
preferable, at least in a message.  And Emacs
itself sometimes says that a mode is "active"
instead of "enabled".  (e.g. allout.el,
autorevert.el)  I think uppercase ON and OFF
stand out clearly in such a message, and that
helps.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 02 Aug 2023 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 239 days ago.

Previous Next


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