all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Philip Kaludercic <philipk@posteo.net>
To: Eshel Yaron <me@eshelyaron.com>
Cc: 71374-done@debbugs.gnu.org
Subject: bug#71374: [PATCH] Simplify 'help-enable-variable-value-editing' using
Date: Mon, 02 Sep 2024 20:56:21 +0000	[thread overview]
Message-ID: <874j6xg4ga.fsf@posteo.net> (raw)
In-Reply-To: <87ttf7do79.fsf@posteo.net> (Philip Kaludercic's message of "Mon,  26 Aug 2024 20:27:38 +0000")

Philip Kaludercic <philipk@posteo.net> writes:

> Eshel Yaron <me@eshelyaron.com> writes:
>
>> Philip Kaludercic <philipk@posteo.net> writes:
>>
>>> Eshel Yaron <me@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





      reply	other threads:[~2024-09-02 20:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-05  6:55 bug#71374: [PATCH] Simplify 'help-enable-variable-value-editing' using Philip Kaludercic
2024-06-05 12:19 ` Eli Zaretskii
2024-06-06  6:22   ` Philip Kaludercic
2024-06-30  5:38     ` Stefan Kangas
2024-07-13 21:53       ` Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-28 12:04         ` Philip Kaludercic
2024-08-02  9:03           ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-12 11:51             ` Philip Kaludercic
2024-08-13  5:59               ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-26 20:27                 ` Philip Kaludercic
2024-09-02 20:56                   ` Philip Kaludercic [this message]

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

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

  git send-email \
    --in-reply-to=874j6xg4ga.fsf@posteo.net \
    --to=philipk@posteo.net \
    --cc=71374-done@debbugs.gnu.org \
    --cc=me@eshelyaron.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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.