unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Okamsn via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 73084@debbugs.gnu.org
Subject: bug#73084: [PATCH] Include the variable name in the `setopt` warning
Date: Sat, 07 Sep 2024 00:23:00 +0000	[thread overview]
Message-ID: <9c212734-cb61-45dc-96f0-3256ab116627@protonmail.com> (raw)

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

Hello,

The attached patch adds the variable name to the `setopt` warning.

I write my Emacs config in an Org file, from which I make the Emacs Lisp 
file.  Currently, if `setopt` detects that the value I wish to make a 
variable hold does not conform to the variable's Custom.el type, then it 
reports the type and the problematic value, but not the variable itself, 
when I open Emacs.  This adds extra steps to editing the code in the Org 
file to fix the warning, especially when the value is created 
programmatically.  It would be faster to search for the variable name 
directly in the Org file and to then re-tangle the Org file.

Thank you.

[-- Attachment #2: 0001-Include-the-variable-name-in-the-warning-in-setopt-s.patch --]
[-- Type: text/x-patch, Size: 1058 bytes --]

From 7cc7134b1b751428b7c14a0b54f55193a59363b1 Mon Sep 17 00:00:00 2001
From: Earl Hyatt <okamsn@protonmail.com>
Date: Fri, 6 Sep 2024 20:04:24 -0400
Subject: [PATCH] Include the variable name in the warning in `setopt--set'.

Including the variable name makes it easier to find the location of the
error.

* lisp/cus-edit.el (setopt--set): Include the variable name in the
warning.
---
 lisp/cus-edit.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index 9f5ac47490c..035499deb71 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -1072,7 +1072,7 @@ setopt--set
   ;; Check that the type is correct.
   (when-let ((type (get variable 'custom-type)))
     (unless (widget-apply (widget-convert type) :match value)
-      (warn "Value `%S' does not match type %s" value type)))
+      (warn "`%s': Value `%S' does not match type %s" variable value type)))
   (put variable 'custom-check-value (list value))
   (funcall (or (get variable 'custom-set) #'set-default) variable value))
 
-- 
2.34.1


             reply	other threads:[~2024-09-07  0:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-07  0:23 Okamsn via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-09-07 12:36 ` bug#73084: [PATCH] Include the variable name in the `setopt` warning Philip Kaludercic
2024-09-08  6:21 ` Eli Zaretskii

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=9c212734-cb61-45dc-96f0-3256ab116627@protonmail.com \
    --to=bug-gnu-emacs@gnu.org \
    --cc=73084@debbugs.gnu.org \
    --cc=okamsn@protonmail.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).