forked from dominiksta/mvtn.el
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mvtn-compat.el
34 lines (27 loc) · 1.3 KB
/
mvtn-compat.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
;;; mvtn-compat.el --- Support for emacs <27 for mvtn -*- lexical-binding: t -*-
;;; Commentary:
;; Provide compatibility with older versions of Emacs.
;;; Code:
(require 'seq)
(defvar mvtn-excluded-directories)
(defun mvtn-list-files-function-native (&optional search)
"Search for SEARCH in `mvtn-note-directories'.
Native (elisp) implementation for `mvtn-list-files-function'.
Does not show hidden files (prefixed with '.'). Emacs <27
compatibility: less performant since it needs to traverse all
excluded directories and only filters afterwards."
(mapcar (lambda (file-name)
(substring file-name (length (expand-file-name default-directory))))
(seq-filter (lambda (file)
(not (member
nil (mapcar (lambda (dir) (not (string-match-p
(format "/%s/" dir) file)))
mvtn-excluded-directories))))
(sort (directory-files-recursively
"." (if search
(format "^[^\\.]*%s.*[^~]$" search)
"^[^\\.].*[^~]$")
nil)
'string<))))
(provide 'mvtn-compat)
;;; mvtn-compat.el ends here