Update.
[elisp.git] / selector.el
index bf9a852..528d96d 100644 (file)
@@ -21,8 +21,8 @@
 ;; The selector/select function provides a simple interface for
 ;; selecting an object with on-the-fly pattern matching in a standard
 ;; buffer (i.e. not in the minibuffer). You can either use it in your
-;; own functions or directly use selector/quick-pick-recent or
-;; selector/quick-move-in-buffer.
+;; own functions or directly use selector/quick-pick-recent,
+;; selector/quick-move-in-buffer, or selector/switch-buffer
 ;;
 ;; For instance, you can add in your .emacs.el
 ;;
@@ -73,6 +73,11 @@ Otherwise use the mode-line."
   :type 'hook
   :group 'selector)
 
+(defcustom selector/quick-pick-recent-hide-filter nil
+  "Regexp specifying which filenames should be hidden by `selector/quick-pick-recent'"
+  :type 'string
+  :group 'selector)
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (defface selector/selection
@@ -390,27 +395,40 @@ filename."
                            (file-name-nondirectory filename)))
     (selector/find-file filename)))
 
-(defun selector/quick-pick-recent ()
+(defun selector/quick-pick-recent (universal)
   "Open a file picked in `recentf-list' with the dynamic
-pattern-matching search implemented in `selector/select'. With a
-prefix argument, allows to edit the filename after selection."
-  (interactive)
+pattern-matching search implemented in `selector/select'.
 
-  (unless (and (boundp recentf-mode) recentf-mode)
-    (error "recentf mode must be turned on"))
+Without a prefix argument, hide files matching
+`selector/quick-pick-recent-hide-filter'.
 
-  ;; (setq selector/previous-filename "")
+With a prefix argument before the selection of the file per se,
+permits to edit it before opening."
+  (interactive "P")
 
-  (selector/select
+  (unless (and (boundp recentf-mode) recentf-mode)
+    (error "recentf mode must be turned on"))
 
-   (mapcar
-    (lambda (s)
-      (cons (selector/filename-to-string s) s))
-    recentf-list)
+  (let ((l
+         (mapcar
+          (lambda (s) (cons (selector/filename-to-string s) s))
+          (if (and (not universal) selector/quick-pick-recent-hide-filter)
+              (delq nil
+                    (mapcar
+                     (lambda (x) (and (not (string-match selector/quick-pick-recent-hide-filter x)) x))
+                     recentf-list)
+                    )
+            recentf-list
+            )
+          )
+         ))
 
-   'selector/pick-file
-   "*selector find-file*"
-   ))
+    (selector/select
+     l
+     'selector/pick-file
+     "*selector find-file*"
+     ))
+  )
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; To search in the current buffer