From 8d87b946fcf9af3bb4d0d6979cc3826c1f8115ed Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 1 Sep 2021 17:15:36 -0500 Subject: Fix acdw/org-next-heading-widen --- lisp/acdw-org.el | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'lisp/acdw-org.el') diff --git a/lisp/acdw-org.el b/lisp/acdw-org.el index 50a0488..d7137b7 100644 --- a/lisp/acdw-org.el +++ b/lisp/acdw-org.el @@ -370,14 +370,16 @@ instead of the true count." ;;; Next and previous heading, with widening (defun acdw/org-next-heading-widen (arg) (interactive "p") - (let ((point-target (if (> arg 0) - (point-max) - (point-min)))) - (unless (or (org-next-visible-heading arg) ; XXX: this doesn't work!!! ARGH - (/= (point) point-target)) - (when (buffer-narrowed-p) - (widen) - (org-next-visible-heading arg))))) + (let ((current-point (point)) + (point-target (if (> arg 0) (point-max) (point-min)))) + (org-next-visible-heading arg) + (when (and (buffer-narrowed-p) + (= (point) point-target) + (or (and (> arg 0)) + (and (< arg 0) + (= (point) current-point)))) + (widen) + (org-next-visible-heading arg)))) (defun acdw/org-previous-heading-widen (arg) (interactive "p") -- cgit 1.4.1-21-gabe81 From 55c563b37f9d8b4f78f97c92e497eead8ec78744 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 1 Sep 2021 17:16:29 -0500 Subject: Add acdw-org/work-month-headings --- lisp/acdw-org.el | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'lisp/acdw-org.el') diff --git a/lisp/acdw-org.el b/lisp/acdw-org.el index d7137b7..89269ab 100644 --- a/lisp/acdw-org.el +++ b/lisp/acdw-org.el @@ -385,6 +385,34 @@ instead of the true count." (interactive "p") (acdw/org-next-heading-widen (- arg))) + +;;; Add headings for every day of the work month +;; Gets rid of weekends. + +(defun acdw-org/work-month-headings (&optional month year) + (interactive (list + (read-number "Month: " (car (calendar-current-date))) + (read-number "Year: " (nth 2 (calendar-current-date))))) + (let ((offset 0) + (month (or month + (car (calendar-current-date)))) + (year (or year + (car (last (calendar-current-date)))))) + (dotimes (day (calendar-last-day-of-month month year)) + (let* ((day (1+ day)) + (day-of-week (calendar-day-of-week (list month day year)))) + (unless (memq day-of-week '(0 6)) ; weekend + (end-of-line) + (org-insert-heading nil t t) + (insert (concat "[" (mapconcat (lambda (n) + (format "%02d" n)) + (list year month day) + "-") + " " + (nth day-of-week '("Sun" "Mon" "Tue" "Wed" "Thu" + "Fri" "Sat")) + "]"))))))) + (provide 'acdw-org) ;; acdw-org.el ends here -- cgit 1.4.1-21-gabe81