]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix handling of empty input in describe-variable and describe-symbol
authorJuri Linkov <juri@linkov.net>
Fri, 6 Mar 2020 00:27:32 +0000 (02:27 +0200)
committerJuri Linkov <juri@linkov.net>
Fri, 6 Mar 2020 00:27:32 +0000 (02:27 +0200)
* lisp/help-fns.el (describe-variable): Use 'user-error' like in
'describe-function'.
(describe-symbol): Use empty string for arg SYMBOL when input is empty
and there is no default value.
This allows to signal the error "You didn't specify a function or variable"
instead of displaying help about the symbol 'nil' on empty input.
OTOH, still allows to see help about 'nil' when the input is "nil".

lisp/help-fns.el

index 59eedb5331df0e915b3ec77e3d119822e713f394..cc00c722ccc82d6f83ce0dda7e1acaaa97444e39 100644 (file)
@@ -944,7 +944,7 @@ it is displayed along with the global value."
     (unless (buffer-live-p buffer) (setq buffer (current-buffer)))
     (unless (frame-live-p frame) (setq frame (selected-frame)))
     (if (not (symbolp variable))
-       (message "You did not specify a variable")
+       (user-error "You didn't specify a variable")
       (save-excursion
        (let ((valvoid (not (with-current-buffer buffer (boundp variable))))
              val val-start-pos locus)
@@ -1435,7 +1435,7 @@ current buffer and the selected frame, respectively."
                                t nil nil
                                (if found (symbol-name v-or-f)))))
      (list (if (equal val "")
-              v-or-f (intern val)))))
+              (or v-or-f "") (intern val)))))
   (if (not (symbolp symbol))
       (user-error "You didn't specify a function or variable"))
   (unless (buffer-live-p buffer) (setq buffer (current-buffer)))