diff options
Diffstat (limited to 'lisp/acdw-org.el')
-rw-r--r-- | lisp/acdw-org.el | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/lisp/acdw-org.el b/lisp/acdw-org.el index 50a0488..89269ab 100644 --- a/lisp/acdw-org.el +++ b/lisp/acdw-org.el | |||
@@ -370,19 +370,49 @@ instead of the true count." | |||
370 | ;;; Next and previous heading, with widening | 370 | ;;; Next and previous heading, with widening |
371 | (defun acdw/org-next-heading-widen (arg) | 371 | (defun acdw/org-next-heading-widen (arg) |
372 | (interactive "p") | 372 | (interactive "p") |
373 | (let ((point-target (if (> arg 0) | 373 | (let ((current-point (point)) |
374 | (point-max) | 374 | (point-target (if (> arg 0) (point-max) (point-min)))) |
375 | (point-min)))) | 375 | (org-next-visible-heading arg) |
376 | (unless (or (org-next-visible-heading arg) ; XXX: this doesn't work!!! ARGH | 376 | (when (and (buffer-narrowed-p) |
377 | (/= (point) point-target)) | 377 | (= (point) point-target) |
378 | (when (buffer-narrowed-p) | 378 | (or (and (> arg 0)) |
379 | (widen) | 379 | (and (< arg 0) |
380 | (org-next-visible-heading arg))))) | 380 | (= (point) current-point)))) |
381 | (widen) | ||
382 | (org-next-visible-heading arg)))) | ||
381 | 383 | ||
382 | (defun acdw/org-previous-heading-widen (arg) | 384 | (defun acdw/org-previous-heading-widen (arg) |
383 | (interactive "p") | 385 | (interactive "p") |
384 | (acdw/org-next-heading-widen (- arg))) | 386 | (acdw/org-next-heading-widen (- arg))) |
385 | 387 | ||
386 | 388 | ||
389 | ;;; Add headings for every day of the work month | ||
390 | ;; Gets rid of weekends. | ||
391 | |||
392 | (defun acdw-org/work-month-headings (&optional month year) | ||
393 | (interactive (list | ||
394 | (read-number "Month: " (car (calendar-current-date))) | ||
395 | (read-number "Year: " (nth 2 (calendar-current-date))))) | ||
396 | (let ((offset 0) | ||
397 | (month (or month | ||
398 | (car (calendar-current-date)))) | ||
399 | (year (or year | ||
400 | (car (last (calendar-current-date)))))) | ||
401 | (dotimes (day (calendar-last-day-of-month month year)) | ||
402 | (let* ((day (1+ day)) | ||
403 | (day-of-week (calendar-day-of-week (list month day year)))) | ||
404 | (unless (memq day-of-week '(0 6)) ; weekend | ||
405 | (end-of-line) | ||
406 | (org-insert-heading nil t t) | ||
407 | (insert (concat "[" (mapconcat (lambda (n) | ||
408 | (format "%02d" n)) | ||
409 | (list year month day) | ||
410 | "-") | ||
411 | " " | ||
412 | (nth day-of-week '("Sun" "Mon" "Tue" "Wed" "Thu" | ||
413 | "Fri" "Sat")) | ||
414 | "]"))))))) | ||
415 | |||
416 | |||
387 | (provide 'acdw-org) | 417 | (provide 'acdw-org) |
388 | ;; acdw-org.el ends here | 418 | ;; acdw-org.el ends here |