2023-11-05 21:18:23 +00:00
|
|
|
|
#+title: quick-find-files.el
|
2021-05-02 15:33:41 +00:00
|
|
|
|
#+author: Lucien Cartier-Tilet
|
|
|
|
|
#+email: lucien@phundrak.com
|
|
|
|
|
* Introduction
|
2023-11-05 21:18:23 +00:00
|
|
|
|
~quick-find-files.el~ is a utility package for all of you out there that
|
|
|
|
|
often find themselves looking for the right file in the right place,
|
|
|
|
|
but you can’t be bothered to have a specific keybinding for that
|
|
|
|
|
particular file for one reason or another.
|
2021-05-02 15:33:41 +00:00
|
|
|
|
|
|
|
|
|
Now, you have a utility for finding files by directory with an
|
|
|
|
|
associated extension! Let’s say you often open files with a ~.org~
|
|
|
|
|
extension from your directory =~/org/=, this package will try to find it
|
|
|
|
|
insantly for you!
|
|
|
|
|
|
2023-12-29 16:36:30 +00:00
|
|
|
|
[[file:./assets/quick-find-files.gif]]
|
|
|
|
|
|
2021-05-02 15:33:41 +00:00
|
|
|
|
* Motivation
|
|
|
|
|
I often find myself opening a specific set of files, but they are too
|
|
|
|
|
numerous to make each one of them a keybinding. Well, I actually
|
|
|
|
|
could, but I end up with way too much for my taste. In fact, at the
|
|
|
|
|
time I’m writing this, I would have to manage a hundred keybindings
|
|
|
|
|
for my various org files alone! Unmanageable!
|
|
|
|
|
|
|
|
|
|
* Installation
|
2021-05-02 16:05:26 +00:00
|
|
|
|
** Prerequisites
|
|
|
|
|
First of all, make sure either ~find~ (which is fairly standard, it
|
2023-12-29 15:16:14 +00:00
|
|
|
|
should be there by default) or [[https://github.com/sharkdp/fd][~fd~]] are available on your system, as
|
2021-05-02 16:05:26 +00:00
|
|
|
|
this package relies on one or the other depending on your choices
|
2023-12-29 15:16:14 +00:00
|
|
|
|
(~find~ by default). On some systems, ~fd~ is installed as ~fdfind~ or
|
|
|
|
|
similar, you may need to configure ~quick-find-files-fd-executable~ if
|
|
|
|
|
you wish to use it.
|
2021-05-02 16:05:26 +00:00
|
|
|
|
|
2021-05-02 15:33:41 +00:00
|
|
|
|
** Local installation
|
|
|
|
|
The vanilla way of installing this package would be to clone this
|
|
|
|
|
repository somewhere in your Emacs’ ~load-path~, or add the following
|
2023-11-05 21:18:23 +00:00
|
|
|
|
line to your Emacs configuration:
|
2021-05-02 15:33:41 +00:00
|
|
|
|
#+begin_src emacs-lisp
|
2023-11-05 21:18:23 +00:00
|
|
|
|
(add-to-list 'load-path "/path/to/quick-find-files.el")
|
2021-05-02 15:33:41 +00:00
|
|
|
|
#+end_src
|
|
|
|
|
|
2023-11-05 21:18:23 +00:00
|
|
|
|
Then add the following lines to your configuration:
|
2021-05-02 15:33:41 +00:00
|
|
|
|
#+begin_src emacs-lisp
|
2023-11-05 21:18:23 +00:00
|
|
|
|
(require 'quick-find-files)
|
2021-05-02 15:33:41 +00:00
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
|
|
** Straight + use-package
|
|
|
|
|
My personnal choice in terms of installing packages is using straight
|
2023-11-05 21:18:23 +00:00
|
|
|
|
with use-package. Here is my own configuration of ~quick-find-files.el~:
|
2021-05-02 15:33:41 +00:00
|
|
|
|
#+begin_src emacs-lisp
|
2023-11-05 21:18:23 +00:00
|
|
|
|
(use-package quick-find-files
|
|
|
|
|
:defer t
|
|
|
|
|
:ensure t
|
|
|
|
|
:straight (quick-find-files :type git
|
|
|
|
|
:host github
|
|
|
|
|
:repo "Phundrak/quick-find-files.el")
|
2023-12-29 15:16:14 +00:00
|
|
|
|
:custom ; Depending on your preferences, of course
|
|
|
|
|
(quick-find-files-program 'fd)
|
|
|
|
|
(quick-find-files-dirs '((:dir "~/org" :ext "org" :ignored ("~/org/config"))
|
|
|
|
|
(:dir "~/.emacs.d/lisp" :ext "el")
|
|
|
|
|
(:dir "~/Documents/Work/" :ignored ("dir1" "report.docx")))))
|
2021-05-02 15:33:41 +00:00
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
|
|
** Other methods
|
|
|
|
|
I am aware other methods are available for installing packages in
|
|
|
|
|
Emacs, such as ~quelpa~ or Spacemacs’ and DoomEmacs’ package managers,
|
|
|
|
|
however I am yet unsure how to install this package with them. If you
|
|
|
|
|
do, feel free to submit a PR with new instructions!
|
|
|
|
|
|
2021-05-02 15:48:39 +00:00
|
|
|
|
* Customizing
|
|
|
|
|
A couple of variables can be editer by the user in order to configure
|
2023-11-05 21:18:23 +00:00
|
|
|
|
~quick-find-files.el~:
|
|
|
|
|
- ~quick-find-files-program~ :: The program to use in order to find your
|
2023-12-29 15:16:14 +00:00
|
|
|
|
files. The two currently supported options are ~'find~ and ~'fd~, the
|
|
|
|
|
former being the default choice.
|
2023-11-05 21:18:23 +00:00
|
|
|
|
- ~quick-find-files-fd-executable~ :: Specify the executable to use when
|
|
|
|
|
using the option ~'fd~.
|
|
|
|
|
- ~quick-find-files-find-executable~ :: Specify the executable to use
|
|
|
|
|
when using the option ~'find~.
|
2023-12-29 15:16:14 +00:00
|
|
|
|
- ~quick-find-files-dirs~ :: Specify in which directory the package
|
|
|
|
|
should search for files. This is a list of property lists which must
|
|
|
|
|
at least contain a ~:dir~ property.
|
|
|
|
|
|
|
|
|
|
An optional ~:ext~ property indicates which file extension to look for
|
|
|
|
|
in this directory and will exclude all other extensions. Be careful,
|
|
|
|
|
this may be case-sensitive.
|
|
|
|
|
|
|
|
|
|
An optional ~:ignored~ property indicates a list of paths the package
|
|
|
|
|
will filter out. Paths in this property can be either files or whole
|
|
|
|
|
directories. If a path is relative, the package will consider the
|
|
|
|
|
~:dir~ directory to be its parent path. For instance, in the code
|
|
|
|
|
below, the package will filter out the directory
|
|
|
|
|
=~/Documents/Work/CVEs= and the file =~/Documents/Work/report.docx= when
|
|
|
|
|
searching in =~/Documents/Work=.
|
|
|
|
|
#+begin_src emacs-lisp
|
|
|
|
|
'((:dir "~/org" :ext "org" :ignored ("~/org/config"))
|
|
|
|
|
(:dir "~/.emacs.d/lisp" :ext "el")
|
|
|
|
|
(:dir "~/Documents/Work" :ignored ("CVEs" "report.docx")))
|
|
|
|
|
#+end_src
|
|
|
|
|
- ~quick-find-files-dirs-and-exts~ :: *DEPRECATED*, use
|
|
|
|
|
~quick-find-files-dirs~ instead.
|
|
|
|
|
|
|
|
|
|
List of pairs between directories and extensions. For one directory,
|
|
|
|
|
the program will be searching recursively all files with the
|
|
|
|
|
specified extension. Possible value:
|
2021-05-02 15:48:39 +00:00
|
|
|
|
#+begin_src emacs-lisp
|
2023-11-05 21:18:23 +00:00
|
|
|
|
'(("~/org" . "org")
|
|
|
|
|
("/tmp" . "html")
|
|
|
|
|
("~/code/C" . "h"))
|
2021-05-02 15:48:39 +00:00
|
|
|
|
#+end_src
|
|
|
|
|
This specific example will recursively search for all ~.org~ files in
|
2021-05-02 15:49:30 +00:00
|
|
|
|
=~/org=, all ~.html~ files in ~/tmp~, and all ~.h~ files in =~/code/C=.
|
2021-05-02 15:48:39 +00:00
|
|
|
|
|
|
|
|
|
* Upcoming changes
|
2023-11-05 21:18:23 +00:00
|
|
|
|
- Plans exist to customize the maximum depth at which ~find~ and ~fd~ are to
|
|
|
|
|
search for files.
|
2023-12-29 15:16:14 +00:00
|
|
|
|
- Search for multiple extensions within the same directory with a
|
|
|
|
|
future ~:exts~ property in ~quick-find-files-dirs~.
|
|
|
|
|
- Exclude specific extensions when searching for all files with a
|
|
|
|
|
future ~:ignored-exts~ property in ~quick-find-files-dirs~.
|
2021-05-02 15:48:39 +00:00
|
|
|
|
|
2023-11-05 21:18:23 +00:00
|
|
|
|
* License
|
|
|
|
|
~quick-find-files.el~ is available under the GNU GPL-3.0 license. You
|
2023-12-29 15:16:14 +00:00
|
|
|
|
can find the full text in [[file:LICENSE][LICENSE]].
|