changeset 95750:6c14c564fa23

(finder-font-lock-keywords): Handle ``quotes''. (finder-compile-keywords): Move let to where needed. (finder-mouse-face-on-line): Go back one more line if needed. (finder-list-matches): Use cadr. (finder-goto-xref): New function. (finder-commentary): Add buttons to jump to foo.el libraries.
author Glenn Morris <rgm@gnu.org>
date Tue, 10 Jun 2008 03:06:30 +0000
parents 7957e6e1f9b6
children e54e9f3fbb29
files lisp/finder.el
diffstat 1 files changed, 34 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/finder.el	Tue Jun 10 02:44:48 2008 +0000
+++ b/lisp/finder.el	Tue Jun 10 03:06:30 2008 +0000
@@ -109,7 +109,7 @@
   "Syntax table used while in `finder-mode'.")
 
 (defvar finder-font-lock-keywords
-  '(("`\\([^']+\\)'" 1 font-lock-constant-face prepend))
+  '(("`\\([^'`]+\\)'" 1 font-lock-constant-face prepend))
   "Font-lock keywords for Finder mode.")
 
 (defvar finder-headmark nil
@@ -138,14 +138,14 @@
 Optional arguments DIRS are a list of Emacs Lisp directories to compile from;
 no arguments compiles from `load-path'."
   (save-excursion
+    (find-file generated-finder-keywords-file)
+    (setq buffer-undo-list t)
+    (erase-buffer)
+    (insert (autoload-rubric generated-finder-keywords-file
+                             "keyword-to-package mapping"))
+    (search-backward "")
+    (insert "(setq finder-package-info '(\n")
     (let (processed summary keywords)
-      (find-file generated-finder-keywords-file)
-      (setq buffer-undo-list t)
-      (erase-buffer)
-      (insert (autoload-rubric generated-finder-keywords-file
-                               "keyword-to-package mapping"))
-      (search-backward "")
-      (insert "(setq finder-package-info '(\n")
       (mapc
        (lambda (d)
 	 (when (file-exists-p (directory-file-name d))
@@ -175,10 +175,10 @@
                              ;; MS-DOG-type filenames.
                              "^[^=].*\\.el\\(\\.\\(gz\\|Z\\)\\)?$"
                              ))))
-       (or dirs load-path))
-      (insert "    ))\n")
-      (eval-buffer)       ; so we get the new keyword list immediately
-      (basic-save-buffer))))
+       (or dirs load-path)))
+    (insert "    ))\n")
+    (eval-buffer)         ; so we get the new keyword list immediately
+    (basic-save-buffer)))
 
 (defun finder-compile-keywords-make-dist ()
   "Regenerate `finder-inf.el' for the Emacs distribution."
@@ -199,6 +199,8 @@
   "Put `mouse-face' and `help-echo' properties on the previous line."
   (save-excursion
     (forward-line -1)
+    ;; If finder-insert-at-column moved us to a new line, go back one more.
+    (if (looking-at "[ \t]") (forward-line -1))
     (unless finder-help-echo
       (setq finder-help-echo
 	    (let* ((keys1 (where-is-internal 'finder-select
@@ -250,11 +252,10 @@
     (setq finder-headmark (point))
     (mapc
      (lambda (x)
-       (if (memq id (car (cdr (cdr x))))
-	   (progn
-	     (insert (car x))
-	     (finder-insert-at-column 16 (concat (nth 1 x) "\n"))
-	     (finder-mouse-face-on-line))))
+       (when (memq id (cadr (cdr x)))
+         (insert (car x))
+         (finder-insert-at-column 16 (concat (cadr x) "\n"))
+         (finder-mouse-face-on-line)))
      finder-package-info)
     (goto-char (point-min))
     (forward-line)
@@ -263,6 +264,15 @@
     (shrink-window-if-larger-than-buffer)
     (finder-summary)))
 
+(define-button-type 'finder-xref 'action #'finder-goto-xref)
+
+(defun finder-goto-xref (button)
+  "Jump to a lisp file for the BUTTON at point."
+  (let* ((file (button-get button 'xref))
+         (lib (locate-library file)))
+    (if lib (finder-commentary lib)
+      (message "Unable to locate `%s'" file))))
+
 ;;;###autoload
 (defun finder-commentary (file)
   "Display FILE's commentary section.
@@ -291,6 +301,13 @@
     (while (re-search-forward "^;+ ?" nil t)
       (replace-match "" nil nil))
     (goto-char (point-min))
+    (while (re-search-forward "\\<\\([-[:alnum:]]+\\.el\\)\\>" nil t)
+      (if (locate-library (match-string 1))
+          (make-text-button (match-beginning 1) (match-end 1)
+                            'xref (match-string-no-properties 1)
+                            'help-echo "Read this file's commentary"
+                            :type 'finder-xref)))
+    (goto-char (point-min))
     (setq buffer-read-only t)
     (set-buffer-modified-p nil)
     (shrink-window-if-larger-than-buffer)