GNU bug report logs - #71374
[PATCH] Simplify 'help-enable-variable-value-editing' using

Previous Next

Package: emacs;

Reported by: Philip Kaludercic <philipk <at> posteo.net>

Date: Wed, 5 Jun 2024 07:15:02 UTC

Severity: wishlist

Tags: patch

Done: Philip Kaludercic <philipk <at> posteo.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Philip Kaludercic <philipk <at> posteo.net>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#71374: closed ([PATCH] Simplify 'help-enable-variable-value-editing'
 using)
Date: Mon, 02 Sep 2024 20:58:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Mon, 02 Sep 2024 20:56:21 +0000
with message-id <874j6xg4ga.fsf <at> posteo.net>
and subject line Re: bug#71374: [PATCH] Simplify 'help-enable-variable-value-editing' using
has caused the debbugs.gnu.org bug report #71374,
regarding [PATCH] Simplify 'help-enable-variable-value-editing' using
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
71374: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71374
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Philip Kaludercic <philipk <at> posteo.net>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Simplify 'help-enable-variable-value-editing' using
Date: Wed, 05 Jun 2024 06:55:46 +0000
[Message part 3 (text/plain, inline)]
The main issue with this patch is that it drops the syntax highlighting
in the *string edit* buffer, but we could fix that in a second patch by
adding support to specify a major mode to inherit from when editing a
string.

[0001-Simplify-'help-enable-variable-value-editing'-usin.patch (text/x-patch, attachment)]
[Message part 5 (text/plain, inline)]
-- 
	Philip Kaludercic on peregrine
[Message part 6 (message/rfc822, inline)]
From: Philip Kaludercic <philipk <at> posteo.net>
To: Eshel Yaron <me <at> eshelyaron.com>
Cc: 71374-done <at> debbugs.gnu.org
Subject: Re: bug#71374: [PATCH] Simplify
 'help-enable-variable-value-editing' using
Date: Mon, 02 Sep 2024 20:56:21 +0000
Philip Kaludercic <philipk <at> posteo.net> writes:

> Eshel Yaron <me <at> eshelyaron.com> writes:
>
>> Philip Kaludercic <philipk <at> posteo.net> writes:
>>
>>> Eshel Yaron <me <at> eshelyaron.com> writes:
>>>
>>>> I'm reopening this (hope you don't mind) to keep track of the minor
>>>> regressions I mentioned here:
>>>>
>>>> https://lists.gnu.org/archive/html/emacs-devel/2024-07/msg01202.html
>>>
>>> Thanks, and my apologies for the late reply.
>>
>> No problem at all.
>>
>>> The issue seems to be that (thing-at-point 'sexp) returns nil if inside
>>> a s-expression looking at whitespace:
>>>
>>> (1 2     3 4 5)
>>>      ^
>>>      M-: (thing-at-point 'sexp) ;=> nil
>>>
>>> One idea is to fall back on a defun at point, if no sexp is found:
>>>
>>> diff --git a/lisp/help-fns.el b/lisp/help-fns.el
>>> index 8ea5b301684..4d55ea8bbff 100644
>>> --- a/lisp/help-fns.el
>>> +++ b/lisp/help-fns.el
>>> @@ -1507,13 +1507,14 @@ help-fns-edit-variable
>>>    "Edit the variable under point."
>>>    (declare (completion ignore))
>>>    (interactive)
>>> -  (let* ((val (thing-at-point 'sexp))
>>> -         (var (get-text-property 0 'help-fns--edit-variable val)))
>>> +  (let ((val (or (thing-at-point 'sexp)
>>> +                 (thing-at-point 'defun))))
>>>      (unless val
>>> -      (error "No variable under point"))
>>> -    (let ((str (read-string-from-buffer
>>> -                (format ";; Edit the `%s' variable." (nth 0 var))
>>> -                (prin1-to-string (nth 1 var)))))
>>> +      (error "No value at point"))
>>> +    (let* ((var (get-text-property 0 'help-fns--edit-variable val))
>>> +           (str (read-string-from-buffer
>>> +                 (format ";; Edit the `%s' variable." (nth 0 var))
>>> +                 (prin1-to-string (nth 1 var)))))
>>>        (set (nth 0 var) (read str)))))
>>
>> Maybe I'm missing something, but why are val and the thing-at-point call
>> needed at all?  Simply grabbing the help-fns--edit-variable property at
>> point should be work as well, I think.
>
> No, I think you are right, we don't have to take the detour over
> 'thing-at-point', meaning that if I am not mistaken, the fix should
> reduce itself to:
>
> diff --git a/lisp/help-fns.el b/lisp/help-fns.el
> index 8a2ae79736f..97d054ce6db 100644
> --- a/lisp/help-fns.el
> +++ b/lisp/help-fns.el
> @@ -1507,9 +1507,8 @@ help-fns-edit-variable
>    "Edit the variable under point."
>    (declare (completion ignore))
>    (interactive)
> -  (let* ((val (thing-at-point 'sexp))
> -         (var (get-text-property 0 'help-fns--edit-variable val)))
> -    (unless val
> +  (let ((var (get-text-property (point) 'help-fns--edit-variable)))
> +    (unless var
>        (error "No variable under point"))
>      (let ((str (read-string-from-buffer
>                  (format ";; Edit the `%s' variable." (nth 0 var))

I have pushed this change and am closing the report.

>> Eshel

-- 
	Philip Kaludercic on peregrine


This bug report was last modified 316 days ago.

Previous Next


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