GNU bug report logs - #51041
28.0.60; toggle-truncate-lines should not print message

Previous Next

Package: emacs;

Reported by: Tyler Grinn <tylergrinn <at> gmail.com>

Date: Tue, 5 Oct 2021 18:03:01 UTC

Severity: normal

Tags: moreinfo, wontfix

Found in version 28.0.60

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 51041 in the body.
You can then email your comments to 51041 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#51041; Package emacs. (Tue, 05 Oct 2021 18:03:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tyler Grinn <tylergrinn <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 05 Oct 2021 18:03:01 GMT) Full text and rfc822 format available.

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

From: Tyler Grinn <tylergrinn <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.60; toggle-truncate-lines should not print message
Date: Tue, 05 Oct 2021 13:39:43 -0400
[Message part 1 (text/plain, inline)]
(toggle-truncate-lines t)

Prints the message "Truncate long lines enabled". When called from
elisp, this message should be ignored. If called interactively, the
message should be displayed.


[grinn-1.diff (text/x-diff, inline)]
diff --git a/lisp/simple.el b/lisp/simple.el
index 3695415163..0df66ab8a8 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -8313,13 +8313,14 @@ toggle-truncate-lines
 		      (if (eq buffer (window-buffer window))
 			  (set-window-hscroll window 0)))
 		    nil t)))
-  (message "Truncate long lines %s%s"
-	   (if truncate-lines "enabled" "disabled")
-           (if (and truncate-lines visual-line-mode)
-               (progn
-                 (visual-line-mode -1)
-                 (format-message " and `visual-line-mode' disabled"))
-             "")))
+  (let ((disable-vlm (and truncate-lines visual-line-mode)))
+    (if disable-vlm (visual-line-mode -1))
+    (if (called-interactively-p 'any)
+        (message "Truncate long lines %s%s"
+	         (if truncate-lines "enabled" "disabled")
+                 (if disable-vlm
+                     (format-message " and `visual-line-mode' disabled")
+                   "")))))
 
 (defun toggle-word-wrap (&optional arg)
   "Toggle whether to use word-wrapping for continuation lines.
[Message part 3 (text/plain, inline)]

In GNU Emacs 28.0.60 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, cairo version 1.16.0)
 of 2021-10-04 built on tyler-hp
Repository revision: 3a9d5f04fb23cc89797f5d5102607c790440201e
Repository branch: HEAD
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Debian GNU/Linux 11 (bullseye)

Configured using:
 'configure --with-mailutils --with-cairo --with-native-compilation
 --with-json --with-modules --with-gnutls --with-harfbuzz
 --with-xwidgets --prefix=/home/tyler/code/emacs 'CFLAGS=-O3
 -mtune=native -march=native -fomit-frame-pointer''

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON
LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS
X11 XDBE XIM XPM XWIDGETS GTK3 ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util rmail
rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json map text-property-search time-date
subr-x seq byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs
cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer cl-generic
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote threads
xwidget-internal dbusbind inotify dynamic-setting system-font-setting
font-render-setting cairo move-toolbar gtk x-toolkit x multi-tty
make-network-process native-compile emacs)

