]> code.delx.au - gnu-emacs/commitdiff
(info-lookup-guess-custom-symbol): New function for retrieving symbol at point
authorEli Zaretskii <eliz@gnu.org>
Sun, 5 Nov 2006 12:08:02 +0000 (12:08 +0000)
committerEli Zaretskii <eliz@gnu.org>
Sun, 5 Nov 2006 12:08:02 +0000 (12:08 +0000)
in custom buffers.
(top level) <info-lookup-maybe-add-help>: Add backquote and comma to ignored
characters in regexps of help specifications for emacs-lisp-mode and
lisp-interaction-mode.  This permits looking up symbols in `...' and after a
comma.  Add help specifications for custom-mode and help-mode.

lisp/ChangeLog
lisp/info-look.el

index 41141bd7a8c877de706f20476703c519183df301..0bb302eb56627dd8055f9daa280511ee5a5e068d 100644 (file)
@@ -1,3 +1,13 @@
+2006-11-05  Martin Rudalics  <rudalics@gmx.at>
+
+       * info-look.el (info-lookup-guess-custom-symbol): New function
+       for retrieving symbol at point in custom buffers.
+       (top level) <info-lookup-maybe-add-help>: Add backquote and
+       comma to ignored characters in regexps of help specifications
+       for emacs-lisp-mode and lisp-interaction-mode.  This permits
+       looking up symbols in `...' and after a comma.  Add help
+       specifications for custom-mode and help-mode.
+
 2006-11-04  Eli Zaretskii  <eliz@gnu.org>
 
        * mail/rmail.el (rmail-redecode-body): New optional argument RAW.
index 2ac461aa6694825e775b48580be3df70e7cf855a..3918eb00eeeab0d3012c329b953d35da35d2bd9f 100644 (file)
@@ -250,10 +250,10 @@ system."
 ;;;###autoload
 (defun info-lookup-symbol (symbol &optional mode)
   "Display the definition of SYMBOL, as found in the relevant manual.
-When this command is called interactively, it reads SYMBOL from the minibuffer.
-In the minibuffer, use M-n to yank the default argument value
-into the minibuffer so you can edit it.
-The default symbol is the one found at point.
+When this command is called interactively, it reads SYMBOL from the
+minibuffer.  In the minibuffer, use M-n to yank the default argument
+value into the minibuffer so you can edit it.  The default symbol is the
+one found at point.
 
 With prefix arg a query for the symbol help mode is offered."
   (interactive
@@ -566,6 +566,45 @@ Return nil if there is nothing appropriate in the buffer near point."
               (concat prefix name))))
     (error nil)))
 
+(defun info-lookup-guess-custom-symbol ()
+  "Get symbol at point in custom buffers."
+  (condition-case nil
+      (save-excursion
+       (let ((case-fold-search t)
+             (ignored-chars "][()`',:.\" \t\n")
+             (significant-chars "^][()`',:.\" \t\n")
+             beg end)
+         (cond
+          ((and (memq (get-char-property (point) 'face)
+                        '(custom-variable-tag custom-variable-tag-face))
+                  (setq beg (previous-single-char-property-change
+                             (point) 'face nil (line-beginning-position)))
+                  (setq end (next-single-char-property-change
+                             (point) 'face nil (line-end-position)))
+                  (> end beg))
+           (subst-char-in-string
+            ?\ ?\- (buffer-substring-no-properties beg end)))
+          ((or (and (looking-at (concat "[" significant-chars "]"))
+                    (save-excursion
+                      (skip-chars-backward significant-chars)
+                      (setq beg (point)))
+                    (skip-chars-forward significant-chars)
+                    (setq end (point))
+                    (> end beg))
+               (and (looking-at "[ \t\n]")
+                    (looking-back (concat "[" significant-chars "]"))
+                    (setq end (point))
+                    (skip-chars-backward significant-chars)
+                    (setq beg (point))
+                    (> end beg))
+               (and (skip-chars-forward ignored-chars)
+                    (setq beg (point))
+                    (skip-chars-forward significant-chars)
+                    (setq end (point))
+                    (> end beg)))
+           (buffer-substring-no-properties beg end)))))
+    (error nil)))
+
 ;;;###autoload
 (defun info-complete-symbol (&optional mode)
   "Perform completion on symbol preceding point."
@@ -789,7 +828,7 @@ Return nil if there is nothing appropriate in the buffer near point."
 
 (info-lookup-maybe-add-help
  :mode 'emacs-lisp-mode
- :regexp "[^][()'\" \t\n]+"
+ :regexp "[^][()`',\" \t\n]+"
  :doc-spec '(;; Commands with key sequences appear in nodes as `foo' and
              ;; those without as `M-x foo'.
              ("(emacs)Command Index"  nil "`\\(M-x[ \t\n]+\\)?" "'")
@@ -806,13 +845,13 @@ Return nil if there is nothing appropriate in the buffer near point."
 
 (info-lookup-maybe-add-help
  :mode 'lisp-interaction-mode
- :regexp "[^][()'\" \t\n]+"
+ :regexp "[^][()`',\" \t\n]+"
  :parse-rule 'ignore
  :other-modes '(emacs-lisp-mode))
 
 (info-lookup-maybe-add-help
  :mode 'lisp-mode
- :regexp "[^()'\" \t\n]+"
+ :regexp "[^()`',\" \t\n]+"
  :parse-rule 'ignore
  :other-modes '(emacs-lisp-mode))
 
@@ -913,6 +952,18 @@ Return nil if there is nothing appropriate in the buffer near point."
              ;; This gets functions in evaluated classes.  Other
              ;; possible patterns don't seem to work too well.
              "`" "(")))
+
+(info-lookup-maybe-add-help
+ :mode 'custom-mode
+ :ignore-case t
+ :regexp "[^][()`',:\" \t\n]+"
+ :parse-rule 'info-lookup-guess-custom-symbol
+ :other-modes '(emacs-lisp-mode))
+
+(info-lookup-maybe-add-help
+ :mode 'help-mode
+ :regexp "[^][()`',:\" \t\n]+"
+ :other-modes '(emacs-lisp-mode))
 \f
 (provide 'info-look)