[Emacs] Move out function definition for `phundrak/find-org-files'
This commit promotes a lambda to an actual function and moves it to the custom functions part.
This commit is contained in:
parent
ae0b14d962
commit
fb0263a3b7
@ -1423,6 +1423,42 @@
|
|||||||
'("st"))
|
'("st"))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
*** ~phundrak/find-org-file~
|
||||||
|
:PROPERTIES:
|
||||||
|
:CUSTOM_ID: User_Configuration-Custom_functions-phundrakfind-org-file-029040a5
|
||||||
|
:END:
|
||||||
|
There are lots of files which I want to be able to quickly open. I used to
|
||||||
|
have one shortcut for each one of these files, but as their number grew, I
|
||||||
|
decided to switch to helm for my file selector which will be called by only
|
||||||
|
one common shortcut. Most of my files will be located in =~/org=, but I have
|
||||||
|
some conlanging files which are located in =~/Documents/conlanging=, and all
|
||||||
|
my university notes are in =~/Documents/university=. Let’s declare these
|
||||||
|
directories in a variable:
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(setq phundrak/org-directories '("~/org"
|
||||||
|
"~/Documents/university"
|
||||||
|
"~/Documents/conlanging"))
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
With this established, let’s 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
|
||||||
|
(defun phundrak/find-org-file ()
|
||||||
|
(interactive)
|
||||||
|
(find-file
|
||||||
|
(helm
|
||||||
|
:sources (helm-build-sync-source "org files"
|
||||||
|
:candidates (-mapcat
|
||||||
|
(lambda (path)
|
||||||
|
(f-files path
|
||||||
|
(lambda (file) (equal (f-ext file) "org"))
|
||||||
|
t))
|
||||||
|
phundrak/org-directories)
|
||||||
|
:fuzzy-match t)
|
||||||
|
:buffer "*org files*")))
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
** Emacs builtins
|
** Emacs builtins
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:CUSTOM_ID: User_Configuration-Emacs_builtins-7822b8dd
|
:CUSTOM_ID: User_Configuration-Emacs_builtins-7822b8dd
|
||||||
@ -2950,39 +2986,9 @@
|
|||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:CUSTOM_ID: User_Configuration-Shortcuts-Files-206c2126
|
:CUSTOM_ID: User_Configuration-Shortcuts-Files-206c2126
|
||||||
:END:
|
:END:
|
||||||
There are lots of files which I want to be able to quickly open. I used to
|
|
||||||
have one shortcut for each one of these files, but as their number grew, I
|
|
||||||
decided to switch to helm for my file selector which will be called by only
|
|
||||||
one common shortcut. Most of my files will be located in =~/org=, but I have
|
|
||||||
some conlanging files which are located in =~/Documents/conlanging=, and all
|
|
||||||
my university notes are in =~/Documents/university=. Let’s declare these
|
|
||||||
directories in a variable:
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
|
||||||
(setq phundrak/org-directories '("~/org"
|
|
||||||
"~/Documents/university"
|
|
||||||
"~/Documents/conlanging"))
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
With this established, let’s 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
|
||||||
(spacemacs/declare-prefix "of" "open org file")
|
(spacemacs/declare-prefix "of" "open org file")
|
||||||
(spacemacs/set-leader-keys
|
(spacemacs/set-leader-keys "of" 'phundrak/find-org-file)
|
||||||
"of"
|
|
||||||
(lambda ()
|
|
||||||
(interactive)
|
|
||||||
(find-file
|
|
||||||
(helm
|
|
||||||
:sources (helm-build-sync-source "org files"
|
|
||||||
:candidates (-mapcat
|
|
||||||
(lambda (path)
|
|
||||||
(f-files path
|
|
||||||
(lambda (file) (equal (f-ext file) "org"))
|
|
||||||
t))
|
|
||||||
phundrak/org-directories)
|
|
||||||
:fuzzy-match t)
|
|
||||||
:buffer "*org files*"))))
|
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
I also have a shortcut for ~helm-locate~ in case I need to find a file that
|
I also have a shortcut for ~helm-locate~ in case I need to find a file that
|
||||||
|
Loading…
Reference in New Issue
Block a user