More on the learning to emacs.
- Save the cursor position to
orig-point
- Go to the beginning of the file
- Look for
#+date
- If you find it, move to the beginning of the line and delete it
- Otherwise move down one line
- Insert the new date
- Go back to where you started
1
2
3
4
5
6
7
8
9
10
11
12
| (defun blog-mode-update-date ()
(interactive)
(let ((orig-point (point)))
(goto-char (point-min))
(if (search-forward "#+date" nil t)
(progn
(move-beginning-of-line 1)
(kill-line))
(progn
(next-line)))
(insert "#+date: " (format-time-string "%Y-%m-%dT%H:%M:%S"))
(goto-char orig-point)))
|