* Modifying a variable from describe-variable
@ 2014-01-10 20:16 Tom
2014-01-11 0:02 ` Stefan Monnier
2014-01-11 4:14 ` Ivan Andrus
0 siblings, 2 replies; 18+ messages in thread
From: Tom @ 2014-01-10 20:16 UTC (permalink / raw)
To: emacs-devel
The other day I checked a variable with describe-variable (C-h v)
and I wanted to do a minor change (like changing a character) in
the value. It was a complicated variable with lots of
sublists (e.g. font-lock-keywords), so it would have been natural
and easy to change it on the spot in the *Help* buffer.
E.g. the user presses e (for edit) in the *Help* buffer which
either becomes writable or a new buffer pops up with the variable
value. The user modifies the value, presses C-c C-c and the
modifications are applied to the variable.
It does not seem hard to implement and it would be quite
convenient for quick experimenting with the value of some variable.
I checked the bindings (surely someone has thought of this
before), but I didn't find an existing function to do that.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Modifying a variable from describe-variable
2014-01-10 20:16 Modifying a variable from describe-variable Tom
@ 2014-01-11 0:02 ` Stefan Monnier
2014-01-11 4:14 ` Ivan Andrus
1 sibling, 0 replies; 18+ messages in thread
From: Stefan Monnier @ 2014-01-11 0:02 UTC (permalink / raw)
To: Tom; +Cc: emacs-devel
> E.g. the user presses e (for edit) in the *Help* buffer which
> either becomes writable or a new buffer pops up with the variable
> value. The user modifies the value, presses C-c C-c and the
> modifications are applied to the variable.
Good idea!
Stefan
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Modifying a variable from describe-variable
2014-01-10 20:16 Modifying a variable from describe-variable Tom
2014-01-11 0:02 ` Stefan Monnier
@ 2014-01-11 4:14 ` Ivan Andrus
2014-01-11 4:22 ` Daniel Colascione
` (2 more replies)
1 sibling, 3 replies; 18+ messages in thread
From: Ivan Andrus @ 2014-01-11 4:14 UTC (permalink / raw)
To: Tom; +Cc: emacs-devel
On Jan 10, 2014, at 1:16 PM, Tom <adatgyujto@gmail.com> wrote:
> The other day I checked a variable with describe-variable (C-h v)
> and I wanted to do a minor change (like changing a character) in
> the value. It was a complicated variable with lots of
> sublists (e.g. font-lock-keywords), so it would have been natural
> and easy to change it on the spot in the *Help* buffer.
>
> E.g. the user presses e (for edit) in the *Help* buffer which
> either becomes writable or a new buffer pops up with the variable
> value. The user modifies the value, presses C-c C-c and the
> modifications are applied to the variable.
>
> It does not seem hard to implement and it would be quite
> convenient for quick experimenting with the value of some variable.
>
> I checked the bindings (surely someone has thought of this
> before), but I didn't find an existing function to do that.
Even simpler (to implement) would be a binding to customize-variable. Of course, it might not always work, but might be preferable to some people in the cases when it does work.
I think the hardest part would be getting it to DTRT WRT buffer local-ness and such.
-Ivan
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Modifying a variable from describe-variable
2014-01-11 4:14 ` Ivan Andrus
@ 2014-01-11 4:22 ` Daniel Colascione
2014-01-11 5:18 ` Stefan Monnier
2014-01-11 6:50 ` Tom
2 siblings, 0 replies; 18+ messages in thread
From: Daniel Colascione @ 2014-01-11 4:22 UTC (permalink / raw)
To: Ivan Andrus, Tom; +Cc: emacs-devel
On 01/10/2014 08:14 PM, Ivan Andrus wrote:
> On Jan 10, 2014, at 1:16 PM, Tom <adatgyujto@gmail.com> wrote:
>
>> The other day I checked a variable with describe-variable (C-h v)
>> and I wanted to do a minor change (like changing a character) in
>> the value. It was a complicated variable with lots of
>> sublists (e.g. font-lock-keywords), so it would have been natural
>> and easy to change it on the spot in the *Help* buffer.
>>
>> E.g. the user presses e (for edit) in the *Help* buffer which
>> either becomes writable or a new buffer pops up with the variable
>> value. The user modifies the value, presses C-c C-c and the
>> modifications are applied to the variable.
>>
>> It does not seem hard to implement and it would be quite
>> convenient for quick experimenting with the value of some variable.
>>
>> I checked the bindings (surely someone has thought of this
>> before), but I didn't find an existing function to do that.
>
>
> Even simpler (to implement) would be a binding to customize-variable
XEmacs uses "c" for this purpose. We might as well too.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Modifying a variable from describe-variable
2014-01-11 4:14 ` Ivan Andrus
2014-01-11 4:22 ` Daniel Colascione
@ 2014-01-11 5:18 ` Stefan Monnier
2014-01-11 6:50 ` Tom
2 siblings, 0 replies; 18+ messages in thread
From: Stefan Monnier @ 2014-01-11 5:18 UTC (permalink / raw)
To: Ivan Andrus; +Cc: Tom, emacs-devel
> Even simpler (to implement) would be a binding to customize-variable.
There should already be a button for that.
Stefan
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Modifying a variable from describe-variable
2014-01-11 4:14 ` Ivan Andrus
2014-01-11 4:22 ` Daniel Colascione
2014-01-11 5:18 ` Stefan Monnier
@ 2014-01-11 6:50 ` Tom
2014-01-11 10:12 ` João Távora
2014-01-11 10:25 ` martin rudalics
2 siblings, 2 replies; 18+ messages in thread
From: Tom @ 2014-01-11 6:50 UTC (permalink / raw)
To: emacs-devel
Ivan Andrus <darthandrus <at> gmail.com> writes:
>
> Even simpler (to implement) would be a binding to customize-variable. Of
course, it might not always work,
> but might be preferable to some people in the cases when it does work.
Both could be provided. c - customize and e - edit (for advanced users).
I'd prefer editing the lisp value directly, since I never use customize
and as you also mention it does not work for all variables.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Modifying a variable from describe-variable
2014-01-11 6:50 ` Tom
@ 2014-01-11 10:12 ` João Távora
2014-01-11 16:45 ` Tom
2014-01-11 10:25 ` martin rudalics
1 sibling, 1 reply; 18+ messages in thread
From: João Távora @ 2014-01-11 10:12 UTC (permalink / raw)
To: Tom; +Cc: emacs-devel
Tom <adatgyujto@gmail.com> writes:
> Ivan Andrus <darthandrus <at> gmail.com> writes:
>>
>> Even simpler (to implement) would be a binding to customize-variable. Of
> course, it might not always work,
>> but might be preferable to some people in the cases when it does work.
> Both could be provided. c - customize and e - edit (for advanced users).
> I'd prefer editing the lisp value directly, since I never use customize
> and as you also mention it does not work for all variables.
This is so good I've already hacked it for me. No idea if I'm doing it
correctly though...
Thanks a lot for the idea.
=== modified file 'lisp/help-fns.el'
--- lisp/help-fns.el 2013-12-07 17:05:38 +0000
+++ lisp/help-fns.el 2014-01-11 10:10:18 +0000
@@ -711,6 +711,15 @@
version package))))))
output))
+(defvar describe-described-variable nil
+ "Symbol naming the variable described by `describe-variable'")
+
+(defun describe-edit-variable ()
+ (interactive)
+ (set describe-described-variable
+ (call-interactively 'eval-expression))
+ (revert-buffer t t t))
+
;;;###autoload
(defun describe-variable (variable &optional buffer frame)
"Display the full documentation of VARIABLE (a symbol).
@@ -753,6 +762,11 @@
(help-setup-xref (list #'describe-variable variable buffer)
(called-interactively-p 'interactive))
(with-help-window (help-buffer)
+ (setq-local describe-described-variable variable)
+ (let ((map (make-sparse-keymap)))
+ (set-keymap-parent map help-mode-map)
+ (define-key map (kbd "e") 'describe-edit-variable)
+ (use-local-map map))
(with-current-buffer buffer
(prin1 variable)
(setq file-name (find-lisp-object-file-name variable 'defvar))
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Modifying a variable from describe-variable
2014-01-11 10:12 ` João Távora
@ 2014-01-11 16:45 ` Tom
2014-01-12 2:34 ` João Távora
0 siblings, 1 reply; 18+ messages in thread
From: Tom @ 2014-01-11 16:45 UTC (permalink / raw)
To: emacs-devel
João Távora <joaotavora <at> gmail.com> writes:
r all variables.
>
> This is so good I've already hacked it for me. No idea if I'm doing it
> correctly though...
>
> Thanks a lot for the idea.
If I understand correctly your solution does not provide the current
value of the variable by default, though this is the point.
E.g. if I have a value like
(("\\.org$" . org-mode)
("\\.php$" . html-mumamo-mode)
("\\.gpg\\(~\\|\\.~[0-9]+~\\)?\\'" nil epa-file)
("\\.dz\\'" nil jka-compr)
("\\.xz\\'" nil jka-compr)
("\\.lzma\\'" nil jka-compr)
("\\.lz\\'" nil jka-compr)
("\\.g?z\\'" nil jka-compr)
("\\.bz2\\'" nil jka-compr)
("\\.Z\\'" nil jka-compr)))
and I want to change a some minor thing it then I don't want to
type whe whole thing. I'd like to have the current value displayed
in a buffer, modify it then simply apply it.
Your solution can be useful for primitive types, but handling
more complex values in the echo area would not be really convenient.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Modifying a variable from describe-variable
2014-01-11 16:45 ` Tom
@ 2014-01-12 2:34 ` João Távora
2014-01-12 6:41 ` Tom
2014-01-12 20:51 ` Josh
0 siblings, 2 replies; 18+ messages in thread
From: João Távora @ 2014-01-12 2:34 UTC (permalink / raw)
To: Tom; +Cc: emacs-devel
Tom <adatgyujto@gmail.com> writes:
>> This is so good I've already hacked it for me. No idea if I'm doing it
>> correctly though...
>>
>> Thanks a lot for the idea.
>
> If I understand correctly your solution does not provide the current
> value of the variable by default, though this is the point.
> and I want to change a some minor thing it then I don't want to
> type whe whole thing. I'd like to have the current value displayed
> in a buffer, modify it then simply apply it.
I see, I see. Then I think you want "c" keybinding that someone
suggested that takes you to a customize buffer. I think that would be
the solution most integrated with emacs's solution. I didn't implement
that.
> Your solution can be useful for primitive types, but handling
> more complex values in the echo area would not be really convenient.
On the other hand, the minibuffer can do multi-line-editing, I don't
find that inconvenient.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Modifying a variable from describe-variable
2014-01-12 2:34 ` João Távora
@ 2014-01-12 6:41 ` Tom
2014-01-12 22:44 ` Stefan Monnier
2014-01-12 20:51 ` Josh
1 sibling, 1 reply; 18+ messages in thread
From: Tom @ 2014-01-12 6:41 UTC (permalink / raw)
To: emacs-devel
João Távora <joaotavora <at> gmail.com> writes:
>
> I see, I see. Then I think you want "c" keybinding that someone
> suggested that takes you to a customize buffer. I think that would be
> the solution most integrated with emacs's solution.
That's not a complete solution, because not all variables are
customizable. This feature should not be limited to only customizable
variables.
BTW, it does not seem hard to implement. One only needs to (prin1 ...)
the value to a buffer where the user can modify it and then it can
be read back with (read).
> I didn't implement that.
Another thing: buffer local variables should be handled somehow.
For example, it could be recorded from which buffer C-h v was
called and the code should switch to that buffer temporarily and
set the variable there, so if the variable has a buffer local binding
then the local variable value is modified, not the global one.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Modifying a variable from describe-variable
2014-01-12 6:41 ` Tom
@ 2014-01-12 22:44 ` Stefan Monnier
2014-01-13 6:49 ` Tom
0 siblings, 1 reply; 18+ messages in thread
From: Stefan Monnier @ 2014-01-12 22:44 UTC (permalink / raw)
To: Tom; +Cc: emacs-devel
> This feature should not be limited to only customizable variables.
Agreed.
> BTW, it does not seem hard to implement. One only needs to (prin1 ...)
> the value to a buffer where the user can modify it and then it can
> be read back with (read).
Indeed. Tho you'll also want to pretty print it.
Maybe even better would be to make the *Help* buffer writable, mark all
the non-value text as read-only and bind C-c C-c to a new command
`help-set-variable'.
> Another thing: buffer local variables should be handled somehow.
Yes, that's very important, but not hard either.
Stefan
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Modifying a variable from describe-variable
2014-01-12 22:44 ` Stefan Monnier
@ 2014-01-13 6:49 ` Tom
0 siblings, 0 replies; 18+ messages in thread
From: Tom @ 2014-01-13 6:49 UTC (permalink / raw)
To: emacs-devel
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>
> Indeed. Tho you'll also want to pretty print it.
> Maybe even better would be to make the *Help* buffer writable, mark all
> the non-value text as read-only and bind C-c C-c to a new command
> `help-set-variable'.
>
Using the Help buffer has the additional advantage that the user can see
the documentation of the variable while tinkering with its value.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Modifying a variable from describe-variable
2014-01-12 2:34 ` João Távora
2014-01-12 6:41 ` Tom
@ 2014-01-12 20:51 ` Josh
1 sibling, 0 replies; 18+ messages in thread
From: Josh @ 2014-01-12 20:51 UTC (permalink / raw)
To: João Távora; +Cc: Tom, emacs-devel
On Sat, Jan 11, 2014 at 6:34 PM, João Távora <joaotavora@gmail.com> wrote:
>> Your solution can be useful for primitive types, but handling
>> more complex values in the echo area would not be really convenient.
>
> On the other hand, the minibuffer can do multi-line-editing, I don't
> find that inconvenient.
Deepak Goel's miniedit library[0] makes such editing quite pleasant.
[0] http://www.emacswiki.org/emacs/MiniEdit
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Modifying a variable from describe-variable
2014-01-11 6:50 ` Tom
2014-01-11 10:12 ` João Távora
@ 2014-01-11 10:25 ` martin rudalics
2014-01-11 10:29 ` David Kastrup
1 sibling, 1 reply; 18+ messages in thread
From: martin rudalics @ 2014-01-11 10:25 UTC (permalink / raw)
To: Tom; +Cc: emacs-devel
> I'd prefer editing the lisp value directly, since I never use customize
> and as you also mention it does not work for all variables.
Interesting idea. How do you intend to ship around complications wrt
the printed representation of objects? For example, how are you going
to handle quotes?
martin
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Modifying a variable from describe-variable
2014-01-11 10:25 ` martin rudalics
@ 2014-01-11 10:29 ` David Kastrup
2014-01-11 14:00 ` martin rudalics
0 siblings, 1 reply; 18+ messages in thread
From: David Kastrup @ 2014-01-11 10:29 UTC (permalink / raw)
To: emacs-devel
martin rudalics <rudalics@gmx.at> writes:
>> I'd prefer editing the lisp value directly, since I never use customize
>> and as you also mention it does not work for all variables.
>
> Interesting idea. How do you intend to ship around complications wrt
> the printed representation of objects? For example, how are you going
> to handle quotes?
As long as you only read and not evaluate the expression, this should be
straightforward.
--
David Kastrup
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2014-01-13 6:49 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-10 20:16 Modifying a variable from describe-variable Tom
2014-01-11 0:02 ` Stefan Monnier
2014-01-11 4:14 ` Ivan Andrus
2014-01-11 4:22 ` Daniel Colascione
2014-01-11 5:18 ` Stefan Monnier
2014-01-11 6:50 ` Tom
2014-01-11 10:12 ` João Távora
2014-01-11 16:45 ` Tom
2014-01-12 2:34 ` João Távora
2014-01-12 6:41 ` Tom
2014-01-12 22:44 ` Stefan Monnier
2014-01-13 6:49 ` Tom
2014-01-12 20:51 ` Josh
2014-01-11 10:25 ` martin rudalics
2014-01-11 10:29 ` David Kastrup
2014-01-11 14:00 ` martin rudalics
2014-01-11 14:08 ` David Kastrup
2014-01-11 16:50 ` Tom
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.