Context: Org Mode.

I want to play a unique audio file when entering each of these three checkbox states: [ ] [-] [X].

So one audio file when entering [ ] state, a different one for [-], etc.

Example document:

+ [ ] Foo
    + [ ] ?
+ [ ] Bar
+ [ ] ...


Pressing C-h k RET when on checkbox gives:

+org/dwim-at-point is an autoloaded and interactive function defined
in org.el.

(+org/dwim-at-point &optional ARG)

Do-what-I-mean at point.

If on a:
- checkbox list item or todo heading: toggle it.
- citation: follow it
- headline: cycle ARCHIVE subtrees, toggle latex fragments and inline images in
  subtree; update statistics cookies/checkboxes and ToCs.
- clock: update its time.
- footnote reference: jump to the footnote's definition
- footnote definition: jump to the first reference of this footnote
- timestamp: open an agenda view for the time-stamp date/range at point.
- table-row or a TBLFM: recalculate the table's formulas
- table-cell: clear it and go into insert mode. If this is a formula cell,
  recaluclate it instead.
- babel-call: execute the source block
- statistics-cookie: update it.
- src block: execute it
- latex fragment: toggle it.
- link: follow it
- otherwise, refresh all inline images in current tree.

Key Bindings
evil-org-mode-map <normal-state> <return>
evil-org-mode-map <normal-state> RET

+org/dwim-at-point is unused in org.el.

Find all references Functions used by +org/dwim-at-point

Enable edebug Enable tracing
Disassemble Forget

Source Code
;; Defined in ~/.config/emacs/modules/lang/org/autoload/org.el
(defun +org/dwim-at-point (&optional arg)
  "Do-what-I-mean at point.


Symbol Properties
  (+org/dwim-at-point 0)
   (autoload "~/.config/emacs/modules/lang/org/autoload/org"
     ("/home/user/.config/emacs/.local/etc/@/init.29.elc" . 180542)
     t nil))
  ((0 . +org/dwim-at-point))
  • Are you typing the characters or are you using C-c C-c somewhere on the line to change the state of a checkbox? If the latter, it will be relatively easy; if the former, it still can be done I think but it will be much more complicated.
    – NickD
    Feb 11 at 20:00
  • @NickD I'm just using the enter/return character. Feb 11 at 20:59
  • To change the state of the checkbox? I don't think that works - does it? Where exactly do you press it? Inside a checkbox? When I do that, it just breaks the line at that point.
    – NickD
    Feb 12 at 3:16
  • @NickD Maybe it's because I'm on Doom Emacs and Evil-Mode? I press enter/return anywhere on the checkbox or right before or after it, and I'm not in "input mode". Feb 13 at 10:11
  • OK - maybe. What does C-h k RET say when you do it at the same place where it switches the checkbox state?
    – NickD
    Feb 13 at 15:10

1 Answer 1


Inspecting the +org/dwim-at-point function, we find that it uses org-toggle-checkbox.

Therefore, we can simply advise that function to add the play sound functionality as follows:

(defun org-toggle-checkbox-ad (_)
  (play-sound-file (pcase (match-string 1)
             ("[ ]" "path/to/sound/file1.wav")
             ("[X]" "path/to/sound/file2.wav")
             ("[-]" "path/to/sound/file3.wav"))))

(advice-add 'org-toggle-checkbox :after #'org-toggle-checkbox-ad)

Like in the +org/dwim-at-point we use (org-at-item-checkbox-p) so that to simply obtain the checkbox (string) using match-string.

Unfortunately, I can't get play-sound-file to work here, as I don't know how to configure the sound device, but if I could, then it would only play .wav or .au files.

However, we can simply call a command line application to play the sounds, e.g. ogg123 to play an .ogg file as follows:

(defun org-toggle-checkbox-ad (_)
  (call-process "ogg123" nil nil nil
        (pcase (match-string 1)
          ("[ ]" "/path/to/sound1.ogg")
          ("[X]" "/path/to/sound2.ogg")
          ("[-]" "/path/to/sound3.ogg"))))

When using the code in the second block, don't forget to additionally advise the org-toggle-checkbox function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.