A Scripter's Notes

Emacs, scripting and anything text oriented.

Second Argument to basename

It is quite common knowledge that the basename command is used to get just the file name without its full path.

> basename /home/$USER/file.txt
file.txt

But what wasn’t common knowledge, at least to me, was that basename also accepts a second argument ..

Emacsclient on Windows

Using emacsclient instead of the emacs binary is a very useful technique to prevent loading emacs from scratch each time you open a new file. That technique is useful on Windows too. But for this to work on Windows, we need some more elisp and Windows environment variable configuration than just the below code,

(require 'server)
;; Start a server if (server-running-p) does not return t (e.g. if it
;; returns nil or :other)
(or (eq (server-running-p) t)
    (server-start))

Generating a transparent favicon

While generating a simple favicon for this blog, I went through a little exercise on how to generate a favicon with transparent background. I did not want the favicon with square block background which runs a risk of not blending well with the browser tab background as seen below:

Bad Favicon

Do ediff as I mean

In almost all of my ediff use cases, I would have windows open side-by-side in a frame, and then I would want to do a diff between the two using ediff-buffers.

But emacs doesn’t know that. So it always asks me to select the buffers I want to diff. The same problem is with ediff-files too.

So I came up with the below helper function to pick the correct ediff command ..

Elisp Meta Characters in String

The setup of outshine package for emacs requires the user to set the variable outline-minor-mode-prefix to "\M-#" before the outline-mode package (that ships with emacs) is loaded.

The best way to do this is via the Customize interface in emacs.

So I did M-x customize and set that variable’s value to "\M-#" and restarted emacs and that worked.

But then I was surprised to see that value being saved in the custom.el as '(outline-minor-mode-prefix "\243").

tmux Shift+Mouse

In tmux, I had been missing the select and middle-click method for copying and pasting stuff in terminal using mouse.

Save a macro as a function in emacs

I am in the process of converting traditional verilog test benches to SystemVerilog UVM test benches. As per the UVM methodology, it is recommended to use `uvm_info instead of $display statements so that the info statement encodes a Message ID and Message Verbosity along with the message required to be printed.

I won’t go in more detail about UVM and verilog as this post is about how I can save a macro that I use very frequently into an elisp function.