]> git.eshelyaron.com Git - emacs.git/commitdiff
Make elisp- and emacs-index-search and default to the thing under point
authorLars Ingebrigtsen <larsi@gnus.org>
Mon, 30 Sep 2019 06:57:45 +0000 (08:57 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 30 Sep 2019 06:57:45 +0000 (08:57 +0200)
* lisp/menu-bar.el (elisp-index-search): Default to the thing
under point interactively (bug#1119).
(emacs-index-search): Ditto.
(emacs-index--prompt): New helper function.

lisp/menu-bar.el

index 389234e97516260ead12c2f8df04976ef5753f6e..19122125c53d8db69bbdb51ec382114bd0a3e461 100644 (file)
@@ -1761,15 +1761,28 @@ key, a click, or a menu-item"))
   (interactive)
   (info "(emacs)Glossary"))
 
+(defun emacs-index--prompt ()
+  (let* ((default (thing-at-point 'sexp))
+         (topic
+          (read-from-minibuffer
+           (format "Subject to look up%s: "
+                   (if default
+                       (format " (default \"%s\")" default)
+                     ""))
+           nil nil nil nil default)))
+    (list (if (zerop (length topic))
+              default
+            topic))))
+
 (defun emacs-index-search (topic)
   "Look up TOPIC in the indices of the Emacs User Manual."
-  (interactive "sSubject to look up: ")
+  (interactive (emacs-index--prompt))
   (info "emacs")
   (Info-index topic))
 
 (defun elisp-index-search (topic)
   "Look up TOPIC in the indices of the Emacs Lisp Reference Manual."
-  (interactive "sSubject to look up: ")
+  (interactive (emacs-index--prompt))
   (info "elisp")
   (Info-index topic))