GNU bug report logs -
#51041
28.0.60; toggle-truncate-lines should not print message
Previous Next
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.
Full log
Message #11 received at 51041 <at> debbugs.gnu.org (full text, mbox):
[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.
This bug report was last modified 3 years and 225 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.