Blog

2026-08-10 Emphasizing a region in Org mode

One of the most basic features of Org mode is its markup. It is basically the Markdown of the Emacs world (although some people, like Karl Voit, claim that it’s superior to Markdown), and it lets do basic things like italic, bold or verbatim very easily – at least if you’re writing text.

I, on the other hand, happen to edit text pretty often. This is very different from writing. When I write, typing a slash before and after something I want to emphasize is easy. When I edit and just want to make some text bold, putting stars around it is much less convenient.

In popular text processors, you can select a piece of text and press some keychord – usually C-b – to make it bold. I figured I could add a similar feature to my Org mode. Of course, I first checked for an existing one. It turns out that (of course!) Org mode has me covered already – but the key binding is absolutely abysmal. To make the active region bold, you need to press C-c C-x C-f *. (This is a general command called org-emphasize, bound to C-c C-x C-f, followed by the emphasizing character, * in this case.) This command is quite sophisticated and quite simplistic at the same time. For example, it can remove the emphasis (you need to press C-c C-x C-f SPC for that), but for this to work, the region must contain the existing emphasis characters. If the active region contains a space, it will be included in the emphasized text, and due to how Org syntax works, Org won’t actually apply the emphasis then. Still, it does its job well enough.

So, I decided to add some nifty keychord so that I can mark a piece of text bold more easily. It turns out that C-c C-x C-8 is free, and quite mnemonic since the star is usually typed with S-8 (that is, shift+8). Note that I didn’t bother with funcall-interactively or similar features since org-emphasize doesn’t care if it was called interactively, and instead of using the interactive form to detect if it should ask about the character to use, it just treats its char parameter as optional and asks the user for it if its nil.

(defun org-emphasize-bold ()
  "Call `org-emphasize' with the argument of `?*'."
  (interactive)
  (org-emphasize ?*))

(keymap-set org-mode-map "C-c C-x C-8" #'org-emphasize-bold)

Now I could add similar commands for other markup, like italics or strike-through, but I don’t use them enough to justify it. You may ask, why do I mark things as bold so often, then? After all, boldface should be used sparingly. The reason is that I often copy some article to my Org file and I want to make the key fragments prominent. Italics is too “weak” for that, while boldface is much more visible at a first glance. A dream of mine is a way to “highlight” the important parts (like in pdf readers, including the excellent pdf-tools), and apparently there exists a package which does exactly that, but I couldn’t make it work for me (yet?).

That’s it for today, see you next week!

CategoryEnglish, CategoryBlog, CategoryEmacs, CategoryOrgMode

Comments on this page

2026-08-01 A fancier splash screen in terminal Emacs

I’ve been using Emacs in a terminal for some time now (an experience worth a blog post another day). One thing that bothered me a little was that the “splash screen” (what Emacs displays at the start) does not show the familiar Emacs logo. I decided to fix this.

The simplest approach I could think of was to generate the logo in ASCII art form and turn some knob to display it in a terminal. It turns out there is no such knob built in – but this is Emacs, so everything can be changed even if the Emacs devs didn’t think of it.

The splash screen is defined in startup.el. A quick scan revealed that on a graphic display, the function fancy-splash-screen is called (which displays the logo), and in a terminal it’s normal-splash-screen (which does not). There aren’t any variables I could find to customize it, but we have advice!

(defun insert-ascii-art-logo-on-splash-screen (&optional startup concise)
  "Insert an ASCII-art Emacs logo on the normal splash screen."
  (unless concise
    (with-current-buffer "*GNU Emacs*"
      (let ((inhibit-read-only t))
        (goto-char (point-min))
        (call-process "jp2a" nil t nil
                      "--invert"
                      (format "--width=%s" (/ (window-width) 2))
                      (expand-file-name "images/splash.png"
                                        data-directory))
        (insert "\n\n")))))

(advice-add 'normal-splash-screen
            :after
            #'insert-ascii-art-logo-on-splash-screen)

ascii-art-emacs-splash-screen.png

As you can see, the code is pretty simple – and the result is actually pretty cool! One thing I’ve learned while writing it was the existence of the jp2a utility; another was the data-directory variable. (If you are bored some day, say M-: (dired data-directory) RET and see what’s there!)

Of course, I could probably make the logo-in-the-terminal look much better with kitty-graphics.el – but where’s the fun in that?

Until next time!

CategoryEnglish, CategoryBlog, CategoryEmacs

Comments on this page

2026-07-27 Outlining in programs

One of the Emacs’ “killer apps” is Org mode, and one of the most iconic features of Org mode is visibility cycling. It is no wonder people (including me) want a similar feature in other modes.

Some time ago, I was writing a Node.js script which (as is usual in many programs) could be naturally divided into “sections” which I could then fold. I wrote about Hideshow mode, which provides such a thing for code blocks, but I wanted something operating on a slightly different level, grouping sets of functions to one foldable unit.

My first thought was that it would be great to be able to use pages for that. I imagined creating “headings” like this:

^L// This is a heading

(in case you don’t know, // is JS’ syntax for a line comment), and being able to press TAB on such a line to fold the whole page. I asked the Emacs devs whether it would be possible to extend Hideshow mode to support that (fully aware that it might be much more difficult than it sounds), and to my surprise, I learned that Emacs already has such a feature built in! It is called Outline minor mode, and turning the option outline-minor-mode-cycle on allows to use TAB to cycle (which is a prerequisite for me – I won’t risk breaking my fingers on the default C-c @ C-c and its ilk;-)). It has some more customization options (which see), but it turned out it has another drawback for me: the Eslint configuration used in the project I participate in does not like whitespace before comments. However, adding "ignoreComments": true to that rule fixed the problem.

However, Outline minor mode is neither the only nor the best solution to this issue. Folding in non-Org files is an itch many people have, and there are numerous third-party solutions to it. Evaluating all (or even a few) of them would be tedious and probably counterproductive. I generally tend to stick with built-in solutions for my Emacs needs – third-party packages, while often useful, have some drawbacks. This is definitely the case here – many folding packages are unmaintained, undocumented, bloated, do not support what I’d like, or several of the above;-). After a short research, I found two other solutions which seemed good candidates for my needs.

The first one is called Allout and is built into Emacs, too. It seems fairly feature-rich, but apparently does not support what I’d like the most – visibility cycling on TAB. I don’t care too much about its other features – this is the most basic thing I need, so I decided to look further.

The second one I couldn’t remember, but I do remember that a friend of mine recommended it, and after a short search I found his blog post where he did so. The tool is called outli and after a short experiment I think it’s the solution for me. It doesn’t seem abandoned, has no open issues, it has few but well-thought out features, and it has less than 400 lines of code (compare this to Allout’s 5000+!).

The main advantage of Outli over Outline minor mode is its keybindings. With the point on a headline, tab (un)folds it, p and n move the point to the previous and next headline, and b​/​f move the point to the previous/next headline on the same level. Pressing ? on a headline shows a buffer with a list of these and other keybindings.

The only thing that Outli lacks (in a sense) is an easy way to jump to the previous or next headline when the point is not on one of them. That is not a very big deal, though – Outli uses Outline minor mode under the hood, so you can always press C-c @ C-p or C-c @ C-n to do that. (If you happen to need that often, my advice would be to bind them to C-c C-3 C-p and C-c C-3 C-n instead to avoid the shift/control dance.)

That’s it for today, see you next week!

CategoryEnglish, CategoryBlog, CategoryEmacs, CategoryOrgMode

Comments on this page

More...

CategoryBlog