emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Keywords


From: Juri Linkov
Subject: Re: Keywords
Date: Mon, 15 Mar 2010 23:33:03 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu)

There are remaining two tasks in finder.el that I think would be useful:

;; Things to do:
;;    1. Support multiple keywords per search.  This could be extremely hairy;
;; there doesn't seem to be any way to get completing-read to exit on
;; an EOL with no substring pending, which is what we'd want to end the loop.
;;    2. Search by string in synopsis line?

The first task is easy to implement with the help of
`completing-read-multiple'.

The second task is also easy to implement by just listing all packages
with synopsis lines and keywords thus allowing to search a string
simply using Isearch.

=== modified file 'lisp/finder.el'
--- lisp/finder.el      2010-03-14 19:59:20 +0000
+++ lisp/finder.el      2010-03-15 21:32:35 +0000
@@ -27,12 +27,6 @@
 
 ;; This mode uses the Keywords library header to provide code-finding
 ;; services by keyword.
-;;
-;; Things to do:
-;;    1. Support multiple keywords per search.  This could be extremely hairy;
-;; there doesn't seem to be any way to get completing-read to exit on
-;; an EOL with no substring pending, which is what we'd want to end the loop.
-;;    2. Search by string in synopsis line?
 
 ;;; Code:
 

=== modified file 'lisp/info.el'
--- lisp/info.el        2010-03-14 16:59:20 +0000
+++ lisp/info.el        2010-03-15 21:31:05 +0000
@@ -3390,7 +3390,8 @@ (defun Info-finder-find-node (filename n
         (insert (format "* %-14s %s.\n"
                         (concat (symbol-name keyword) "::")
                         (cdr assoc)))))
-     (cons '(unknown . "unknown keywords")
+     (append '((all . "All package info")
+              (unknown . "unknown keywords"))
           finder-known-keywords)))
    ((equal nodename "unknown")
     ;; Display unknown keywords
@@ -3405,6 +3406,22 @@ (defun Info-finder-find-node (filename n
                       (concat (symbol-name (car assoc)) "::")
                       (cdr assoc))))
      (finder-unknown-keywords)))
+   ((equal nodename "all")
+    ;; Display all package info.
+    (insert (format "\n\^_\nFile: %s,  Node: %s,  Up: Top\n\n"
+                   Info-finder-file nodename))
+    (insert "Finder Package Info\n")
+    (insert "*******************\n\n")
+    (mapc (lambda (package)
+           (insert (format "%s - %s\n"
+                           (format "*Note %s::" (nth 0 package))
+                           (nth 1 package)))
+           (insert "Keywords: "
+                   (mapconcat (lambda (keyword)
+                                (format "*Note %s::" (symbol-name keyword)))
+                              (nth 2 package) ", ")
+                   "\n\n"))
+         finder-package-info))
    ((string-match-p "\\.el\\'" nodename)
     ;; Display commentary section
     (insert (format "\n\^_\nFile: %s,  Node: %s,  Up: Top\n\n"
@@ -3429,6 +3446,7 @@ (defun Info-finder-find-node (filename n
           (buffer-string))))))
    (t
     ;; Display packages that match the keyword
+    ;; or the list of keywords separated by comma.
     (insert (format "\n\^_\nFile: %s,  Node: %s,  Up: Top\n\n"
                    Info-finder-file nodename))
     (insert "Finder Packages\n")
@@ -3436,21 +3454,39 @@ (defun Info-finder-find-node (filename n
     (insert
      "The following packages match the keyword `" nodename "':\n\n")
     (insert "* Menu:\n\n")
-    (let ((id (intern nodename)))
+    (let ((keywords
+          (mapcar 'intern (if (string-match-p "," nodename)
+                              (split-string nodename ",[ \t\n]*" t)
+                            (list nodename)))))
       (mapc
-       (lambda (x)
-        (when (memq id (cadr (cdr x)))
+       (lambda (package)
+        (unless (memq nil (mapcar (lambda (k) (memq k (nth 2 package)))
+                                  keywords))
           (insert (format "* %-16s %s.\n"
-                          (concat (car x) "::")
-                          (cadr x)))))
+                          (concat (nth 0 package) "::")
+                          (nth 1 package)))))
        finder-package-info)))))
 
 ;;;###autoload
-(defun info-finder ()
-  "Display descriptions of the keywords in the Finder virtual manual."
-  (interactive)
+(defun info-finder (&optional keywords)
+  "Display descriptions of the keywords in the Finder virtual manual.
+In interactive use, a prefix argument directs this command to read
+a list of keywords separated by comma.  After that, it displays a node
+with a list packages that contain all specified keywords."
+  (interactive
+   (when current-prefix-arg
+     (require 'finder)
+     (list
+      (completing-read-multiple
+       "Keywords (separated by comma): "
+       (mapcar 'symbol-name (mapcar 'car (append finder-known-keywords
+                                                (finder-unknown-keywords))))
+       nil t))))
   (require 'finder)
-  (Info-find-node Info-finder-file "Top"))
+  (if keywords
+      (Info-find-node Info-finder-file (mapconcat 'identity keywords ", "))
+    (Info-find-node Info-finder-file "Top")))
+
 
 (defun Info-undefined ()
   "Make command be undefined in Info."


-- 
Juri Linkov
http://www.jurta.org/emacs/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]