;;; Code:
(require 'info)
+(require 'subr-x)
(defgroup info-lookup nil
"Major mode sensitive help agent."
(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."
: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)
\f
(provide 'info-look)