aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2009-11-03 22:24:34 +0000
committerStefan Monnier2009-11-03 22:24:34 +0000
commit7e83e8b459e07f89f8a1e3902637b6b2e7a94288 (patch)
tree82860594ff850bdc64e8c6d48c7f0c16f2a64b17
parentfae4e5b9f5047d2bb9d1100162e6be8561af424a (diff)
downloademacs-7e83e8b459e07f89f8a1e3902637b6b2e7a94288.tar.gz
emacs-7e83e8b459e07f89f8a1e3902637b6b2e7a94288.zip
(todo-add-category): Don't hardcode point-min==1.
(todo-top-priorities): Only display-buffer when called interactively. (todo-item-start): Don't save excursion point. (todo-item-end): Be slightly more careful. Add `include-sep' arg. (todo-insert-item-here, todo-file-item, todo-remove-item): Adjust uses of todo-item-start and todo-item-end.
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/calendar/todo-mode.el63
2 files changed, 39 insertions, 31 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d252f343d53..5ccb97f2150 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,12 @@
12009-11-03 Stefan Monnier <monnier@iro.umontreal.ca> 12009-11-03 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * calendar/todo-mode.el (todo-add-category): Don't hardcode point-min==1.
4 (todo-top-priorities): Only display-buffer when called interactively.
5 (todo-item-start): Don't save excursion point.
6 (todo-item-end): Be slightly more careful. Add `include-sep' arg.
7 (todo-insert-item-here, todo-file-item, todo-remove-item):
8 Adjust uses of todo-item-start and todo-item-end.
9
3 * emacs-lisp/autoload.el (generated-autoload-feature): Remove. 10 * emacs-lisp/autoload.el (generated-autoload-feature): Remove.
4 (autoload-rubric): Don't use any more. 11 (autoload-rubric): Don't use any more.
5 * cedet/semantic/fw.el (semantic/loaddefs): 12 * cedet/semantic/fw.el (semantic/loaddefs):
diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el
index 1e06d4a4f3f..fcf060dd6fe 100644
--- a/lisp/calendar/todo-mode.el
+++ b/lisp/calendar/todo-mode.el
@@ -48,7 +48,7 @@
48;; 48;;
49;; Preface, Quickstart Installation 49;; Preface, Quickstart Installation
50;; 50;;
51;; To get this to work, make emacs execute the line 51;; To get this to work, make Emacs execute the line
52;; 52;;
53;; (autoload 'todo-mode "todo-mode" 53;; (autoload 'todo-mode "todo-mode"
54;; "Major mode for editing TODO lists." t) 54;; "Major mode for editing TODO lists." t)
@@ -237,7 +237,7 @@
237;; o GNATS support 237;; o GNATS support
238;; o elide multiline (as in bbdb, or, to a lesser degree, in 238;; o elide multiline (as in bbdb, or, to a lesser degree, in
239;; outline mode) 239;; outline mode)
240;; o rewrite complete package to store data as lisp objects 240;; o rewrite complete package to store data as Lisp objects
241;; and have display modes for display, for diary export, 241;; and have display modes for display, for diary export,
242;; etc. (Richard Stallman pointed out this is a bad idea) 242;; etc. (Richard Stallman pointed out this is a bad idea)
243;; o so base todo-mode.el on generic-mode.el instead 243;; o so base todo-mode.el on generic-mode.el instead
@@ -554,7 +554,7 @@ Use `todo-categories' instead.")
554 (setq todo-categories (cons cat todo-categories)) 554 (setq todo-categories (cons cat todo-categories))
555 (widen) 555 (widen)
556 (goto-char (point-min)) 556 (goto-char (point-min))
557 (if (search-forward "-*- mode: todo; " 17 t) 557 (if (search-forward "-*- mode: todo; " (+ (point-min) 16) t)
558 (kill-line) 558 (kill-line)
559 (insert "-*- mode: todo; \n") 559 (insert "-*- mode: todo; \n")
560 (forward-char -1)) 560 (forward-char -1))
@@ -605,7 +605,7 @@ Use `todo-categories' instead.")
605;;;###autoload 605;;;###autoload
606(defun todo-insert-item (arg) 606(defun todo-insert-item (arg)
607 "Insert new TODO list entry. 607 "Insert new TODO list entry.
608With a prefix argument solicit the category, otherwise use the current 608With a prefix argument ARG solicit the category, otherwise use the current
609category." 609category."
610 (interactive "P") 610 (interactive "P")
611 (save-excursion 611 (save-excursion
@@ -631,11 +631,11 @@ If point is on an empty line, insert the entry there."
631 "New TODO entry: " 631 "New TODO entry: "
632 (if todo-entry-prefix-function 632 (if todo-entry-prefix-function
633 (funcall todo-entry-prefix-function)))))) 633 (funcall todo-entry-prefix-function))))))
634 (unless (and (bolp) (eolp)) (goto-char (todo-item-start))) 634 (unless (and (bolp) (eolp)) (todo-item-start))
635 (insert (concat new-item "\n")) 635 (insert (concat new-item "\n"))
636 (backward-char) 636 (backward-char)
637 ;; put point at start of new entry 637 ;; put point at start of new entry
638 (goto-char (todo-item-start)))) 638 (todo-item-start)))
639 639
640(defun todo-more-important-p (line) 640(defun todo-more-important-p (line)
641 "Ask whether entry is more important than the one at LINE." 641 "Ask whether entry is more important than the one at LINE."
@@ -706,15 +706,15 @@ If point is on an empty line, insert the entry there."
706 "(" comment ")")) 706 "(" comment ")"))
707 (goto-char (todo-item-end)) 707 (goto-char (todo-item-end))
708 (insert " [" (nth todo-category-number todo-categories) "]") 708 (insert " [" (nth todo-category-number todo-categories) "]")
709 (goto-char (todo-item-start)) 709 (todo-item-start)
710 (let ((temp-point (point))) 710 (let ((temp-point (point)))
711 (if (looking-at (regexp-quote todo-prefix)) 711 (if (looking-at (regexp-quote todo-prefix))
712 (replace-match (time-stamp-string)) 712 (replace-match (time-stamp-string))
713 ;; Standard prefix -> timestamp 713 ;; Standard prefix -> timestamp
714 ;; Else prefix non-standard item start with timestamp 714 ;; Else prefix non-standard item start with timestamp
715 (insert (time-stamp-string))) 715 (insert (time-stamp-string)))
716 (append-to-file temp-point (1+ (todo-item-end)) todo-file-done) 716 (append-to-file temp-point (todo-item-end 'include-sep) todo-file-done)
717 (delete-region temp-point (1+ (todo-item-end)))) 717 (delete-region temp-point (todo-item-end 'include-sep)))
718 (todo-backward-item) 718 (todo-backward-item)
719 (message ""))) 719 (message "")))
720 720
@@ -724,16 +724,18 @@ If point is on an empty line, insert the entry there."
724 724
725 725
726;;;###autoload 726;;;###autoload
727(defun todo-top-priorities (&optional nof-priorities category-pr-page) 727(defun todo-top-priorities (&optional nof-priorities category-pr-page
728 interactive)
728 "List top priorities for each category. 729 "List top priorities for each category.
729 730
730Number of entries for each category is given by NOF-PRIORITIES which 731Number of entries for each category is given by NOF-PRIORITIES which
731defaults to \'todo-show-priorities\'. 732defaults to `todo-show-priorities'.
732 733
733If CATEGORY-PR-PAGE is non-nil, a page separator \'^L\' is inserted 734If CATEGORY-PR-PAGE is non-nil, a page separator \'^L\' is inserted
734between each category." 735between each category.
736INTERACTIVE should be non-nil if this function is called interactively."
735 737
736 (interactive "P") 738 (interactive "P\ni\nP")
737 (or nof-priorities (setq nof-priorities todo-show-priorities)) 739 (or nof-priorities (setq nof-priorities todo-show-priorities))
738 (if (listp nof-priorities) ;universal argument 740 (if (listp nof-priorities) ;universal argument
739 (setq nof-priorities (car nof-priorities))) 741 (setq nof-priorities (car nof-priorities)))
@@ -776,10 +778,7 @@ between each category."
776 (and (looking-at " ") (replace-match "")) ;Remove trailing form-feed. 778 (and (looking-at " ") (replace-match "")) ;Remove trailing form-feed.
777 (goto-char (point-min)) ;Due to display buffer 779 (goto-char (point-min)) ;Due to display buffer
778 ))) 780 )))
779 ;; Could have used switch-to-buffer as it has a norecord argument, 781 (when interactive (display-buffer todo-print-buffer-name))
780 ;; which is nice when we are called from e.g. todo-print.
781 ;; Else we could have used pop-to-buffer.
782 (display-buffer todo-print-buffer-name)
783 (message "Type C-x 1 to remove %s window. M-C-v to scroll the help." 782 (message "Type C-x 1 to remove %s window. M-C-v to scroll the help."
784 todo-print-buffer-name))) 783 todo-print-buffer-name)))
785 784
@@ -841,25 +840,27 @@ Number of entries for each category is given by `todo-print-priorities'."
841 item)) 840 item))
842 841
843(defun todo-item-start () 842(defun todo-item-start ()
844 "Return point at start of current TODO list item." 843 "Go to start of current TODO list item and return point."
845 (save-excursion 844 (beginning-of-line)
846 (beginning-of-line) 845 (if (not (looking-at (regexp-quote todo-prefix)))
847 (if (not (looking-at (regexp-quote todo-prefix))) 846 (search-backward-regexp
848 (search-backward-regexp 847 (concat "^" (regexp-quote todo-prefix)) nil t))
849 (concat "^" (regexp-quote todo-prefix)) nil t)) 848 (point))
850 (point))) 849
851 850(defun todo-item-end (&optional include-sep)
852(defun todo-item-end () 851 "Return point at end of current TODO list item.
853 "Return point at end of current TODO list item." 852If INCLUDE-SEP is non-nil, return point after the separator."
854 (save-excursion 853 (save-excursion
855 (end-of-line) 854 (end-of-line)
856 (search-forward-regexp 855 (if (search-forward-regexp
857 (concat "^" (regexp-quote todo-prefix)) nil 'goto-end) 856 (concat "^" (regexp-quote todo-prefix)) nil 'goto-end)
858 (1- (line-beginning-position)))) 857 (goto-char (match-beginning 0)))
858 (unless include-sep (skip-chars-backward "\n"))
859 (point)))
859 860
860(defun todo-remove-item () 861(defun todo-remove-item ()
861 "Delete the current entry from the TODO list." 862 "Delete the current entry from the TODO list."
862 (delete-region (todo-item-start) (1+ (todo-item-end)))) 863 (delete-region (todo-item-start) (todo-item-end 'include-sep)))
863 864
864(defun todo-item-string () 865(defun todo-item-string ()
865 "Return current TODO list entry as a string." 866 "Return current TODO list entry as a string."