|
@@ -11,15 +11,8 @@
|
|
|
# .*date: <.*>
|
|
|
#
|
|
|
#
|
|
|
-
|
|
|
-
|
|
|
-# hook to update date strings on write
|
|
|
-#
|
|
|
-# - First N lines
|
|
|
+# Also adds hook to update dates in file on save
|
|
|
#
|
|
|
-# - N lines around point
|
|
|
-#
|
|
|
-# update date string in first N lines
|
|
|
|
|
|
* Reference
|
|
|
See [[file:~/home/public/elisp-public/gmj-set-accounts-property-dates.el::defun gmj-set-accounts-property-defaults (][gmj-set-accounts-proptery-defaults]] for an earlier, related hack.
|
|
@@ -61,7 +54,6 @@
|
|
|
)
|
|
|
#+end_src
|
|
|
|
|
|
-;; make sure we have an active region; if not set to current line
|
|
|
* DONE Update date in first N lines
|
|
|
#+begin_src elisp
|
|
|
(defun gmj/update-date-first-n-lines (linesArg)
|
|
@@ -94,11 +86,8 @@
|
|
|
)
|
|
|
#+end_src
|
|
|
|
|
|
-
|
|
|
-
|
|
|
* DONE Update date in specified region
|
|
|
#+begin_src elisp
|
|
|
-
|
|
|
(defun gmj/update-date (start end)
|
|
|
"Update date string in region"
|
|
|
;;(interactive)
|
|
@@ -117,21 +106,22 @@
|
|
|
(replace-match (concat "date: " (format-time-string "<%Y-%m-%d %a %H:%M:%S>")) nil t))
|
|
|
)
|
|
|
)
|
|
|
-
|
|
|
#+end_src
|
|
|
|
|
|
-* Add the hook
|
|
|
+* DONE Add the save hook
|
|
|
#+begin_src elisp
|
|
|
(remove-hook 'before-save-hook 'gmj-update-date-save-hook)
|
|
|
|
|
|
(defun gmj-update-date-save-hook ()
|
|
|
- "Update 'date: lines at start of file and in current block"
|
|
|
+ "On save, update 'date: lines at start of file and in current block"
|
|
|
(interactive)
|
|
|
(progn
|
|
|
- (message "gmj-update-save-date-hook")
|
|
|
- (gmj/update-date-current-block))
|
|
|
- )
|
|
|
-
|
|
|
+ (message "gmj-update-save-date-hook start")
|
|
|
+ (gmj/update-date-current-block)
|
|
|
+ (gmj/update-date-first-n-lines 10)
|
|
|
+ (message "gmj-update-save-date-hook end"))
|
|
|
+ )
|
|
|
+
|
|
|
(add-hook 'before-save-hook 'gmj-update-date-save-hook)
|
|
|
#+end_src
|
|
|
|
|
@@ -140,3 +130,4 @@
|
|
|
|
|
|
|
|
|
;(add-hook 'find-file-hook 'accounts.org_file_hook)
|
|
|
+
|