Parcourir la Source

Removed Solaire-Mode bit and added Hugo draft list

Solaire-mode seems to do its job or I just don't know how it works yet.
Did some extra formatting on the font setup too.
Eiyeron Fulmincendii il y a 6 ans
Parent
commit
60fc1eb24d
1 fichiers modifiés avec 65 ajouts et 36 suppressions
  1. 65 36
      config.org

+ 65 - 36
config.org

@@ -22,55 +22,84 @@ it's made for: displaying text in a flexible yet consistent way. I really like
 the small touches like the ligatures
 #+begin_src emacs-lisp
 (let ((base-size 12))
-  (setq doom-font (font-spec :family "PragmataPro Mono Liga" :size base-size)
-        doom-variable-pitch-font (font-spec :family "PragmataPro Liga" :size base-size)
-        doom-unicode-font (font-spec :family "PragmataPro Liga" :size base-size)
-        doom-big-font (font-spec :family "PragmataPro Liga" :size (* base-size 2))))
+  (setq doom-font (font-spec
+                   :family "PragmataPro Mono Liga"
+                   :size base-size)
+        doom-variable-pitch-font (font-spec
+                                  :family "PragmataPro Liga"
+                                  :size base-size)
+        doom-unicode-font (font-spec
+                           :family "PragmataPro Liga"
+                           :size base-size)
+        doom-big-font (font-spec
+                       :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.
 ** Tweaks
-*** Gruvbox and Solaire-mode
-#+begin_quote
-\[T]/
-#+end_quote
-This is an attempt at hacking ~+doom-solaire-themes~ to add Gruvbox as a working
-theme as the original theme has multiple background options. Sadly, I can't make
-it work yet on Windows for some reason, solaire doesn't just do its background
-swap when swapping buffers. So it'll be commented out until I see if it somehow
-works.
+*** Window borders
+Nothing really fancy yet, I'm content with how Doom looks right now. In the
+future I might add something to change the windows' border colors. Window
+dividers (located in the ~window-divider~ group) are inheriting from the
+~vertical-border~ face, so editing the later allows me to quickly change the
+border color if needed.
 #+begin_src emacs-lisp
-;; (setq +doom-solaire-themes (append +doom-solaire-themes
-;;                                    '((doom-gruvbox . t))))
+;; (set-face-attribute 'vertical-border nil :foreground "red")
 #+end_src
+
+#+RESULTS:
+: red
+
 * Functions
 ** Blog helpers
-*** TODO Draft list
 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
 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.
+file browser, so I have to adapt it to feed Ivy. I currently have a version that
+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
 #+begin_src emacs-lisp
-;; (defun chicken/list-hugo-drafts()
-;;   (interactive)
-;;   (let* ((default-directory (projectile-project-root))
-;;          (selected-file (helm
-;;                          :sources
-;;                          (helm-build-async-source
-;;                           "Draft blog posts"
-;;                           :candidates-process (lambda ()
-;;                                                 (start-process
-;;                                                  "hugo"
-;;                                                  nil
-;;                                                  "hugo"
-;;                                                  "list"
-;;                                                  "drafts")))
-;;                          :buffer
-;;                          "*helm hugo drafts*")))
-;;     (when selected-file
-;;       (find-file (concat default-directory selected-file)))))
+(defun chicken/list-hugo-drafts ()
+  "Fetches the current drafts in a hugo project when available"
+  (let
+      ((root (projectile-project-root)))
+    (counsel--split-string
+     (counsel--call
+      (list "hugo" "-s" root "list" "drafts")))))
 #+end_src
+
+Then I have an interactive function I can call that will process the list given
+by ~list-hugo-drafts~ and either opens the file or does nothing if the user
+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.
+
+#+begin_src emacs-lisp
+(defun chicken/hugo-goto-draft ()
+  (interactive)
+  (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))
+#+end_src
+
+#+RESULTS:
+: chicken/hugo-goto-draft