|
|
@@ -35,6 +35,7 @@ the small touches like the ligatures
|
|
|
:family "PragmataPro Liga"
|
|
|
:size (* base-size 2))))
|
|
|
#+end_src
|
|
|
+
|
|
|
PragmataPro's ligatures have been toggled within ~init.el~ though the
|
|
|
~pretty-code~ layer and it's optional specialization for this font. No more
|
|
|
setting is to be done for this font.
|
|
|
@@ -49,15 +50,12 @@ border color if needed.
|
|
|
;; (set-face-attribute 'vertical-border nil :foreground "red")
|
|
|
#+end_src
|
|
|
|
|
|
-#+RESULTS:
|
|
|
-: red
|
|
|
-
|
|
|
* Functions
|
|
|
** Blog helpers
|
|
|
Org mode is awesome, that's a fact. I tried to look into making org my blog
|
|
|
framework/builder but I couldn't. I switched to Hugo and reconverted my blog
|
|
|
files into Markdown.
|
|
|
-*** WAIT Draft list
|
|
|
+*** Draft jump list
|
|
|
Hugo has a few utilities, notably listing draft posts. I wrote a while ago a
|
|
|
function to list drafts and feed them to helm. Doom Emacs seems to use ivy as
|
|
|
file browser, so I have to adapt it to feed Ivy. I currently have a version that
|
|
|
@@ -65,10 +63,12 @@ works pretty well on the blog's project. I have an error risen by Hugo that
|
|
|
blocks Ivy from doing its completion when Hugo can't find the blog config.
|
|
|
|
|
|
Here's how it works. First we have a function that calls Hugo's draft listing
|
|
|
-based on the project's directory
|
|
|
+based on the project's directory.
|
|
|
+
|
|
|
#+begin_src emacs-lisp
|
|
|
(defun chicken/list-hugo-drafts ()
|
|
|
- "Fetches the current drafts in a hugo project when available"
|
|
|
+ "Fetches the current drafts in a hugo project when available.
|
|
|
+Assumes the current project is a Hugo one."
|
|
|
(let
|
|
|
((root (projectile-project-root)))
|
|
|
(counsel--split-string
|
|
|
@@ -82,24 +82,81 @@ cancels the search. Something to note here is how I have to rebuild the whole
|
|
|
path based on the project's root. If the user was in another folder, which can
|
|
|
happen for instance when opening another file, the action callback would have
|
|
|
tried to open the selected file relatively to the current folder instead of the
|
|
|
-project folder.
|
|
|
+project folder. There is also a check to detect first the presence of a config
|
|
|
+file before attmepting to invoke hugo to give a sensible message.
|
|
|
|
|
|
#+begin_src emacs-lisp
|
|
|
+;;;###autoload
|
|
|
(defun chicken/hugo-goto-draft ()
|
|
|
+ "Opens an ivy-powered search helper to quickly jump on a draft
|
|
|
+if the current project is the root of a Hugo-powered site."
|
|
|
+ (interactive)
|
|
|
+ (if (file-exists-p! "config.toml" (projectile-project-root))
|
|
|
+ (ivy-read "Open a draft: " (chicken/list-hugo-drafts)
|
|
|
+ :require-match t
|
|
|
+ :history 'chicken/hugo-goto-history
|
|
|
+ :action (lambda (file)
|
|
|
+ (with-ivy-window
|
|
|
+ (when file
|
|
|
+ (let*
|
|
|
+ ((root (projectile-project-root))
|
|
|
+ (full-file (concat root file)))
|
|
|
+ (find-file full-file)))))
|
|
|
+ :unwind #'counsel-delete-process
|
|
|
+ :caller 'chicken/hugo-goto-draft)
|
|
|
+ (message "The current project doesn't have a config.toml in the root directory.")))
|
|
|
+#+end_src
|
|
|
+** Search Everything with Everything
|
|
|
+[[https://www.voidtools.com/][Everything]] is a very useful tool for Windows that indexes all the available in
|
|
|
+the system and provides a insanely fast search popup to directly find the file
|
|
|
+you want based on either globbing or regexes. On Windows, I just can't live
|
|
|
+without it. It also provides a [[https://www.voidtools.com/support/everything/command_line_interface/][command line utility]] designed to search on a
|
|
|
+console but also works very well as part of a scripting toolbox.
|
|
|
+
|
|
|
+Inspired by a friend's desire to use it on his own Emacs setup, I wrote a small
|
|
|
+function based on Ivy to let me jump on any file with the command line version.
|
|
|
+First, the function that will feed ~ivy-read~. It assumes ~es.exe~ is in your
|
|
|
+~PATH~.
|
|
|
+#+begin_src emacs-lisp
|
|
|
+(defun chicken/counsel-es-function (str)
|
|
|
+ (or
|
|
|
+ (ivy-more-chars)
|
|
|
+ (progn
|
|
|
+ (counsel--async-command
|
|
|
+ (format "es %s" str))
|
|
|
+ '("" "working..."))))
|
|
|
+#+end_src
|
|
|
+
|
|
|
+Then the search function. It doesn't do any guards on the presence or not of the
|
|
|
+~es.exe~ executable in your ~PATH~ environment variable. The function is largely
|
|
|
+inspired by Ivy's own examples.
|
|
|
+#+begin_src emacs-lisp
|
|
|
+;;;###autoload
|
|
|
+(defun chicken/search-everything ()
|
|
|
+ "Call the \"es\" shell command.
|
|
|
+INITIAL-INPUT can be given as the initial minibuffer input."
|
|
|
(interactive)
|
|
|
- (ivy-read "Open a draft: " (chicken/list-hugo-drafts)
|
|
|
+ (ivy-read "Everything: " #'chicken/counsel-es-function
|
|
|
+ :dynamic-collection t
|
|
|
:require-match t
|
|
|
- :history 'chicken/hugo-goto-history
|
|
|
+ :history 'chicken/search-everything-history
|
|
|
:action (lambda (file)
|
|
|
(with-ivy-window
|
|
|
(when file
|
|
|
- (let*
|
|
|
- ((root (projectile-project-root))
|
|
|
- (full-file (concat root file)))
|
|
|
- (find-file full-file)))))
|
|
|
+ (find-file file))))
|
|
|
:unwind #'counsel-delete-process
|
|
|
- :caller 'chicken))
|
|
|
+ :caller 'chicken/search-everything ))
|
|
|
#+end_src
|
|
|
|
|
|
-#+RESULTS:
|
|
|
-: chicken/hugo-goto-draft
|
|
|
+Finally, let's set up a shortcut to directly search a file globally with that
|
|
|
+tool. I'm going to map it on ~[LEADER]-s-E~, as I hope it won't be used in the
|
|
|
+near future by Doom Emacs' default configuration. The mapping makes sure that
|
|
|
+you have the executable available before enabling the mapping.
|
|
|
+#+begin_src emacs-lisp
|
|
|
+(map! (:when
|
|
|
+ (and
|
|
|
+ (executable-find "es")
|
|
|
+ (featurep! :completion ivy)))
|
|
|
+ :leader
|
|
|
+ :desc "Everything" "sE" #'chicken/search-everything)
|
|
|
+#+end_src
|