Updating date in org file

simple and fun

Published July 10, 2023

emacs, org-mode
Contents

More on the learning to emacs.

  1. Save the cursor position to orig-point
  2. Go to the beginning of the file
  3. Look for #+date
  4. If you find it, move to the beginning of the line and delete it
  5. Otherwise move down one line
  6. Insert the new date
  7. 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)))

Previously

bad analogies

2023-07-09

Next

Playing with unocss Slimmer than tailwind, but still cool

2023-07-10

labnotes

Previously

Watching a directory for changes simple job queue

2023-07-03

Next

Playing with unocss Slimmer than tailwind, but still cool

2023-07-10