And yet again, Christmas came! Every year, this is a powerful reminder that one day, we may live with God in Heaven. And much more than a reminder – Jesus lives and is truly present in the Eucharist, and like usual food and drink enables us to live here on Earth, Holy Communion enables us to live eternally. We just need to follow Him, and seriously! And Christmas is one of quite a few festivals where we have the opportunity to thank God for that and participate in the events that happened two thousand years ago. All this is of course only possible because of God’s mercy, since we are all sinners, but as St. Paul writes (paraphrasing Isaiah):
What eye has not seen, and ear has not heard, and what has not entered the human heart, what God has prepared for those who love him.
Let us rejoice, because Christ is born today to save us from the devil and the consequences of our own evil deeds! And let us rejoice because the Holy Spirit guides us every day so that we may do good, too!
And according to the little tradition of mine, I will of course say a decade of Rosary for all of you, my dear readers.
Happy Christmas!
Today I have a short Elisp trick, probably slightly more interesting than useful, but still.
A long time ago I wrote about some debugging capabilities of Emacs Lisp. The feature mentioned in the last of these posts, debug-on-variable-change
, allows to invoke the debugger whenever some Elisp code changes the value of a variable (with a few minor limitations). What I didn’t mention then is that you can actually do things other than start the Emacs debugger when a variable’s value changes. The function add-variable-watcher
(and two of its friends) is the way debug-on-variable-change
is defined. This means that you can use it for example to update the display on a change of a variable’s value. I’m not sure if I can think of any other uses of this feature, but I don’t think it needs any more justification – even the debugging thing is very useful.
That’s it for today, thanks for reading!
One of the things I do quite often is refiling Org entries to my “archive” file and marking them as DONE
or CANCELED
. (For some reason I can’t even remember now, I don’t use the archiving feature of Org.) It occurred to me that having Emacs change the todo state automatically would be very convenient.
Of course, I don’t want to do that every time I refile anything – just when I refile a headline to my archive.org
file. Guess what? Emacs and Org mode have me covered!
(defun org-todo-when-archive () "Run `org-todo' but only when in `archive.org'. This is suitable for putting in `org-after-refile-insert-hook' so that I can easily mark stuff refiled there as `DONE' or `CANCELED'." (when (string= (file-name-nondirectory (buffer-file-name)) "archive.org") (org-todo))) (add-hook #'org-after-refile-insert-hook #'org-todo-when-archive)
From now on, items I refile to my personal archive will get a chance of having their state changed with just one more keypress. And the best thing is, I needed less than 10 minutes to code this!
Of course, I have to make an obligatory shoutout to the wonderful Introduction to programming in Emacs Lisp by the late Robert J. Chassell, which will teach you the basics of Emacs Lisp so that you’ll be able to extend your Emacs, too. And if you want to learn more, but studying the Emacs Lisp reference manual seems too daunting, check out my ebook Hacking your way around in Emacs.
CategoryEnglish, CategoryBlog, CategoryEmacs, CategoryOrgMode