|
|
@@ -13,15 +13,15 @@ being that I was tired of all those blue themes. It's a warm colorscheme, it has
|
|
|
a good contrast in most of the situations and I built my whole's old laptop UI
|
|
|
based on Gruvbox. Good thing Doom Emacs has a preset for this specific
|
|
|
colorscheme.
|
|
|
-#+begin_src emacs-lisp
|
|
|
+#+BEGIN_SRC emacs-lisp
|
|
|
(setq doom-theme 'doom-gruvbox)
|
|
|
-#+end_src
|
|
|
+#+END_SRC
|
|
|
** The fonts
|
|
|
The other basic configuration I usually do first too is setting a font.
|
|
|
PragmataPro has been my newest typographic friend as it's /really/ good for what
|
|
|
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
|
|
|
+#+BEGIN_SRC emacs-lisp
|
|
|
(let ((base-size 12))
|
|
|
(setq doom-font (font-spec
|
|
|
:family "PragmataPro Mono Liga"
|
|
|
@@ -35,7 +35,7 @@ the small touches like the ligatures
|
|
|
doom-big-font (font-spec
|
|
|
:family "PragmataPro Liga"
|
|
|
:size (* base-size 2))))
|
|
|
-#+end_src
|
|
|
+#+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
|
|
|
@@ -47,9 +47,9 @@ 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
|
|
|
-;; (set-face-attribute 'vertical-border nil :foreground "red")
|
|
|
-#+end_src
|
|
|
+#+BEGIN_SRC emacs-lisp :tangle no
|
|
|
+(set-face-attribute 'vertical-border nil :foreground "red")
|
|
|
+#+END_SRC
|
|
|
|
|
|
* Blog writing
|
|
|
I have a [[https://retroactive.me][blog]]. I want to use emacs as my platform to type bits and bobs on it.
|
|
|
@@ -72,7 +72,7 @@ file browser, so I had to rewrite one to feed Ivy with my draft list. 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
|
|
|
+#+BEGIN_SRC emacs-lisp
|
|
|
(defun chicken/list-hugo-drafts ()
|
|
|
"Fetches the current drafts in a hugo project when available.
|
|
|
Assumes the current project is a Hugo one."
|
|
|
@@ -81,7 +81,7 @@ Assumes the current project is a Hugo one."
|
|
|
(counsel--split-string
|
|
|
(counsel--call
|
|
|
(list "hugo" "-s" root "list" "drafts")))))
|
|
|
-#+end_src
|
|
|
+#+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
|
|
|
@@ -92,7 +92,7 @@ tried to open the selected file relatively to the current folder instead of the
|
|
|
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
|
|
|
+#+BEGIN_SRC emacs-lisp
|
|
|
;;;###autoload
|
|
|
(defun chicken/hugo-goto-draft ()
|
|
|
"Opens an ivy-powered search helper to quickly jump on a draft
|
|
|
@@ -112,8 +112,8 @@ if the current project is the root of a Hugo-powered site."
|
|
|
: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
|
|
|
-** TODO Convert GIF to videos
|
|
|
+#+END_SRC
|
|
|
+** PROJ Convert GIF to videos
|
|
|
I like GIFs, that's a fact. But neither your bandwidth nor your CPU will
|
|
|
appreciate them. It's soon 2020 and GIFs are one of the most known ways to share
|
|
|
a small video but it is one of the heaviest way one could do on the internet.
|
|
|
@@ -122,7 +122,7 @@ the time a little encoding will lose little details but a lot of filesize?
|
|
|
|
|
|
I have a recipe to convert GIFs (and anything video related) into webm or mp4
|
|
|
with the help of FFMPEG, here it is.
|
|
|
-#+begin_src bash :tangle no
|
|
|
+#+BEGIN_SRC bash :tangle no
|
|
|
# base
|
|
|
ffmpeg -i input-file.mp4 -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis output-file.webm
|
|
|
# This worked not so bad on voxathrone gif
|
|
|
@@ -130,24 +130,121 @@ ffmpeg -i input-file.mp4 -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis output-file.
|
|
|
# auto-alt-ref is needed because the webm format will throw a tantrum due to
|
|
|
# transparency in the gif.
|
|
|
ffmpeg -i .\collision_benchmark.gif -c:v libvpx -crf 10 -auto-alt-ref 0 -b:v 1M -an .\collision_benchmark.webm
|
|
|
-#+end_src
|
|
|
+#+END_SRC
|
|
|
|
|
|
It might be nice to have some functions in emacs to convert a picture when
|
|
|
working on a post. I'm still randomly trying to figure what I need, but here
|
|
|
what I have for now:
|
|
|
-- Codec selection (vpx, mp4)
|
|
|
-- /Sane/ quality presets
|
|
|
-- Customizable variables (crf quality for MP4, crf quality and video bandwidth
|
|
|
+- [ ] Codec selection (vpx, mp4)
|
|
|
+- [ ] /Sane/ quality presets
|
|
|
+- [ ] Customizable variables (crf quality for MP4, crf quality and video bandwidth
|
|
|
for webm)
|
|
|
-- Detect when working on a post to automatically filter the compatible pictures
|
|
|
+- [ ] Detect when working on a post to automatically filter the compatible pictures
|
|
|
- I'm usually working with an "images" folder. That could be a thing to detect.
|
|
|
- - I don't know how it works, but I could detect the `{{< video >}}` template
|
|
|
+ - I don't know how it works, but I could detect the ~{{< video >}}~ template
|
|
|
so I can extract the link to the file and locate the file.
|
|
|
-- GPU codec selection?
|
|
|
-
|
|
|
+ - Meanwhile I can still only list gifs in the ~content~ folder.
|
|
|
+- [ ] GPU codec selection?
|
|
|
Of course, an automatic script could help too, but I think this is kind of
|
|
|
situation where I prefer handling myself the conversion as I might still need
|
|
|
GIFs in some situations.
|
|
|
+*** DONE A first version
|
|
|
+I somehow found out how to make a first usable function that allows me to
|
|
|
+quickly find a gif in any post and convert it. There is no smarter filtering or
|
|
|
+a way to ask for quality parameters, but it's already usable as is.
|
|
|
+Looking back to the earlier comment block, we can figure an argument listing
|
|
|
+which will be ~apply~'d to the process creation routine
|
|
|
+#+BEGIN_SRC emacs-lisp
|
|
|
+(defun chicken/mp4-command (in-file out-file)
|
|
|
+ "Returns a list composed of my default command to make MP4 out
|
|
|
+of gifs."
|
|
|
+ (list "ffmpeg" "-i" in-file
|
|
|
+ "-crf" "10"
|
|
|
+ "-pix_fmt" "yuv420p"
|
|
|
+ "-y"
|
|
|
+ out-file))
|
|
|
+
|
|
|
+(defun chicken/webm-command (in-file out-file)
|
|
|
+ "Returns a list composed of my default command to make WEBM out
|
|
|
+of gifs. This one was found by experiment. The ~auto-alt-ref~
|
|
|
+argument was found required because ffmpeg would fail with GIFs
|
|
|
+with alpgha channels otherwise."
|
|
|
+ (list "ffmpeg" "-i" in-file
|
|
|
+ "-c:v" "libvpx"
|
|
|
+ "-crf" "10"
|
|
|
+ "-b:v" "1M"
|
|
|
+ "-auto-alt-ref" "0"
|
|
|
+ "-c:a" "libvorbis"
|
|
|
+ "-y"
|
|
|
+ out-file))
|
|
|
+#+END_SRC
|
|
|
+
|
|
|
+Given a path to a .gif file, it's relatively easy to derive the location of the
|
|
|
+video files and to run the processes with the precedent part. It's good to note
|
|
|
+that currently there is no way to guess the result value nor the errors except
|
|
|
+by checking the processes' buffers. This is something to work on but for now,
|
|
|
+it'll do. I don't know if the ivy window wrapper is pertinent as the processes
|
|
|
+run in their own buffer.
|
|
|
+#+BEGIN_SRC emacs-lisp
|
|
|
+(defun chicken/process-gif(file)
|
|
|
+ "Given a .gif file, calls ffmpeg twice to convert once in a
|
|
|
+webm and once in a mp4."
|
|
|
+ (with-ivy-window
|
|
|
+ (when file
|
|
|
+ (let* ((default-directory (projectile-project-root))
|
|
|
+ (input-file file)
|
|
|
+ (noext-file (file-name-sans-extension file))
|
|
|
+ (mp4-file (concat noext-file ".mp4"))
|
|
|
+ (webm-file (concat noext-file ".webm"))
|
|
|
+ (mp4-command-line (chicken/mp4-command input-file mp4-file))
|
|
|
+ (webm-command-line (chicken/webm-command input-file webm-file))
|
|
|
+ (mp4-process-args (-concat '("ffmpeg") '("*chicken/convert-mp4*") mp4-command-line))
|
|
|
+ (webm-process-args (-concat '("ffmpeg") '("*chicken/convert-webm*") webm-command-line)))
|
|
|
+ (start-process "pwd" "*pwd*" "pwd")
|
|
|
+ (apply 'start-process mp4-process-args)
|
|
|
+ (apply 'start-process webm-process-args)))))
|
|
|
+#+END_SRC
|
|
|
+
|
|
|
+Then comes the counsel-powered wrapper. I haven't made it as resilient as the
|
|
|
+draft lister, but for now it just wraps over one of counsel's built-in file
|
|
|
+listers to filter it and only keep the .gif located in the ~content~ folder.
|
|
|
+Simple but rather effective.
|
|
|
+#+BEGIN_SRC emacs-lisp
|
|
|
+(defun chicken/counsel-filter-gif(regex candidates)
|
|
|
+ "Wraps counsel--find-file-matcher to filter files to only keep
|
|
|
+gifs located in the content subfolder."
|
|
|
+ (let ((filtered
|
|
|
+ (remove-if-not
|
|
|
+ (lambda (file) (and (s-ends-with-p ".gif" file t)
|
|
|
+ (s-starts-with-p "content" file t)))
|
|
|
+ candidates)))
|
|
|
+ (counsel--find-file-matcher regex filtered)))
|
|
|
+
|
|
|
+;;;###autoload
|
|
|
+(defun chicken/convert-post-gif()
|
|
|
+ "Askes the user for a gif located in the content folder to
|
|
|
+convert it automatically into mp4 and webm."
|
|
|
+ (interactive)
|
|
|
+ (ivy-read "The GAME:" (counsel--find-return-list
|
|
|
+ counsel-file-jump-args)
|
|
|
+ :matcher #'chicken/counsel-filter-gif
|
|
|
+ :require-match t
|
|
|
+ :history 'chicken/convert-post-gif-history
|
|
|
+ :action #'chicken/process-gif
|
|
|
+ :unwind #'counsel-delete-process
|
|
|
+ :caller 'chicken/convert-post-gif))
|
|
|
+#+END_SRC
|
|
|
+
|
|
|
+*** TODO A shortcutmapping
|
|
|
+Finally, I would like to make a shortcut to launch the conversion function to
|
|
|
+quickly get things done. I need to find a proper wrapper for that and to read
|
|
|
+more Doom Emacs' documentation to figure how and where to scope the mapping.
|
|
|
+#+BEGIN_SRC emacs-lisp :tangle no
|
|
|
+(map! (:when
|
|
|
+ (functionp 'chicken/search-everything))
|
|
|
+ :leader
|
|
|
+ :desc "Everything" "sE" #'chicken/search-everything)
|
|
|
+#+END_SRC
|
|
|
* Unsorted Functions
|
|
|
** Search Everything with Everything
|
|
|
[[https://www.voidtools.com/][Everything]] is a very useful tool for Windows that indexes all the available in
|
|
|
@@ -160,8 +257,7 @@ 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
|
|
|
-;;;###autoload
|
|
|
+#+BEGIN_SRC emacs-lisp
|
|
|
(defun chicken/counsel-es-function (str)
|
|
|
(or
|
|
|
(ivy-more-chars)
|
|
|
@@ -169,13 +265,12 @@ First, the function that will feed ~ivy-read~. It assumes ~es.exe~ is in your
|
|
|
(counsel--async-command
|
|
|
(format "es.exe %s" str))
|
|
|
'("" "working..."))))
|
|
|
-#+end_src
|
|
|
+#+END_SRC
|
|
|
|
|
|
Then the search function. It is defined when the executable ~es.exe~ can be
|
|
|
found in your ~PATH~ environment variable. The function is largely inspired by
|
|
|
Ivy's own examples.
|
|
|
-#+begin_src emacs-lisp
|
|
|
-;;;###autoload
|
|
|
+#+BEGIN_SRC emacs-lisp
|
|
|
(when (and
|
|
|
(executable-find "es.exe")
|
|
|
(featurep! :completion ivy))
|
|
|
@@ -194,16 +289,16 @@ INITIAL-INPUT can be given as the initial minibuffer input."
|
|
|
:unwind #'counsel-delete-process
|
|
|
:caller 'chicken/search-everything )))
|
|
|
|
|
|
-#+end_src
|
|
|
+#+END_SRC
|
|
|
|
|
|
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 by checking if the function to be called is
|
|
|
available.
|
|
|
-#+begin_src emacs-lisp
|
|
|
+#+BEGIN_SRC emacs-lisp
|
|
|
(map! (:when
|
|
|
(functionp 'chicken/search-everything))
|
|
|
:leader
|
|
|
:desc "Everything" "sE" #'chicken/search-everything)
|
|
|
-#+end_src
|
|
|
+#+END_SRC
|