From 57938a7982e20e7d8b96171f19821876c98cb4dc Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Sun, 14 Mar 2010 23:28:52 +0200 Subject: [PATCH] Add finder unknown keywords. * finder.el (finder-unknown-keywords): New function. * info.el (Info-finder-find-node): Use `finder-unknown-keywords' to create a Finder node with unknown keywords. --- lisp/ChangeLog | 9 +++++++++ lisp/finder.el | 24 +++++++++++++++++++++++- lisp/info.el | 17 ++++++++++++++++- 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 751b6078806..d80d987972a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,12 @@ +2010-03-14 Juri Linkov + + Add finder unknown keywords. + + * finder.el (finder-unknown-keywords): New function. + + * info.el (Info-finder-find-node): Use `finder-unknown-keywords' + to create a Finder node with unknown keywords. + 2010-03-14 Juri Linkov * finder.el (finder-compile-keywords): Replace `princ' with diff --git a/lisp/finder.el b/lisp/finder.el index b1e67908d1a..358c0a1fee2 100644 --- a/lisp/finder.el +++ b/lisp/finder.el @@ -33,7 +33,6 @@ ;; 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? -;; 3. Function to check finder-package-info for unknown keywords. ;;; Code: @@ -230,6 +229,29 @@ no arguments compiles from `load-path'." '(mouse-face highlight help-echo finder-help-echo)))) +(defun finder-unknown-keywords () + "Return an alist of unknown keywords and number of their occurences. +Unknown are keywords that are present in `finder-package-info' +but absent in `finder-known-keywords'." + (let ((unknown-keywords-hash (make-hash-table))) + ;; Prepare a hash where key is a keyword + ;; and value is the number of keyword occurences. + (mapc (lambda (package) + (mapc (lambda (keyword) + (unless (assq keyword finder-known-keywords) + (puthash keyword + (1+ (gethash keyword unknown-keywords-hash 0)) + unknown-keywords-hash))) + (nth 2 package))) + finder-package-info) + ;; Make an alist from the hash and sort by the keyword name. + (sort (let (unknown-keywords-list) + (maphash (lambda (key value) + (push (cons key value) unknown-keywords-list)) + unknown-keywords-hash) + unknown-keywords-list) + (lambda (a b) (string< (car a) (car b)))))) + ;;;###autoload (defun finder-list-keywords () "Display descriptions of the keywords in the Finder buffer." diff --git a/lisp/info.el b/lisp/info.el index a1ce05d6292..4f9c5a0da71 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -3343,6 +3343,7 @@ Build a menu of the possible matches." (defvar finder-known-keywords) (defvar finder-package-info) (declare-function find-library-name "find-func" (library)) +(declare-function finder-unknown-keywords "finder" ()) (declare-function lm-commentary "lisp-mnt" (&optional file)) (defun Info-finder-find-node (filename nodename &optional no-going-back) @@ -3361,7 +3362,21 @@ Build a menu of the possible matches." (insert (format "* %-14s %s.\n" (concat (symbol-name keyword) "::") (cdr assoc))))) - finder-known-keywords)) + (cons '(unknown . "unknown keywords") + finder-known-keywords))) + ((equal nodename "unknown") + ;; Display unknown keywords + (insert (format "\n\^_\nFile: %s, Node: %s, Up: Top\n\n" + Info-finder-file nodename)) + (insert "Finder Unknown Keywords\n") + (insert "***********************\n\n") + (insert "* Menu:\n\n") + (mapc + (lambda (assoc) + (insert (format "* %-14s %s.\n" + (concat (symbol-name (car assoc)) "::") + (cdr assoc)))) + (finder-unknown-keywords))) ((string-match-p "\\.el\\'" nodename) ;; Display commentary section (insert (format "\n\^_\nFile: %s, Node: %s, Up: Top\n\n" -- 2.39.2