project-find-file 如何对文件列表排序和过滤?我想用后缀名排序


  1. 后缀ts的排序优先级最高
  2. 我需要js文件在git中,同时如果可能 find file 直接从配置忽略掉js文件


看一下 project-find-file 源代码,不难发现可以在哪里排序,关键的是排序算法:

(defun project-find-file (&optional include-all)
  "Visit a file (with completion) in the current project.

The filename at point (determined by `thing-at-point'), if any,
is available as part of \"future history\".

If INCLUDE-ALL is non-nil, or with prefix argument when called
interactively, include all files under the project root, except
for VCS directories listed in `vc-directory-exclusion-list'."
  (interactive "P")
  (let* ((pr (project-current t))
         (root (project-root pr))
         (dirs (list root)))
    (project-find-file-in ;; <<----
     (or (thing-at-point 'filename)
         (and buffer-file-name (file-relative-name buffer-file-name root)))
     dirs pr include-all)))