*** planner.el.orig Mon Jul 19 12:42:56 2004 --- planner.el Fri Jul 16 00:50:53 2004 *************** *** 820,825 **** :type 'boolean :group 'planner) (defcustom planner-renumber-tasks-automatically t ! "Non-nil means sort and renumber tasks whenever a planner file is saved." :type 'boolean :group 'planner) --- 820,829 ---- :type 'boolean :group 'planner) + (defcustom planner-sort-tasks-automatically t + "Non-nil means sort tasks whenever a planner file is saved." + :type 'boolean + :group 'planner) (defcustom planner-renumber-tasks-automatically t ! "Non-nil means renumber tasks whenever a planner file is saved." :type 'boolean :group 'planner) *************** *** 838,841 **** --- 842,847 ---- (when planner-align-tasks-automatically (add-hook hook 'planner-align-tasks nil t)) + (when planner-sort-tasks-automatically + (add-hook hook 'planner-sort-tasks nil t)) (when planner-renumber-tasks-automatically (add-hook hook 'planner-renumber-tasks nil t)) *************** *** 1667,1672 **** (setq tasks (cdr tasks))))) ! (defun planner-renumber-tasks () ! "Update task numbering. On day pages, sort according to category and position. On plan pages, sort according to status, category, date, and position." --- 1673,1678 ---- (setq tasks (cdr tasks))))) ! (defun planner-sort-tasks () ! "Sort the tasks. On day pages, sort according to category and position. On plan pages, sort according to status, category, date, and position." *************** *** 1723,1737 **** (buffer-substring (point) (+ 10 (point))) ! ""))))) nil))) ; sort-fields ! ;; Fix numbering after completed tasks are moved to the bottom. (goto-char (point-min)) (let ((counters (list (cons "A" 1) (cons "B" 1) (cons "C" 1)))) (while (re-search-forward "^#\\([A-C]\\)\\([0-9]+\\)" nil t) ! (let ((counter (assoc (match-string 1) counters))) ! (replace-match (number-to-string (cdr counter)) t t nil 2) ! (setcdr counter (1+ (cdr counter)))))) (goto-char old-point)) ! nil) ; Must return nil because of write-file-functions ;;;_ + Notes --- 1729,1750 ---- (buffer-substring (point) (+ 10 (point))) ! ""))))) nil))) ; sort-fields ! (goto-char old-point)) ! nil) ; Must return nil because of write-file-functions ! ! (defun planner-renumber-tasks () ! "Update task numbering to be in sequence once again." ! (interactive) ! (let ((old-point (point))) (goto-char (point-min)) (let ((counters (list (cons "A" 1) (cons "B" 1) (cons "C" 1)))) (while (re-search-forward "^#\\([A-C]\\)\\([0-9]+\\)" nil t) ! (let ((counter (assoc (match-string 1) counters))) ! (replace-match (number-to-string (cdr counter)) t t nil 2) ! (setcdr counter (1+ (cdr counter)))))) (goto-char old-point)) ! nil) ; Must return nil because of write-file-functions ! ;;;_ + Notes *************** *** 2215,2220 **** ;; Jump to the most recent daily page (planner-save-buffers) - (with-emacs-wiki-project planner-project - (emacs-wiki-refresh-file-alist)) (if (planner-page-file today) (planner-goto-today) --- 2228,2231 ---- *************** *** 2724,2760 **** ;;;_ + Extracting - (defun planner-seek-next-unfinished-task () - "Move point to the next unfinished task on this page. - Return nil if not found." - (interactive) - (re-search-forward "^#[A-C][0-9]*\\s-+[_o>P]\\s-+" nil t)) - (defun planner-list-tasks-with-status (status &optional check-plan-pages) ! "Display all tasks that match the STATUS regular expression on all day pages. ! If CHECK-PLAN-PAGES is non-nil, plan pages are also checked. This ! could take a long time." (interactive (list (read-string "Status: "))) (set-buffer (get-buffer-create "*Planner Tasks*")) (erase-buffer) ! (let ((emacs-wiki-project planner-project)) ! (planner-mode) ! (let ((planner-task-format "#%s%s]] | %s | %s%s") ! tasks) ! (setq tasks (planner-extract-tasks ! (if check-plan-pages ! (planner-file-alist) ! (planner-get-day-pages)) ! (lambda (item) ! (string-match status (planner-task-status item))))) ! (while tasks ! (insert ! "[[" ! (planner-task-date (car tasks)) ! (planner-format-task (car tasks) nil ! (or (planner-task-priority (car tasks)) "")) ! "\n") ! (setq tasks (cdr tasks)))) ! (goto-char (point-min)) ! (pop-to-buffer (current-buffer)))) (defun planner-list-unfinished-tasks () --- 2735,2764 ---- ;;;_ + Extracting (defun planner-list-tasks-with-status (status &optional check-plan-pages) ! "Display all tasks that match the STATUS regular expression. ! If CHECK-PLAN-PAGES is non-nil, plan pages are also checked. ! This could take a long time." (interactive (list (read-string "Status: "))) (set-buffer (get-buffer-create "*Planner Tasks*")) (erase-buffer) ! (emacs-wiki-change-project planner-project) ! (let ((planner-task-format "#%s%s]] | %s | %s%s") ! tasks) ! (setq tasks (planner-extract-tasks ! (if check-plan-pages ! (planner-file-alist) ! (planner-get-day-pages)) ! (lambda (item) ! (string-match status (planner-task-status item))))) ! (while tasks ! (insert ! "[[" ! (planner-task-date (car tasks)) ! (planner-format-task (car tasks) nil ! (or (planner-task-priority (car tasks)) "")) ! "\n") ! (setq tasks (cdr tasks)))) ! (goto-char (point-min)) ! (pop-to-buffer (current-buffer))) (defun planner-list-unfinished-tasks ()