summaryrefslogtreecommitdiff
path: root/lisp/info-look.el
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-01-16 15:59:06 -0700
committerTom Tromey <tom@tromey.com>2017-01-17 15:40:16 -0700
commitdbb29d7eb428dd53617d31a9cc159d889deb1e8e (patch)
treef14753b2ea969f34ee0a2fe101e1d13a82528b8b /lisp/info-look.el
parent8083d258ba96065ac5a201a69f34f7a4d92fe24c (diff)
downloademacs-dbb29d7eb428dd53617d31a9cc159d889deb1e8e.tar.gz
Add info-lookup help for gdb-script-mode
Bug#25464: * lisp/info-look.el (info-lookup-guess-gdb-script-symbol): New function. Add help for gdb-script-mode.
Diffstat (limited to 'lisp/info-look.el')
-rw-r--r--lisp/info-look.el29
1 files changed, 29 insertions, 0 deletions
diff --git a/lisp/info-look.el b/lisp/info-look.el
index 1f3c50870e0..694bcb462ce 100644
--- a/lisp/info-look.el
+++ b/lisp/info-look.el
@@ -43,6 +43,7 @@
;;; Code:
(require 'info)
+(require 'subr-x)
(defgroup info-lookup nil
"Major mode sensitive help agent."
@@ -648,6 +649,26 @@ Return nil if there is nothing appropriate in the buffer near point."
(buffer-substring-no-properties beg end)))))
(error nil)))
+(defun info-lookup-guess-gdb-script-symbol ()
+ "Get symbol at point in GDB script buffers."
+ (condition-case nil
+ (save-excursion
+ (back-to-indentation)
+ ;; Try to find the current line's full command in the index;
+ ;; and default to the longest subset that is found.
+ (when (looking-at "[-a-z]+\\(\\s-[-a-z]+\\)*")
+ (let ((str-list (split-string (match-string-no-properties 0)
+ "\\s-+" t))
+ (completions (info-lookup->completions 'symbol
+ 'gdb-script-mode)))
+ (catch 'result
+ (while str-list
+ (let ((str (string-join str-list " ")))
+ (when (assoc str completions)
+ (throw 'result str))
+ (nbutlast str-list)))))))
+ (error nil)))
+
;;;###autoload
(defun info-complete-symbol (&optional mode)
"Perform completion on symbol preceding point."
@@ -1051,6 +1072,14 @@ Return nil if there is nothing appropriate in the buffer near point."
:mode 'help-mode
:regexp "[^][()`'‘’,:\" \t\n]+"
:other-modes '(emacs-lisp-mode))
+
+(info-lookup-maybe-add-help
+ :mode 'gdb-script-mode
+ :ignore-case nil
+ :regexp "\\([-a-z]+\\(\\s-+[-a-z]+\\)*\\)"
+ :doc-spec '(("(gdb)Command and Variable Index" nil
+ nil nil))
+ :parse-rule 'info-lookup-guess-gdb-script-symbol)
(provide 'info-look)