Add alu-time-now
This commit is contained in:
parent
c429981c5e
commit
a303636dfe
24
elisp/README.org
Normal file
24
elisp/README.org
Normal file
|
@ -0,0 +1,24 @@
|
|||
* =alu-time-now=
|
||||
|
||||
This function came from my desire to speed up a repetitive part of my blogging process. I have a
|
||||
last modified field in the metadata for my posts and when go to commit changes, I want to update
|
||||
that value. At first this function just shelled out and called =date=, but it also got tedious to
|
||||
delete the old timestamp. So this function is my one =M-x= solution.
|
||||
|
||||
Notable elisp features:
|
||||
- Using and cleaning up a temporary buffer
|
||||
- Writing the output of a shell command to some buffer
|
||||
- Inserting the content of a buffer into the current buffer
|
||||
|
||||
#+begin_src elisp
|
||||
(defun alu-time-now ()
|
||||
"With point on a date time string, replace with current time"
|
||||
(interactive)
|
||||
(let* ((tmp-buffer (generate-new-buffer "alu-scratch")))
|
||||
(shell-command "date -Iseconds"
|
||||
tmp-buffer)
|
||||
(delete-char 25)
|
||||
(insert-buffer-substring (buffer-name tmp-buffer)
|
||||
1 26)
|
||||
(kill-buffer tmp-buffer)))
|
||||
#+end_src
|
Loading…
Reference in a new issue