[Emacs] Remove helm dependency for `find-org-files'

This function is also renamed from `find-org-file' to `find-org-files`
and it became much, much faster.
This commit is contained in:
Lucien Cartier-Tilet 2020-12-10 08:57:20 +01:00
parent 5f129d953a
commit 880a0e14df
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA

View File

@ -1285,22 +1285,20 @@ There are lots of files which I want to be able to quickly open. I used to have
With this established, lets write some emacs-lisp that will allow me to get a list of all these files and select them through helm. Be aware that I will be using some functions from third party packages, such as [[https://github.com/rejeep/f.el][f.el]] and [[https://github.com/magnars/dash.el][dash]]. With this established, lets write some emacs-lisp that will allow me to get a list of all these files and select them through helm. Be aware that I will be using some functions from third party packages, such as [[https://github.com/rejeep/f.el][f.el]] and [[https://github.com/magnars/dash.el][dash]].
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defun phundrak/find-org-file () (defun phundrak/find-org-files ()
"Find all org files in the directories listed in "Find all org files in the directories listed in
`phundrak/org-directories', then list them in a helm buffer where `phundrak/org-directories', then list them in an ido buffer where
the user can fuzzy-match one and open it." the user can match one and open it."
(interactive) (interactive)
(find-file (find-file
(helm (ido-completing-read
:sources (helm-build-sync-source "org files" "Org File:"
:candidates (-mapcat (s-split "\n"
(lambda (path) (mapconcat (lambda (path)
(f-files path (shell-command-to-string
(lambda (file) (equal (f-ext file) "org")) (format "fd . %s -e org" path)))
t)) phundrak/org-directories
phundrak/org-directories) "\n")))))
:fuzzy-match t)
:buffer "*org files*")))
#+END_SRC #+END_SRC
*** ~phundrak/git-repo-root~ *** ~phundrak/git-repo-root~
@ -2996,7 +2994,7 @@ A couple of other useful utilities, sach as opening all marked files, sorting fi
:END: :END:
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(spacemacs/declare-prefix "of" "open org file") (spacemacs/declare-prefix "of" "open org file")
(spacemacs/set-leader-keys "of" 'phundrak/find-org-file) (spacemacs/set-leader-keys "of" 'phundrak/find-org-files)
#+END_SRC #+END_SRC
I also have a shortcut for ~helm-locate~ in case I need to find a file that is not in these directories. One advantage of this over ~helm-find~ is that it doesnt matter from where I call it, it will find any file on my system that matches the query, whereas ~helm-find~ will only search in the current directory and its subdirectories. This time, the declaration is much simpler: I also have a shortcut for ~helm-locate~ in case I need to find a file that is not in these directories. One advantage of this over ~helm-find~ is that it doesnt matter from where I call it, it will find any file on my system that matches the query, whereas ~helm-find~ will only search in the current directory and its subdirectories. This time, the declaration is much simpler: