unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Robert Pluim <rpluim@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 30757@debbugs.gnu.org, npostavs@gmail.com
Subject: bug#30757: Better manipulation (suppressing, examining type) of warnings from *Warnings* buffer
Date: Fri, 09 Mar 2018 17:54:23 +0100	[thread overview]
Message-ID: <87vae5jikg.fsf@gmail.com> (raw)
In-Reply-To: <83zi3husrr.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 09 Mar 2018 18:18:32 +0200")

[-- Attachment #1: Type: text/plain, Size: 2661 bytes --]

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Robert Pluim <rpluim@gmail.com>
>> Date: Fri, 09 Mar 2018 16:53:26 +0100
>> Cc: 30757@debbugs.gnu.org
>> 
>> Here's what I've got so far. Suggestions welcome for wording, style
>> changes, etc.
>
> Thanks.
>
>> --- a/etc/NEWS
>> +++ b/etc/NEWS
>> @@ -71,6 +71,12 @@ moved to the early init file (see above).
>>  \f
>>  * Changes in Emacs 27.1
>>  
>> ++++
>
> "+++" means this change was documented in the manual(s), but this
> change wasn't, AFAIU.  Shkuld this be documented in the ELisp manual?
>

etc/NEWS says:

  +++ indicates that all necessary documentation updates are complete.
      (This means all relevant manuals in doc/ AND lisp doc-strings.)

I'd looked through the manuals and couldn't see anywhere where I
thought it should be documented, hence I only changed the
doc-string. We can go for '---' in that case.

>> +** Warning types can now be disabled from the warning buffer.
>> +For each warning 'display-warning' now adds buttons to the buffer it
>> +uses to allow permanent suppression of the warning popup or of the
>> +warning itself.
>
> This entry should be made more clear.  "Warning types" is never
> explained, the reference to 'display-warning' is confusing (this is a
> user-level feature, so why mention the function which is involved?),
> it is unclear what buffer is alluded to by "the buffer it uses", and
> the difference between "warning popup" and "warning itself" is left
> unexplained.

I've rewritten it. See attached.

>> +(define-button-type 'warning-suppress-warning
>> +  'action #'warning-suppress-action
>> +  'help-echo "mouse-2, RET: Permanently disable popping up this warning")
>> +(defun warning-suppress-action (button)
>> +  (customize-save-variable 'warning-suppress-types
>> +                           (cons (list (button-get button 'warning-type))
>> +                                 warning-suppress-types)))
>> +(define-button-type 'warning-suppress-log-warning
>> +  'action #'warning-suppress-log-action
>> +  'help-echo "mouse-2, RET: Never generate this warning")
>
> Likewise here: the difference between "disable popping up" and "never
> generate" is unclear.  maybe a different wording will clarify that,
> but I cannot suggest one because frankly I don't understand well
> enough what each one does.

Yes. I'm stuck between being precise but verbose, and more general and
succinct, and expressing the permanence of the resulting change. I've
make another attempt, although I'm still not entirely happy with it,
especially since the button texts are now quite long (I thought about
using the verb 'hide', but that's not accurate either).

Robert


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Show-log-suppression-buttons-in-display-warning-buff.patch --]
[-- Type: text/x-diff, Size: 3949 bytes --]

From ba62307cfb0633637cc1fa9351c942cf79f34b90 Mon Sep 17 00:00:00 2001
From: Robert Pluim <rpluim@gmail.com>
Date: Fri, 9 Mar 2018 16:41:36 +0100
Subject: [PATCH] Show log suppression buttons in display-warning buffer

* lisp/emacs-lisp/warnings.el (warning-suppress-warning):
Define button.
(warning-suppress-action): New function.
(warning-suppress-log-warning): Define button.
(warning-suppress-log-action): New function.
(display-warning): Show buttons to allow permanent
modification of warning-suppress-types and
warning-suppress-log-types per warning.

* etc/NEWS: Describe 'display-warning' button change.
---
 etc/NEWS                    | 10 +++++++++-
 lisp/emacs-lisp/warnings.el | 26 +++++++++++++++++++++++++-
 2 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 14926ba2e3..a36967d473 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -69,7 +69,15 @@ in your init file.  However, if your init file changes the values of
 moved to the early init file (see above).
 
 \f
-* Changes in Emacs 27.1
+* Changes in Emacs 27.
+
+---
+** Specific warnings can now be disabled from the warning buffer.
+When a warning is displayed to the user, the resulting buffer now has
+buttons which allow making permanent changes to the treatment of that
+warning.  Automatic showing of the warning can be disabled (although
+it is still generated), or generation of the warning can be disabled
+entirely.
 
 ---
 ** The new option 'tooltip-resize-echo-area' avoids truncating tooltip text
diff --git a/lisp/emacs-lisp/warnings.el b/lisp/emacs-lisp/warnings.el
index 489611d4d1..245cd3f39a 100644
--- a/lisp/emacs-lisp/warnings.el
+++ b/lisp/emacs-lisp/warnings.el
@@ -197,6 +197,21 @@ warning-suppress-p
     ;; we return t.
     some-match))
 \f
+(define-button-type 'warning-suppress-warning
+  'action #'warning-suppress-action
+  'help-echo "mouse-2, RET: Don't display this warning automatically")
+(defun warning-suppress-action (button)
+  (customize-save-variable 'warning-suppress-types
+                           (cons (list (button-get button 'warning-type))
+                                 warning-suppress-types)))
+(define-button-type 'warning-suppress-log-warning
+  'action #'warning-suppress-log-action
+  'help-echo "mouse-2, RET: Never generate this warning again")
+(defun warning-suppress-log-action (button)
+  (customize-save-variable 'warning-suppress-log-types
+                           (cons (list (button-get button 'warning-type))
+                                 warning-suppress-types)))
+
 ;;;###autoload
 (defun display-warning (type message &optional level buffer-name)
   "Display a warning message, MESSAGE.
@@ -223,7 +238,12 @@ display-warning
 See the `warnings' custom group for user customization features.
 
 See also `warning-series', `warning-prefix-function' and
-`warning-fill-prefix' for additional programming features."
+`warning-fill-prefix' for additional programming features.
+
+This will also display buttons allowing the user to permanently
+disable automatic display of the warning or disable the warning
+entirely by setting `warning-suppress-types' or
+`warning-suppress-log-types' on their behalf."
   (if (not (or after-init-time noninteractive (daemonp)))
       ;; Ensure warnings that happen early in the startup sequence
       ;; are visible when startup completes (bug#20792).
@@ -264,6 +284,10 @@ display-warning
 	      (insert (format (nth 1 level-info)
 			      (format warning-type-format typename))
 		      message)
+              (insert " ")
+              (insert-button "Disable showing automatically" 'type 'warning-suppress-warning 'warning-type type)
+              (insert " ")
+              (insert-button "Never generate" 'type 'warning-suppress-log-warning 'warning-type type)
 	      (newline)
 	      (when (and warning-fill-prefix (not (string-match "\n" message)))
 		(let ((fill-prefix warning-fill-prefix)
-- 
2.16.1.72.g5be1f00a9


  reply	other threads:[~2018-03-09 16:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-09 12:31 bug#30757: Better manipulation (suppressing, examining type) of warnings from *Warnings* buffer Noam Postavsky
2018-03-09 14:11 ` Robert Pluim
2018-03-09 14:24   ` Robert Pluim
2018-03-09 14:53     ` Noam Postavsky
2018-03-09 15:53       ` Robert Pluim
2018-03-09 16:18         ` Eli Zaretskii
2018-03-09 16:54           ` Robert Pluim [this message]
2018-03-09 18:28             ` Eli Zaretskii
2018-03-10  3:14             ` Noam Postavsky
2018-03-12 11:04               ` Robert Pluim
2020-09-04  4:30             ` Lars Ingebrigtsen
2020-09-04  8:54               ` Robert Pluim
2020-09-04 11:22                 ` Lars Ingebrigtsen
2018-03-09 15:05 ` Drew Adams
2018-03-09 15:49   ` Robert Pluim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87vae5jikg.fsf@gmail.com \
    --to=rpluim@gmail.com \
    --cc=30757@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=npostavs@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).