blog

My Emacs configuration changes in 2025

$ git diff tags/2024...tags/2025 --stat | ag changed
 38 files changed, 540 insertions(+), 409 deletions(-)

A list of the main changes (introducing or eliminating packages, structural changes, important changes in the interface).

0441b30 2025-01-04 dired-subtree configuration
4fc34aa 2025-02-04 switch to doom-tomorrow-night as default
3100c81 2025-02-05 + forge
90dfc96 2025-02-05 + org-sidebar
5318eb6 2025-02-16 switch to sqlformat
6eddac8 2025-02-16 + vertico + corfu + marginalia + orderless + consult
291089c 2025-02-16 combo for consult-line
0de118b 2025-02-21 trying treesit-fold instead of yafolding
e54719f 2025-02-21 sideline + minimap (WIP)
a030077 2025-03-07 + colorful package
bf09612 2025-03-08 using hideshow instead of treesit-fold, more versatile
801fddf 2025-03-15 git in fringes
d91e87d 2025-03-15 Personalized fringe bitmap for Flymake
1e56038 2025-03-15 Integration with Ollama (Ellama)
169efab 2025-06-15 minimal init messages
f42b4b6 2025-06-20 Jira integration (using auth-info)
9000572 2025-09-17 renamed larsen-ibuffer -> larsen-buffer; added bufferlo package
eedc448 2025-09-19 better configuration for the background
4db8195 2025-10-08 new work projects agenda view
2c0cb99 2025-11-20 Switch to Sly (from Slime)
d65d153 2025-11-20 more adjustments for Sly
147e53c 2025-11-20 + embark
1123bd1 2025-11-20 setup for using and exporting GPX files
8f2db38 2025-12-30 extending image-dired to show image size

Books read in 2025

books2025.png
Author   Title Pages Started Finished Category
Zachary Tellman Elements of Clojure 119 2025-01-01 2025-01-13 N
Gianni Solla   Il ladro di quaderni 256 2025-01-01 2025-01-02 F
Kent Beck Smalltalk Best Practice Patterns 215 2025-01-13 2025-01-20 N
Leonardo Sciascia   Il contesto 114 2025-01-25 2025-01-26 F
Ian McEwan   Sweet Tooth 370 2025-02-02 2025-02-08 F
Michał "phoe" Herda   The Common Lisp Condition System 320 2025-02-09 2025-02-16 N
Neil MacGregor   Germany: Memories of a Nation 563 2025-02-22 2025-03-09 N
Eric Evans Domain-Driven Design 560 2025-02-28 2025-06-26 N
Vittorio Sermonti   L'inferno di Dante 555 2025-03-25 2025-04-13 N
Roberto Bolaño 2666 963 2025-04-01 2025-05-09 F
James Hawes   The Shortest History of Germany 227 2025-05-10 2025-05-22 N
Leonardo Sciascia   Il giorno della civetta 137 2025-05-23 2025-05-23 F
Leonardo Sciascia   Todo Modo 121 2025-05-24 2025-05-25 F
Judea Pearl, Dana Mackenzie The Book of Why 372 2025-07-12 2025-08-24 N
Barney White-Spunner Berlin: The Story of a City 448 2025-07-12 2025-08-16 N
Seishi Yokomizo   Il detective Kindaichi 145 2025-08-03 2025-08-10 F
Albert Hofmann   LSD Il mio bambino difficile 175 2025-08-25 2025-09-04 N
Neal Stephenson   Seveneves 861 2025-09-05 2025-09-19 F
Simon Masoned   Un omicidio a Novembre 382 2025-10-05 2025-10-08 F
Ursula K. Le Guin   A wizard of Earthsea 167 2025-09-20 2025-10-26 F
James Rebanks The Shepherd's Life 287 2025-10-25 2025-11-12 N
Kent Beck   Tidy First? 92 2025-12-06 2025-12-06 N
Tanya Reilly   The Staff Engineer's Path 311 2025-12-06 2025-12-28 N
      7760      

(⭐ marks books I particularly liked)

Links #76

scott-jenson-ubuntu-summit.png

Extending image-dired

Emacs' image-dired is a companion package to dired that makes it easier to browse images and to do some very basic image editing. It is a perfect example of how Emacs can be extended to accomplish tasks that go beyond text manipulation.

I will not go through the details of how to use it, but I will illustrate a couple of things I recently added to it in my configuration.

I typically use image-dired to manipulate pictures that accompany blog posts and other stuff I publish on my personal website. These pictures are often exported from Google Photos, and when that is the case their size is usually not suitable for web.

So, I want to be able to know their resolution and, when it is too high, to quickly resize them.

More details in the header line

Let's tackle the first problem first. The image-dired header line only displays the name and the size of the the image file.

Unfortunately, image-dired does not provide a direct way to customize the header line format, so I have to recur to advicing.

The general idea of function advicing is to change the behavior of an existing function without altering its original code. More specifically, it allows to provide a new function that is called :before or :after each call to the original function, or even to replace the original function into a new one that can intercept the function call and completely control what is returned (this function composition method is called :around). Refer to the manual for further options and instructions.

In general, I tend to avoid functions advicing because it creates an invisible layer of indirection between the function definition and its behaviour; in other words, it makes it impossible to know the real result of a function call by just looking at the code of its implementation.

Anyway, here my code:

(defun my/image-size (file)
  (with-temp-buffer
    (call-process "identify" nil t nil "-format" "%wx%h" file )
    (buffer-string)))

(defun my/image-dired-enrich-properties (orig-fun buf file image-count props comment)
  (let ((orig-str (apply orig-fun (list buf file image-count props comment)))
        (size (my/image-size file)))
    (concat orig-str " " size)))

(advice-add 'image-dired-format-properties-string :around #'my/image-dired-enrich-properties)

The original function is image-dired-format-properties-string. I encapsulated a call to the external tool identify (part of ImageMagick) into my/image-size, which I then call to add that particular bit of information to the header line string. In what is a typical :around composition pattern, my advice function calls the original function, then adds extra information to the original input.

Here an example of the results:

image-dired-enrich-properties.png

Interactively resizing images

The mechanism here is even simpler. We just need to provide a function that can resize an image (again, using an utility courtesy of ImageMagick), and wrap it in a interactive function we can call when we are in the image-dired buffer.

(defun my/resize-image (file size)
  "Resize the image in FILE to the specified SIZE (interpreted as a percentage). "
  (call-process "magick" nil t nil file "-resize" (format "%d%%" size) file))

(defun image-dired-thumbnail-resize-image ()
  "Resize the image at point. The size is specified at the prompt as a percentage of the original size."
  (interactive nil image-dired-thumbnail-mode)
  (if (not (image-dired-image-at-point-p))
      (message "No thumbnail at point")
    (let* ((file (image-dired-original-file-name))
           (defdir default-directory))
      (with-temp-buffer
        (setq default-directory defdir)
        (if (eq 0 (my/resize-image file (read-number "New size (%): " 50)))
            (message "Successfully resized image")
          (error "Could not resize image: %s"
                 (string-replace "\n" "" (buffer-string))))))))

If we want, we can even map this function to a keystroke, manipulating its specific keymap.

(keymap-set image-dired-thumbnail-mode-map "Z" 'image-dired-thumbnail-resize-image)

Links #75

byte-archive.png
Other posts