GNU bug report logs - #77834
[PATCH] Improve help-fns-edit-variable for Lisp editing

Previous Next

Package: emacs;

Reported by: Spencer Baugh <sbaugh <at> janestreet.com>

Date: Tue, 15 Apr 2025 21:20:02 UTC

Severity: normal

Tags: patch

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Philip Kaludercic <philipk <at> posteo.net>
To: Spencer Baugh <sbaugh <at> janestreet.com>
Cc: 77834 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>, larsi <at> gnus.org, azeng <at> janestreet.com
Subject: bug#77834: [PATCH] Improve help-fns-edit-variable for Lisp editing
Date: Thu, 17 Apr 2025 08:05:54 +0000
Spencer Baugh <sbaugh <at> janestreet.com> writes:


[...]

> diff --git a/lisp/help-fns.el b/lisp/help-fns.el
> index 0eb0a7a40be..7a0bc2908e9 100644
> --- a/lisp/help-fns.el
> +++ b/lisp/help-fns.el
> @@ -1561,11 +1561,20 @@ help-fns-edit-variable
>    (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))
> -                (prin1-to-string (nth 1 var)))))
> -      (set (nth 0 var) (read str))
> -      (revert-buffer))))
> +    (string-edit
> +     (format ";; Edit the `%s' variable." (nth 0 var))
> +     (prin1-to-string (nth 1 var))
> +     (lambda (edited)
> +       (set (nth 0 var) edited)
> +       (exit-recursive-edit))
> +     :abort-callback
> +     (lambda ()
> +       (exit-recursive-edit)
> +       (error "Aborted edit, variable unchanged"))
> +     :major-mode #'emacs-lisp-mode
> +     :read #'read)
> +    (recursive-edit)
> +    (revert-buffer)))

I don't remember the details here anymore, but why do you need the
`recursive-edit' and `exit-recursive-edit'?  Shouldn't `string-edit'
take care of this instead of the caller?

[...]





This bug report was last modified 24 days ago.

Previous Next


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