I want to set a key binding to insert the date into the buffer. I have written the following lisp in my .emacs file. Using date as an example:
;;put the date
(global-set-key
(kbd "C-c C-d")
(shell-command "date" (current-buffer))
)
The key binding works okay when I use other commands like 'next-line, but shell-command will put it into the *scratch* buffer when the .emacs is read and leaves it at that.
Maybe I need to use shell-command-on-region.
(current-buffer)gets evaluated when your.emacsruns. You want to use(shell-command "date" t)to have it insert in the buffer which is current when you invoke the command, or encapsulate it in adefun, so that it gets evaluated when you execute the function.