[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Modifying a variable from describe-variable

From: João Távora
Subject: Re: Modifying a variable from describe-variable
Date: Sat, 11 Jan 2014 10:12:38 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Tom <address@hidden> 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))))))
+(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))
 (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))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]