changeset 103967:e7050deb1cce

Virtual Info keyword finder. (add-to-list)<Info-virtual-files>: Add "\\`\\*Finder.*\\*\\'". (Info-finder-file): New variable. (Info-finder-find-file): New function. (finder-known-keywords, finder-package-info) (find-library-name, lm-commentary): Use defvar and declare-function to silence compiler warnings. (Info-finder-find-node): New function. (info-finder): New command.
author Juri Linkov <juri@jurta.org>
date Sat, 18 Jul 2009 21:01:49 +0000
parents e1f250fc8519
children ecefdd6eb866
files lisp/info.el
diffstat 1 files changed, 82 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/info.el	Sat Jul 18 20:42:55 2009 +0000
+++ b/lisp/info.el	Sat Jul 18 21:01:49 2009 +0000
@@ -3323,6 +3323,88 @@
 	      Info-apropos-nodes)
 	(Info-find-node Info-apropos-file nodename)))))
 
+(add-to-list 'Info-virtual-files
+	     '("\\`\\*Finder.*\\*\\'"
+	       (find-file . Info-finder-find-file)
+	       (find-node . Info-finder-find-node)
+	       ))
+
+(defvar Info-finder-file "*Finder*"
+  "Info file name of the virtual Info keyword finder manual.")
+
+(defun Info-finder-find-file (filename &optional noerror)
+  "Finder-specific implementation of Info-find-file."
+  filename)
+
+(defvar finder-known-keywords)
+(defvar finder-package-info)
+(declare-function find-library-name "find-func" (library))
+(declare-function lm-commentary "lisp-mnt" (&optional file))
+
+(defun Info-finder-find-node (filename nodename &optional no-going-back)
+  "Finder-specific implementation of Info-find-node-2."
+  (cond
+   ((equal nodename "Top")
+    ;; Display Top menu with descriptions of the keywords
+    (insert (format "\n\^_\nFile: %s,  Node: %s,  Up: (dir)\n\n"
+		    Info-finder-file nodename))
+    (insert "Finder Keywords\n")
+    (insert "***************\n\n")
+    (insert "* Menu:\n\n")
+    (mapc
+     (lambda (assoc)
+       (let ((keyword (car assoc)))
+	 (insert (format "* %-14s %s.\n"
+			 (concat (symbol-name keyword) "::")
+			 (cdr assoc)))))
+     finder-known-keywords))
+   ((string-match-p "\\.el\\'" nodename)
+    ;; Display commentary section
+    (insert (format "\n\^_\nFile: %s,  Node: %s,  Up: Top\n\n"
+		    Info-finder-file nodename))
+    (insert "Finder Commentary\n")
+    (insert "*****************\n\n")
+    (insert
+     "Commentary section of the package `" nodename "':\n\n")
+    (let ((str (lm-commentary (find-library-name nodename))))
+      (if (null str)
+	  (insert "Can't find any Commentary section\n\n")
+	(insert
+	 (with-temp-buffer
+	   (insert str)
+	   (goto-char (point-min))
+	   (delete-blank-lines)
+	   (goto-char (point-max))
+	   (delete-blank-lines)
+	   (goto-char (point-min))
+	   (while (re-search-forward "^;+ ?" nil t)
+	     (replace-match "" nil nil))
+	   (buffer-string))))))
+   (t
+    ;; Display packages that match the keyword
+    (insert (format "\n\^_\nFile: %s,  Node: %s,  Up: Top\n\n"
+		    Info-finder-file nodename))
+    (insert "Finder Packages\n")
+    (insert "***************\n\n")
+    (insert
+     "The following packages match the keyword `" nodename "':\n\n")
+    (insert "* Menu:\n\n")
+    (let ((id (intern nodename)))
+      (mapc
+       (lambda (x)
+	 (when (memq id (cadr (cdr x)))
+	   (insert (format "* %-16s %s.\n"
+			   (concat (car x) "::")
+			   (cadr x)))))
+       finder-package-info)))))
+
+;;;###autoload
+(defun info-finder ()
+  "Display descriptions of the keywords in the Finder virtual manual."
+  (interactive)
+  (require 'finder)
+  (Info-find-node Info-finder-file "Top"))
+
 (defun Info-undefined ()
   "Make command be undefined in Info."
   (interactive)