Memory information:
((conses 16 70085 8512)
 (symbols 48 6642 0)
 (strings 32 19589 1584)
 (string-bytes 1 672318)
 (vectors 16 14113)
 (vector-slots 8 298530 14069)
 (floats 8 22 31)
 (intervals 56 331 1)
 (buffers 992 11))


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51041; Package emacs. (Tue, 05 Oct 2021 18:35:01 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: Tyler Grinn <tylergrinn <at> gmail.com>, "51041 <at> debbugs.gnu.org"
 <51041 <at> debbugs.gnu.org>
Subject: RE: [External] : bug#51041: 28.0.60; toggle-truncate-lines should not
 print message
Date: Tue, 5 Oct 2021 18:34:39 +0000
> (toggle-truncate-lines t)
> 
> Prints the message "Truncate long lines enabled". When called from
> elisp, this message should be ignored. If called interactively, the
> message should be displayed.

Yes.

But the right fix is to add "&optional msg",
use (interactive "P\np"), and test for non-nil
MSG as the condition for showing the message.

Lisp code for a command can use that toggle
function, and when _that_ command is invoked
interactively it too might make sense to show
the message (that can depend on the command
and when the toggling occurs as part of it).

The same kind of fix is no doubt appropriate
for some other existing commands that instead
just test `called-interactively-p'.  Surely
we shouldn't perpetuate such design by adding
more such.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51041; Package emacs. (Tue, 05 Oct 2021 20:02:01 GMT) Full text and rfc822 format available.

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

From: Tyler Grinn <tylergrinn <at> gmail.com>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: "51041 <at> debbugs.gnu.org" <51041 <at> debbugs.gnu.org>
Subject: Re: bug#51041: [External] : bug#51041: 28.0.60;
 toggle-truncate-lines should not print message
Date: Tue, 05 Oct 2021 16:01:14 -0400
[Message part 1 (text/plain, inline)]
Drew Adams <drew.adams <at> oracle.com> writes:

>> (toggle-truncate-lines t)
>> 
>> Prints the message "Truncate long lines enabled". When called from
>> elisp, this message should be ignored. If called interactively, the
>> message should be displayed.
>
> Yes.
>
> But the right fix is to add "&optional msg",
> use (interactive "P\np"), and test for non-nil
> MSG as the condition for showing the message.
>
> Lisp code for a command can use that toggle
> function, and when _that_ command is invoked
> interactively it too might make sense to show
> the message (that can depend on the command
> and when the toggling occurs as part of it).
>
> The same kind of fix is no doubt appropriate
> for some other existing commands that instead
> just test `called-interactively-p'.  Surely
> we shouldn't perpetuate such design by adding
> more such.

Sounds good to me.

[grinn-2.diff (text/x-diff, inline)]
diff --git a/lisp/simple.el b/lisp/simple.el
index 3695415163..47a00fca3c 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -8294,14 +8294,15 @@ set-selective-display
 
 (defvaralias 'indicate-unused-lines 'indicate-empty-lines)
 
-(defun toggle-truncate-lines (&optional arg)
+(defun toggle-truncate-lines (&optional arg msg)
   "Toggle truncating of long lines for the current buffer.
-When truncating is off, long lines are folded.
-With prefix argument ARG, truncate long lines if ARG is positive,
-otherwise fold them.  Note that in side-by-side windows, this
-command has no effect if `truncate-partial-width-windows' is
-non-nil."
-  (interactive "P")
+When truncating is off, long lines are folded.  With prefix
+argument ARG, truncate long lines if ARG is positive, otherwise
+fold them.  When called interactively or if MSG is non-nil, print
+a message describing the new state of truncate-lines.  Note that
+in side-by-side windows, this command has no effect if
+`truncate-partial-width-windows' is non-nil."
+  (interactive "P\np")
   (setq truncate-lines
 	(if (null arg)
 	    (not truncate-lines)
@@ -8313,13 +8314,14 @@ toggle-truncate-lines
 		      (if (eq buffer (window-buffer window))
 			  (set-window-hscroll window 0)))
 		    nil t)))
-  (message "Truncate long lines %s%s"
-	   (if truncate-lines "enabled" "disabled")
-           (if (and truncate-lines visual-line-mode)
-               (progn
-                 (visual-line-mode -1)
-                 (format-message " and `visual-line-mode' disabled"))
-             "")))
+  (let ((disable-vlm (and truncate-lines visual-line-mode)))
+    (if disable-vlm (visual-line-mode -1))
+    (if msg
+        (message "Truncate long lines %s%s"
+	         (if truncate-lines "enabled" "disabled")
+                 (if disable-vlm
+                     (format-message " and `visual-line-mode' disabled")
+                   "")))))
 
 (defun toggle-word-wrap (&optional arg)
   "Toggle whether to use word-wrapping for continuation lines.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51041; Package emacs. (Tue, 05 Oct 2021 21:40:02 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefan <at> marxist.se>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: "51041 <at> debbugs.gnu.org" <51041 <at> debbugs.gnu.org>,
 Tyler Grinn <tylergrinn <at> gmail.com>
Subject: Re: bug#51041: 28.0.60; toggle-truncate-lines should not print message
Date: Tue, 5 Oct 2021 17:39:00 -0400
Drew Adams <drew.adams <at> oracle.com> writes:

>> (toggle-truncate-lines t)
>>
>> Prints the message "Truncate long lines enabled". When called from
>> elisp, this message should be ignored. If called interactively, the
>> message should be displayed.
>
> Yes.
>
> But the right fix is to add "&optional msg",
> use (interactive "P\np"), and test for non-nil
> MSG as the condition for showing the message.
>
> Lisp code for a command can use that toggle
> function, and when _that_ command is invoked
> interactively it too might make sense to show
> the message (that can depend on the command
> and when the toggling occurs as part of it).
>
> The same kind of fix is no doubt appropriate
> for some other existing commands that instead
> just test `called-interactively-p'.  Surely
> we shouldn't perpetuate such design by adding
> more such.

I don't think it's worth making the call signature of
`toggle-truncate-lines' more complicated just for the purpose of showing
a message.

Why should a different command want to show this message?  Why can't
that calling Lisp code just show an appropriate message itself?
Do we have a concrete use-case for it, or is it just a "maybe nice to
have"?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51041; Package emacs. (Tue, 05 Oct 2021 23:42:02 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: "51041 <at> debbugs.gnu.org" <51041 <at> debbugs.gnu.org>,
 Tyler Grinn <tylergrinn <at> gmail.com>
Subject: RE: [External] : Re: bug#51041: 28.0.60; toggle-truncate-lines should
 not print message
Date: Tue, 5 Oct 2021 23:41:31 +0000
> > Yes.
> >
> > But the right fix is to add "&optional msg",
> > use (interactive "P\np"), and test for non-nil
> > MSG as the condition for showing the message.
> >
> > Lisp code for a command can use that toggle
> > function, and when _that_ command is invoked
> > interactively it too might make sense to show
> > the message (that can depend on the command
> > and when the toggling occurs as part of it).
> >
> > The same kind of fix is no doubt appropriate
> > for some other existing commands that instead
> > just test `called-interactively-p'.  Surely
> > we shouldn't perpetuate such design by adding
> > more such.
> 
> I don't think it's worth making the call signature of
> `toggle-truncate-lines' more complicated just for the purpose of
> showing a message.
> 
> Why should a different command want to show this message?

Why shouldn't it?

> Why can't that calling Lisp code just show an appropriate message itself?
> Do we have a concrete use-case for it, or is it just a "maybe nice to
> have"?

Do as you like.  IMHO, using optional MSG corresponds
to our advertised suggestion and convention.  It makes
the code more flexible and more usable by other code.

(elisp) Distinguish Interactive:

  The recommended way to test whether the function
  was called using ‘call-interactively’ is to give
  it an optional argument ‘print-message’ and use
  the ‘interactive’ spec to make it non-‘nil’ in
  interactive calls.  Here’s an example:

     (defun foo (&optional print-message)
       (interactive "p")
       (when print-message
         (message "foo")))

`foo' is a command.  This is about calling `foo'
from Lisp, in particular by some other command.
That command can choose whether it makes sense,
for its own interaction, for a user to see the
message from `foo'.  `foo's signature lets the
calling command do TRT directly.

Typical use of such an approach is for a command
someone writes that does more than one thing, and
that can benefit from such reporting echoes -
multiple steps, for example.  The code making use
of such a command as a function might have no way
of knowing what/which message(s) the called command
might report.

This corresponds to what we recommend.  We do NOT
recommend testing with `called-interactively', for
example.  There's no reason to hard-code whether a
command called from Lisp can emit a message.  Using
an optional arg MSG or NOMSG is TRT.

There's lots of old code that does hard-code things
here.  `count-words' and `count-words-region' are
good examples of such bad examples.

But again, you will do what you will.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51041; Package emacs. (Wed, 06 Oct 2021 00:29:01 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefan <at> marxist.se>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: "51041 <at> debbugs.gnu.org" <51041 <at> debbugs.gnu.org>,
 Tyler Grinn <tylergrinn <at> gmail.com>
Subject: RE: [External] : Re: bug#51041: 28.0.60; toggle-truncate-lines should
 not print message
Date: Tue, 5 Oct 2021 20:28:29 -0400
Drew Adams <drew.adams <at> oracle.com> writes:

> This corresponds to what we recommend.  We do NOT
> recommend testing with `called-interactively', for
> example.  There's no reason to hard-code whether a
> command called from Lisp can emit a message.  Using
> an optional arg MSG or NOMSG is TRT.
>
> There's lots of old code that does hard-code things
> here.  `count-words' and `count-words-region' are
> good examples of such bad examples.

So this is about avoiding `called-interactively-p'?  If so, I think an
argument is indeed the way to do that.

Another solution would be to have one function meant for interactive
use, and another one for use from Lisp.  That might be too much in this
case, though, as this function seems somewhat uncommon.

A third one would be to do nothing, and say: it's up to the caller to
just call (message "") to clear the echo area, if they don't want the
message there.

But actually, isn't the way to truncate lines just to say this?

    (setq truncate-lines t)

In summary, I don't think I understand the use-case here.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51041; Package emacs. (Wed, 06 Oct 2021 09:24:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: "51041 <at> debbugs.gnu.org" <51041 <at> debbugs.gnu.org>,
 Tyler Grinn <tylergrinn <at> gmail.com>, Drew Adams <drew.adams <at> oracle.com>
Subject: Re: bug#51041: 28.0.60; toggle-truncate-lines should not print message
Date: Wed, 06 Oct 2021 11:23:39 +0200
Stefan Kangas <stefan <at> marxist.se> writes:

> But actually, isn't the way to truncate lines just to say this?
>
>     (setq truncate-lines t)
>
> In summary, I don't think I understand the use-case here.

Yes, `toggle-truncate-lines' looks like a user-level command to me.  The
only places it's called in Emacs is from places like
`menu-bar--wrap-long-lines-window-edge' (where it should issue the
message) and `gnus-article-toggle-truncate-lines' (ditto).

-- 
(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. (Wed, 06 Oct 2021 09:24:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51041; Package emacs. (Wed, 06 Oct 2021 14:29:02 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>, Stefan Kangas <stefan <at> marxist.se>
Cc: "51041 <at> debbugs.gnu.org" <51041 <at> debbugs.gnu.org>,
 Tyler Grinn <tylergrinn <at> gmail.com>
Subject: RE: [External] : Re: bug#51041: 28.0.60; toggle-truncate-lines should
 not print message
Date: Wed, 6 Oct 2021 14:28:34 +0000
> Yes, `toggle-truncate-lines' looks like a user-level command to me.

Of course it's a user-level command.  That doesn't
preclude it from being usefully called from Lisp.

> The only places it's called in Emacs is ...

Irrelevant.  Functions can be, and are, called
from code written by Emacs users, including
3rd-party libraries.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51041; Package emacs. (Wed, 06 Oct 2021 18:12:02 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefan <at> marxist.se>
To: Drew Adams <drew.adams <at> oracle.com>, Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: "51041 <at> debbugs.gnu.org" <51041 <at> debbugs.gnu.org>,
 Tyler Grinn <tylergrinn <at> gmail.com>
Subject: RE: [External] : Re: bug#51041: 28.0.60; toggle-truncate-lines should
 not print message
Date: Wed, 6 Oct 2021 14:11:00 -0400
Drew Adams <drew.adams <at> oracle.com> writes:

>> Yes, `toggle-truncate-lines' looks like a user-level command to me.
>
> Of course it's a user-level command.  That doesn't
> preclude it from being usefully called from Lisp.

What is the use-case for calling it from Lisp?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51041; Package emacs. (Wed, 06 Oct 2021 20:47:01 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: Stefan Kangas <stefan <at> marxist.se>, Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: "51041 <at> debbugs.gnu.org" <51041 <at> debbugs.gnu.org>,
 Tyler Grinn <tylergrinn <at> gmail.com>
Subject: RE: [External] : Re: bug#51041: 28.0.60; toggle-truncate-lines should
 not print message
Date: Wed, 6 Oct 2021 20:45:48 +0000
> >> Yes, `toggle-truncate-lines' looks like a user-level command to me.
> >
> > Of course it's a user-level command.  That doesn't
> > preclude it from being usefully called from Lisp.
> 
> What is the use-case for calling it from Lisp?

What is the use case for hard-coding behavior
based on called-interactively?  Why go against
what Emacs recommends?  Why reduce flexibility?

The guideline makes sense.  There's no need to
a priori justify following it by presupposing
some concrete code that invokes the command.

What's your specific justification for flouting
the guideline in this case?

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

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

From: Stefan Kangas <stefan <at> marxist.se>
To: Drew Adams <drew.adams <at> oracle.com>, Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: "51041 <at> debbugs.gnu.org" <51041 <at> debbugs.gnu.org>,
 Tyler Grinn <tylergrinn <at> gmail.com>
Subject: RE: [External] : Re: bug#51041: 28.0.60; toggle-truncate-lines should
 not print message
Date: Wed, 6 Oct 2021 17:09:16 -0400
Drew Adams <drew.adams <at> oracle.com> writes:

>> What is the use-case for calling it from Lisp?
>
> What is the use case for hard-coding behavior
> based on called-interactively?

Drew, it is draining to discuss this way.  I have alredy agreed that
an argument is better than 'called-interactively-p'.  No one is
arguing for that.  Please drop it.  Read the thread.

The argument is that from Lisp you can just set the `truncate-lines'
variable instead of calling `toggle-truncate-lines'.

Does that not work?  If it doesn't, please explain the use-case.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51041; Package emacs. (Wed, 06 Oct 2021 22:13:02 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: Stefan Kangas <stefan <at> marxist.se>, Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: "51041 <at> debbugs.gnu.org" <51041 <at> debbugs.gnu.org>,
 Tyler Grinn <tylergrinn <at> gmail.com>
Subject: RE: [External] : Re: bug#51041: 28.0.60; toggle-truncate-lines should
 not print message
Date: Wed, 6 Oct 2021 22:12:16 +0000
> >> What is the use-case for calling it from Lisp?
> >
> > What is the use case for hard-coding behavior
> > based on called-interactively?
> 
> Drew, it is draining to discuss this way.  I have alredy agreed that
> an argument is better than 'called-interactively-p'.  No one is
> arguing for that.  Please drop it.  Read the thread.
> 
> The argument is that from Lisp you can just set the `truncate-lines'
> variable instead of calling `toggle-truncate-lines'.
> 
> Does that not work?  If it doesn't, please explain the use-case.

Stefan - it's draining to discuss this way.

No one has argued that a command should invoke
`toggle-truncate-lines' instead of setting var
`truncate-lines'.  Please drop it.  Read the
thread.

You're free to close the bug as not-a-bug or
whatever.  The bug report asks _how to invoke
the command from Lisp_ without printing a msg.
You're free to tell the OP to just not do that.

The point is that the command _need not_ have
hard-coded behavior that always prints a msg.
That just complicates things needlessly.

It could simply follow the guidelines and thus
(1) print when invoked interactively and (2)
provide a way to invoke it without printing
(and with the bonus, not provided by setting
the variable, that code _can_ instead choose
to _show_ the message).

The command should have been coded in the
conventional way from the beginning (you
apparently agree now).  Is it worth fixing,
to DTRT now?  That's not my call.  Please
stop haranguing me (present examples etc.).
You will anyway do what you want.

But if you'd like to respond to the actual
bug report, and not just close as won't-fix,
then (you apparently agree) the right fix is
to follow the guideline: add "&optional msg"
for message control.

Do I care whether you do that?  Not a bit.
(Maybe a tiny bit, wishing the best for Emacs.)

Just trying to help, by being clear about how
the command _should_ have been coded (IMHO -
and following the convention, which is a good
one).  You agree with that now.  Underbar.

(Oh, BTW: `toggle-truncate-lines' does more
than change the variable value and print a msg,
in particular when turning off truncation.)

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51041; Package emacs. (Thu, 07 Oct 2021 12:42:02 GMT) Full text and rfc822 format available.

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

From: Tyler Grinn <tylergrinn <at> gmail.com>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: "51041 <at> debbugs.gnu.org" <51041 <at> debbugs.gnu.org>,
 Lars Ingebrigtsen <larsi <at> gnus.org>, Stefan Kangas <stefan <at> marxist.se>
Subject: Re: [External] : Re: bug#51041: 28.0.60; toggle-truncate-lines
 should not print message
Date: Thu, 07 Oct 2021 08:41:03 -0400
Drew Adams <drew.adams <at> oracle.com> writes:

>> >> What is the use-case for calling it from Lisp?
>> >
>> > What is the use case for hard-coding behavior
>> > based on called-interactively?
>> 
>> Does that not work?  If it doesn't, please explain the use-case.
>
> Stefan - it's draining to discuss this way.
>
> You're free to close the bug as not-a-bug or
> whatever.  The bug report asks _how to invoke
> the command from Lisp_ without printing a msg.
> You're free to tell the OP to just not do that.
>
> (Oh, BTW: `toggle-truncate-lines' does more
> than change the variable value and print a msg,
> in particular when turning off truncation.)

Yeah, I would like some direction on this.

My understanding is that if some functionality or minor mode provides a
function to toggle it, it is a best practice to use that function rather
than re-implement it, such that if the behavior of the toggle function
changes my code doesn't have to change.

-- 

Best,

Tyler




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

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Tyler Grinn <tylergrinn <at> gmail.com>
Cc: "51041 <at> debbugs.gnu.org" <51041 <at> debbugs.gnu.org>,
 Stefan Kangas <stefan <at> marxist.se>, Drew Adams <drew.adams <at> oracle.com>
Subject: Re: [External] : Re: bug#51041: 28.0.60; toggle-truncate-lines
 should not print message
Date: Thu, 07 Oct 2021 19:42:58 +0200
Tyler Grinn <tylergrinn <at> gmail.com> writes:

> My understanding is that if some functionality or minor mode provides a
> function to toggle it, it is a best practice to use that function rather
> than re-implement it, such that if the behavior of the toggle function
> changes my code doesn't have to change.

We have a number of commands that are meant to be used for interactive
use only (and will give a warning if used from code).  We also have some
commands that are OK to use from code, but only if that code is
user-oriented, and `toggle-truncate-lines' seems very much like that.

Normal code that needs to change truncate-lines should just set the
variable -- which is what happens already.  There's about a hundred
instances of "setq.*truncate-lines" in the Emacs tree, while there's
three calls to `toggle-truncate-lines' (and all are from code that are
user oriented and should message).

So I agree with Stefan -- altering `toggle-truncate-lines' like
suggested isn't appropriate, and I'm closing this bug report.

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




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

bug closed, send any further explanations to 51041 <at> debbugs.gnu.org and Tyler Grinn <tylergrinn <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 07 Oct 2021 17:44: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. (Fri, 05 Nov 2021 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 173 days ago.

Previous Next


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