changeset 107469:e009deee2da4

Merge from mainline.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Tue, 23 Mar 2010 07:28:39 +0000
parents b1a085b9e50a (current diff) 008c1c06812b (diff)
children a213d79a9aae
files
diffstat 4 files changed, 78 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Tue Mar 23 06:43:05 2010 +0000
+++ b/lisp/ChangeLog	Tue Mar 23 07:28:39 2010 +0000
@@ -1,3 +1,21 @@
+2010-03-23  Juri Linkov  <juri@jurta.org>
+
+	* replace.el (occur-accumulate-lines, occur-engine):
+	Use `occur-engine-line' instead of duplicate code.
+	(occur-engine-line): New function created from duplicate code
+	in `occur-accumulate-lines' and `occur-engine'.
+
+2010-03-23  Juri Linkov  <juri@jurta.org>
+
+	* finder.el: Remove TODO tasks.
+
+	* info.el (Info-finder-find-node): Add node "all"
+	with all package info.  Handle a list of multiple keywords
+	separated by comma.
+	(info-finder): In interactive use with a prefix argument,
+	use `completing-read-multiple' to read a list of keywords
+	separated by comma.
+
 2010-03-23  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	Add a new completion style `substring'.
--- a/lisp/finder.el	Tue Mar 23 06:43:05 2010 +0000
+++ b/lisp/finder.el	Tue Mar 23 07:28:39 2010 +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:
 
--- a/lisp/info.el	Tue Mar 23 06:43:05 2010 +0000
+++ b/lisp/info.el	Tue Mar 23 07:28:39 2010 +0000
@@ -3362,7 +3362,8 @@
 	 (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
@@ -3377,6 +3378,22 @@
 		       (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"
@@ -3401,6 +3418,7 @@
 	   (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")
@@ -3408,21 +3426,39 @@
     (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."
--- a/lisp/replace.el	Tue Mar 23 06:43:05 2010 +0000
+++ b/lisp/replace.el	Tue Mar 23 07:28:39 2010 +0000
@@ -1016,18 +1016,7 @@
 	(setq count (+ count (if forwardp -1 1)))
 	(setq beg (line-beginning-position)
 	      end (line-end-position))
-	(if (and keep-props (if (boundp 'jit-lock-mode) jit-lock-mode)
-		 (text-property-not-all beg end 'fontified t))
-	    (if (fboundp 'jit-lock-fontify-now)
-		(jit-lock-fontify-now beg end)))
-	(push
-	 (if (and keep-props (not (eq occur-excluded-properties t)))
-	     (let ((str (buffer-substring beg end)))
-	       (remove-list-of-text-properties
-		0 (length str) occur-excluded-properties str)
-	       str)
-	   (buffer-substring-no-properties beg end))
-	 result)
+	(push (occur-engine-line beg end) result)
 	(forward-line (if forwardp 1 -1)))
       (nreverse result))))
 
@@ -1228,17 +1217,7 @@
 			    endpt (line-end-position)))
 		    (setq marker (make-marker))
 		    (set-marker marker matchbeg)
-		    (if (and keep-props
-			     (if (boundp 'jit-lock-mode) jit-lock-mode)
-			     (text-property-not-all begpt endpt 'fontified t))
-			(if (fboundp 'jit-lock-fontify-now)
-			    (jit-lock-fontify-now begpt endpt)))
-		    (if (and keep-props (not (eq occur-excluded-properties t)))
-			(progn
-			  (setq curstring (buffer-substring begpt endpt))
-			  (remove-list-of-text-properties
-			   0 (length curstring) occur-excluded-properties curstring))
-		      (setq curstring (buffer-substring-no-properties begpt endpt)))
+		    (setq curstring (occur-engine-line begpt endpt))
 		    ;; Highlight the matches
 		    (let ((len (length curstring))
 			  (start 0))
@@ -1335,6 +1314,18 @@
       ;; Return the number of matches
       globalcount)))
 
+(defun occur-engine-line (beg end)
+  (if (and keep-props (if (boundp 'jit-lock-mode) jit-lock-mode)
+	   (text-property-not-all beg end 'fontified t))
+      (if (fboundp 'jit-lock-fontify-now)
+	  (jit-lock-fontify-now beg end)))
+  (if (and keep-props (not (eq occur-excluded-properties t)))
+      (let ((str (buffer-substring beg end)))
+	(remove-list-of-text-properties
+	 0 (length str) occur-excluded-properties str)
+	str)
+    (buffer-substring-no-properties beg end)))
+
 ;; Generate context display for occur.
 ;; OUT-LINE is the line where the match is.
 ;; NLINES and KEEP-PROPS are args to occur-engine.