I'd like to replicate something in emacs that I do in AutoHotkey all the time:
- type
td
- have that string be replaced with the current date
I'm trying to do this with Emacs abbrevs but I'm running into an Invalid function:
error.
I've also tried using a builtin function, but I get the same Invalid function error. I've done a bunch of research but no avail.
Here's the code I have currently in my .emacs
:
(defun insert-current-iso-date ()
"..."
(format-time-string "%Y-%m-%d"))
(define-abbrev-table 'global-abbrev-table
'(("td" "" (insert-current-iso-date))))
C-u M-! date -I
to insert a date, assuming GNU date, the prefix arg means insert the output of the shell command. I don't have experience with abbrev (it seems too heavy to me), so I'm not sure that's possible with Emacs' built-in abbrev, and I hear YASnippet is popular and powerful.