Selaa lähdekoodia

buffer/region/first-n working

George Jones 3 vuotta sitten
vanhempi
commit
13d6707661
1 muutettua tiedostoa jossa 25 lisäystä ja 7 poistoa
  1. 25 7
      elisp-public/gmj-update-date.org

+ 25 - 7
elisp-public/gmj-update-date.org

@@ -22,7 +22,6 @@
 #  update date string in first N lines
 
 * DONE Update date in whole buffer
-  - State "DONE"       from              [2020-12-19 Sat 06:57]
 #+begin_src elisp
 (defun gmj/update-date-buffer ()
   "Update date stamps in whole buffer "
@@ -48,11 +47,9 @@
       (progn
         (if (use-region-p)
             (progn
-                                        ;(message "use-region-p is t")
               (setq p1 (region-beginning) p2 (region-end))
               )
           (progn
-                                        ;(message "use-region-p is nil")
             (setq p1 (line-beginning-position)  p2 (line-end-position)))
           )
 
@@ -66,16 +63,36 @@
 ;; update date string for N lines around point
 
 ;; make sure we have an active region; if not set to current line
-* TODO Update date in first N lines
+* IN-PROGRESS Update date in first N lines
+  - State "IN-PROGRESS" from "TODO"       [2020-12-19 Sat 07:35]
+#+begin_src elisp
+
+(defun gmj/update-date-first-n-lines ()
+  "Update date stamps in whole buffer "
+  (interactive)
+  (save-excursion
+    (let (p1 p2)
+      (setq p1 (point-min))
+      (goto-char (point-min))
+      (forward-line 8)
+      (setq p2 (point))
+      (gmj/update-date p1 p2)
+      )))
+#+end_src
+
+* TODO Update date, N-lines around point
+
+
 * IN-PROGRESS Update date in specified region
 
   - State "IN-PROGRESS" from              [2020-12-19 Sat 06:57]
 #+begin_src elisp
 (defun gmj/update-date (start end)
   "Update date string in region"
+  ;;(interactive)
   (save-restriction
       (narrow-to-region start end)
-      (goto-char (point-min))
+      (goto-char start)
 
       ;; Add date to blank line
       (while (search-forward "date: " nil t)
@@ -89,13 +106,14 @@
 
           )
         )
-      (goto-char (point-min))
+      ;(goto-char (point-min))
 
       ;; Replace existing date
 
       ;; (while (search-forward " beta" nil t)
       ;;   (replace-match " β" nil t))
-      (goto-char (point-min))
+      ;(goto-char (point-min))
       )
   )
+
 #+end_src