|
@@ -1,4 +1,4 @@
|
|
|
- #+PROPERTY: header-args :results silent
|
|
|
+#+PROPERTY: header-args :results silent
|
|
|
|
|
|
# These function update date strings in a buffer.
|
|
|
#
|
|
@@ -61,26 +61,40 @@
|
|
|
)
|
|
|
#+end_src
|
|
|
|
|
|
-;; update date string for N lines around point
|
|
|
-
|
|
|
;; make sure we have an active region; if not set to current line
|
|
|
-* IN-PROGRESS Update date in first N lines
|
|
|
+* DONE Update date in first N lines
|
|
|
#+begin_src elisp
|
|
|
-
|
|
|
-(defun gmj/update-date-first-n-lines ()
|
|
|
- "Update date stamps in whole buffer "
|
|
|
- (interactive)
|
|
|
+(defun gmj/update-date-first-n-lines (linesArg)
|
|
|
+ "Update date stamps first N lines, default 8"
|
|
|
+ (interactive "p")
|
|
|
(save-excursion
|
|
|
- (let (p1 p2)
|
|
|
+ (let (p1 p2 lines)
|
|
|
+
|
|
|
+ (if (= linesArg 1)
|
|
|
+ (setq lines 8)
|
|
|
+ (setq lines linesArg))
|
|
|
+
|
|
|
(setq p1 (point-min))
|
|
|
(goto-char (point-min))
|
|
|
- (forward-line 8)
|
|
|
+ (forward-line lines)
|
|
|
(setq p2 (point))
|
|
|
(gmj/update-date p1 p2)
|
|
|
)))
|
|
|
#+end_src
|
|
|
|
|
|
-** TODO Update date, N-lines around point
|
|
|
+** DONE Update dates in current block
|
|
|
+#+begin_src elisp
|
|
|
+(defun gmj/update-date-current-block ()
|
|
|
+ "Update date string in current-block"
|
|
|
+ (interactive)
|
|
|
+ (save-excursion
|
|
|
+ (xah-select-block)
|
|
|
+ (gmj/update-date-region)
|
|
|
+ )
|
|
|
+ )
|
|
|
+#+end_src
|
|
|
+
|
|
|
+
|
|
|
|
|
|
* DONE Update date in specified region
|
|
|
#+begin_src elisp
|
|
@@ -105,3 +119,24 @@
|
|
|
)
|
|
|
|
|
|
#+end_src
|
|
|
+
|
|
|
+* Add the 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"
|
|
|
+ (interactive)
|
|
|
+ (progn
|
|
|
+ (message "gmj-update-save-date-hook")
|
|
|
+ (gmj/update-date-current-block))
|
|
|
+ )
|
|
|
+
|
|
|
+ (add-hook 'before-save-hook 'gmj-update-date-save-hook)
|
|
|
+ #+end_src
|
|
|
+
|
|
|
+ ;; (when (string= (file-name-nondirectory (buffer-file-name)) "accounts.org.gpg")
|
|
|
+ ;; (gmj-set-accounts-property-defaults)))
|
|
|
+
|
|
|
+
|
|
|
+;(add-hook 'find-file-hook 'accounts.org_file_hook)
|