emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/xeft 20f4d0d36f 1/4: Add xeft-file-filter


From: ELPA Syncer
Subject: [elpa] externals/xeft 20f4d0d36f 1/4: Add xeft-file-filter
Date: Sat, 28 Jan 2023 22:58:22 -0500 (EST)

branch: externals/xeft
commit 20f4d0d36fbf1345c1c59f828b43fc13be8c3925
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>

    Add xeft-file-filter
    
    xeft-file-filter allow more flexible file filtering in case when
    xeft-ignore-extension is not flexible enough and
    xeft-file-list-function is too verbose.
    
    * xeft.el (xeft-file-filter): New variable.
    (xeft-default-file-filter): New function.
    (xeft--file-list): Use xeft-file-filter to filter files.
---
 xeft.el | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/xeft.el b/xeft.el
index 29fc11580f..5cd3e952cb 100644
--- a/xeft.el
+++ b/xeft.el
@@ -138,6 +138,15 @@ indexed in the database, simply delete the database and 
start
 xeft again."
   :type '(list string))
 
+(defcustom xeft-file-filter #'xeft-default-file-filter
+  "A filter function that excludes files from indexing.
+
+If ‘xeft-ignore-extension’ is not flexible enough, customize this
+function to filter out unwanted files. This function should take
+the absolute path of a file and return t/nil indicating
+keeping/excluding the file from indexing."
+  :type 'function)
+
 (defcustom xeft-recursive nil
   "If non-nil, xeft searches for file recursively.
 Xeft doesn’t follow symlinks and ignores inaccessible directories."
@@ -538,17 +547,24 @@ search phrase the user typed."
   (interactive)
   (xeft-refresh t))
 
+(defun xeft-default-file-filter (file)
+  "Return nil if FILE should be ignored.
+
+FILE is an absolute path. This default implementation ignores
+directories, dot files, and files matched by
+‘xeft-ignore-extension’."
+  (and (file-regular-p file)
+       (not (string-prefix-p
+             "." (file-name-base file)))
+       (not (member (file-name-extension file)
+                    xeft-ignore-extension))))
+
 (defun xeft--file-list ()
   "Default function for ‘xeft-file-list-function’.
 Return a list of all files in ‘xeft-directory’, ignoring dot
 files and directories and check for ‘xeft-ignore-extension’."
   (cl-remove-if-not
-   (lambda (file)
-     (and (file-regular-p file)
-          (not (string-prefix-p
-                "." (file-name-base file)))
-          (not (member (file-name-extension file)
-                       xeft-ignore-extension))))
+   xeft-file-filter
    (if xeft-recursive
        (directory-files-recursively
         xeft-directory "" nil (lambda (dir)



reply via email to

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