About Archive Tags RSS Feed

 

Keeping a simple markdown work-log, via emacs

1 November 2019 16:00

For the past few years I've been keeping a work-log of everything I do. I don't often share these, though it is sometimes interesting to be able to paste into a chat-channel "Oh on the 17th March I changed that .."

I've had a couple of different approaches but for the past few years I've mostly settled upon emacs ~/Work.md. I just create a heading for the date and I'm done:

 # 10-03-2019

 * Did a thing.
   * See this link
 * Did another thing.

 ## Misc.

 Happy Birthday to me.

As I said I've been doing this for years, but it was only last week that I decided to start making it more efficient. Since I open this file often I should bind it to a key:

(defun worklog()
  (interactive "*")
  (find-file "~/Work.MD"))

(global-set-key (kbd "C-x w") 'worklog)

This allows me to open the log by just pressing C-x w. The next step was to automate the headers. So I came up with a function which will search for today's date, adding it if missing:

(defun worklog-today()
  "Move to today's date, if it isn't found then append it"
  (interactive "*")
  (beginning-of-buffer)
  (if (not (search-forward (format-time-string "# %d-%m-%Y") nil t 1))
      (progn
        (end-of-buffer)
        (insert (format-time-string "\n\n# %d-%m-%Y\n")))))

Now we use some magic to makes this function run every time I open ~/Work.md:

(defun worklog_hook ()
  (when (equalp (file-name-nondirectory (buffer-file-name)) "work.md")
    (worklog-today)
    )
)

(add-hook 'find-file-hook 'worklog_hook)

Finally there is a useful package imenu-list which allows you to create an inline sidebar for files. Binding that to a key allows it to be toggled easily:

    (add-hook 'markdown-mode-hook
     (lambda ()
      (local-set-key (kbd "M-'") 'imenu-list-smart-toggle)

The end result is a screen that looks something like this:

If you have an interest in such things I store my emacs configuration on github, in a dotfile-repository. My init file is writting in markdown, which makes it easy to read:

| 4 comments

 

Comments on this entry

icon hommelix at 21:30 on 1 November 2019

Hi Steve, I'm using a similar work journal using orgmode. orgmode provides already some hooks to insert a timestamp or keep a structure. Maybe you get some inspiration from orgmode? Best regards, Hommelix

icon Jonathan at 00:36 on 2 November 2019
http://jmtd.net

I've heard this described as keeping a "lab book" before, something that people in other disciplines are encouraged to do as part of their professional training, but strangely CS types are (generally) not.

icon Adam at 01:48 on 2 November 2019
https://asjo.koldfront.dk/

The sidebar-thing looks cool!

I've been using... Debian changelog format for the same purpose!

Simple format, yet has a little bit of structure, newest first, easy to edit for both Emacs and vi users, easy to search, easy to version control.

The debian-changelog-mode in dpkg-dev-el makes it really convenient to add new entries, and "sign" them.

At work we also use them for incident logs, maintenance logs and logs for various applications.

icon Steve Kemp at 09:17 on 2 November 2019
https://steve.fi/

hommelix: org-mode is the traditional approach for this, I don't use it largely due to ignorance of org-mode.

Adam: The sidebar mode is pretty cool, and works well in a lot of different modes. It could probably be configured to work in changelog-mode too, though I've not tried.