use (project-files) and match them stripped to basename against thing-at-point
This commit is contained in:
parent
b5caec4543
commit
96af6e8ffe
1 changed files with 11 additions and 28 deletions
39
elisp/um.el
39
elisp/um.el
|
|
@ -107,36 +107,17 @@
|
||||||
;; `embark-target-finders', since I'd have to remove the file finder and put my
|
;; `embark-target-finders', since I'd have to remove the file finder and put my
|
||||||
;; function in the same place in the list anyway.
|
;; function in the same place in the list anyway.
|
||||||
|
|
||||||
;; HACK: taken from project-find-file-in and project--files-in-directory.
|
|
||||||
(defun find-directories-only (dir)
|
|
||||||
(let* ((default-directory dir)
|
|
||||||
(vc-dirs-ignores (mapcar
|
|
||||||
(lambda (d)
|
|
||||||
(concat d "/"))
|
|
||||||
vc-directory-exclusion-list))
|
|
||||||
(command (format "%s -H . $s -type d"
|
|
||||||
find-program
|
|
||||||
(xref--find-ignores-arguments vc-dirs-ignores "./")
|
|
||||||
))
|
|
||||||
(outstr (shell-command-to-string command)))
|
|
||||||
|
|
||||||
(mapcar (lambda (path)
|
|
||||||
(expand-file-name path dir)) (split-string outstr "\n"))
|
|
||||||
))
|
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun um-file-at-point-advice (origfunc)
|
(defun um-file-at-point-advice (origfunc)
|
||||||
"Like find-file-at-point, but checks all known project paths.
|
"Like find-file-at-point, but checks all known project paths.
|
||||||
|
|
||||||
In this order:
|
In this order:
|
||||||
1. current project root
|
1. current project root
|
||||||
2. all other project roots
|
2. all subdirectories in current project
|
||||||
3. journal/ path
|
3. all other project roots
|
||||||
|
4. journal/ path
|
||||||
|
|
||||||
Since journal/ is the origin and other projects shadow it.
|
Since journal/ is the origin and other projects shadow it.
|
||||||
|
|
||||||
TODO: Use a special directory name for potentials/ or the like, in case it's not
|
|
||||||
in the root dir.
|
|
||||||
"
|
"
|
||||||
(or
|
(or
|
||||||
;; current project
|
;; current project
|
||||||
|
|
@ -145,13 +126,15 @@ in the root dir.
|
||||||
;; NOTE: Recurse down into current project directories.
|
;; NOTE: Recurse down into current project directories.
|
||||||
;; project-find-file does it fine, just don't want interactive
|
;; project-find-file does it fine, just don't want interactive
|
||||||
;; completing-read call.
|
;; completing-read call.
|
||||||
(let ((result) (start-dir (project-root (project-current))))
|
(let ((result) (tap (thing-at-point 'filename t)))
|
||||||
(cl-loop for path in
|
;; TODO: this is procedural thinking and not lisp-like:
|
||||||
(find-directories-only start-dir)
|
(cl-loop for file in
|
||||||
do (let ((default-directory path))
|
(project-files (project-current))
|
||||||
(setq result (funcall origfunc)))
|
do (let ((basename (file-name-nondirectory file)))
|
||||||
|
(setq result (equal tap basename)))
|
||||||
if result
|
if result
|
||||||
return result
|
;; see `embark-target-finders':
|
||||||
|
return (cons 'file file)
|
||||||
))
|
))
|
||||||
|
|
||||||
;; all other projects
|
;; all other projects
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue