unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#73084: [PATCH] Include the variable name in the `setopt` warning
@ 2024-09-07  0:23 Okamsn via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-09-07 12:36 ` Philip Kaludercic
  2024-09-08  6:21 ` Eli Zaretskii
  0 siblings, 2 replies; 3+ messages in thread
From: Okamsn via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-09-07  0:23 UTC (permalink / raw)
  To: 73084

[-- 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#73084: [PATCH] Include the variable name in the `setopt` warning
  2024-09-07  0:23 bug#73084: [PATCH] Include the variable name in the `setopt` warning Okamsn via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-09-07 12:36 ` Philip Kaludercic
  2024-09-08  6:21 ` Eli Zaretskii
  1 sibling, 0 replies; 3+ messages in thread
From: Philip Kaludercic @ 2024-09-07 12:36 UTC (permalink / raw)
  To: Okamsn; +Cc: 73084

Okamsn <okamsn@protonmail.com> writes:

> 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.

I think this is a good idea!  What might also be useful would be to
generate line warnings, as the backtrace should have the necessary
information.

> Thank you.
>
> 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))

-- 
	Philip Kaludercic on siskin





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#73084: [PATCH] Include the variable name in the `setopt` warning
  2024-09-07  0:23 bug#73084: [PATCH] Include the variable name in the `setopt` warning Okamsn via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-09-07 12:36 ` Philip Kaludercic
@ 2024-09-08  6:21 ` Eli Zaretskii
  1 sibling, 0 replies; 3+ messages in thread
From: Eli Zaretskii @ 2024-09-08  6:21 UTC (permalink / raw)
  To: Okamsn; +Cc: 73084-done

> Date: Sat, 07 Sep 2024 00:23:00 +0000
> From:  Okamsn via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
> 
> 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.

Thanks, I made the warning say

  Value `foo' for variable `bar' does not match its type "type"

I installed this on the master branch, and I'm therefore closing this
bug.





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-09-08  6:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-07  0:23 bug#73084: [PATCH] Include the variable name in the `setopt` warning Okamsn via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-07 12:36 ` Philip Kaludercic
2024-09-08  6:21 ` Eli Zaretskii

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).