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))))) (defun help-fns--run-describe-functions (functions &rest args)