aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Berman2013-06-01 01:37:53 +0200
committerStephen Berman2013-06-01 01:37:53 +0200
commite4ae44d9501d524b1c2995395e434f6555f893b0 (patch)
tree8499fcdad8294a1c5bee7567e323f91f03bcdd55
parent9fa64073386ba6607afdddd773be9aed2a85370d (diff)
downloademacs-e4ae44d9501d524b1c2995395e434f6555f893b0.tar.gz
emacs-e4ae44d9501d524b1c2995395e434f6555f893b0.zip
* todos.el: Move auto-mode-alist entries above provide sexp.
Update adapted diary-goto-entry, so it also works with todo items when the buffer in which the included todo file is processed for the Fancy Diary is not killed. (todos-insert-item-from-calendar): Move to item editing commands section of file. Add doc string, use todos-basic-insert-item and remove mistaken invocation of todos-show.
-rw-r--r--lisp/calendar/ChangeLog10
-rw-r--r--lisp/calendar/todos.el136
2 files changed, 80 insertions, 66 deletions
diff --git a/lisp/calendar/ChangeLog b/lisp/calendar/ChangeLog
index 43fbbf2ec41..b794836dca4 100644
--- a/lisp/calendar/ChangeLog
+++ b/lisp/calendar/ChangeLog
@@ -1,5 +1,15 @@
12013-05-31 Stephen Berman <stephen.berman@gmx.net> 12013-05-31 Stephen Berman <stephen.berman@gmx.net>
2 2
3 * todos.el: Move auto-mode-alist entries above provide sexp.
4 Update adapted diary-goto-entry, so it also works with todo items
5 when the buffer in which the included todo file is processed for
6 the Fancy Diary is not killed.
7 (todos-insert-item-from-calendar): Move to item editing commands
8 section of file. Add doc string, use todos-basic-insert-item and
9 remove mistaken invocation of todos-show.
10
112013-05-31 Stephen Berman <stephen.berman@gmx.net>
12
3 * todos.el (todos-edit-quit): After editing an item, make sure to 13 * todos.el (todos-edit-quit): After editing an item, make sure to
4 return to its category. 14 return to its category.
5 15
diff --git a/lisp/calendar/todos.el b/lisp/calendar/todos.el
index 0bbf139b7ee..415615c726d 100644
--- a/lisp/calendar/todos.el
+++ b/lisp/calendar/todos.el
@@ -28,7 +28,7 @@
28;;; Code: 28;;; Code:
29 29
30(require 'diary-lib) 30(require 'diary-lib)
31;; For cl-remove-duplicates in todos-insertion-commands-args and cl-oddp. 31;; For cl-remove-duplicates (in todos-insertion-commands-args) and cl-oddp.
32(require 'cl-lib) 32(require 'cl-lib)
33 33
34;; ============================================================================= 34;; =============================================================================
@@ -38,8 +38,6 @@
38;;; Options for file and category selection 38;;; Options for file and category selection
39;; ----------------------------------------------------------------------------- 39;; -----------------------------------------------------------------------------
40 40
41;; These definitions have to precede `todos-filter-files'.
42
43(defcustom todos-directory (locate-user-emacs-file "todos/") 41(defcustom todos-directory (locate-user-emacs-file "todos/")
44 "Directory where user's Todos files are saved." 42 "Directory where user's Todos files are saved."
45 :type 'directory 43 :type 'directory
@@ -1222,17 +1220,6 @@ the new item:
1222 (if (or diary todos-include-in-diary) (todos-update-count 'diary 1)) 1220 (if (or diary todos-include-in-diary) (todos-update-count 'diary 1))
1223 (todos-update-categories-sexp)))))) 1221 (todos-update-categories-sexp))))))
1224 1222
1225(defun todos-copy-item ()
1226 "Copy item at point and insert the copy as a new item."
1227 (interactive)
1228 (unless (or (todos-done-item-p) (looking-at "^$"))
1229 (let ((copy (todos-item-string))
1230 (diary-item (todos-diary-item-p)))
1231 (todos-set-item-priority copy (todos-current-category) t)
1232 (todos-update-count 'todo 1)
1233 (when diary-item (todos-update-count 'diary 1))
1234 (todos-update-categories-sexp))))
1235
1236(defvar todos-date-from-calendar nil 1223(defvar todos-date-from-calendar nil
1237 "Helper variable for setting item date from the Emacs Calendar.") 1224 "Helper variable for setting item date from the Emacs Calendar.")
1238 1225
@@ -1266,6 +1253,32 @@ the new item:
1266 (when (stringp todos-date-from-calendar) 1253 (when (stringp todos-date-from-calendar)
1267 todos-date-from-calendar))))) 1254 todos-date-from-calendar)))))
1268 1255
1256(defun todos-insert-item-from-calendar (&optional arg)
1257 "Prompt for and insert a new item with date selected from calendar.
1258Invoked without a prefix argument, insert the item into the
1259current category, without one prefix argument, prompt for the
1260category from the current todo file or from one listed in
1261`todos-category-completions-files'; with two prefix arguments,
1262prompt for a todo file and then for a category in it."
1263 (interactive "P")
1264 (setq todos-date-from-calendar
1265 (calendar-date-string (calendar-cursor-to-date t) t t))
1266 (calendar-exit)
1267 (todos-basic-insert-item arg nil nil todos-date-from-calendar))
1268
1269(define-key calendar-mode-map "it" 'todos-insert-item-from-calendar)
1270
1271(defun todos-copy-item ()
1272 "Copy item at point and insert the copy as a new item."
1273 (interactive)
1274 (unless (or (todos-done-item-p) (looking-at "^$"))
1275 (let ((copy (todos-item-string))
1276 (diary-item (todos-diary-item-p)))
1277 (todos-set-item-priority copy (todos-current-category) t)
1278 (todos-update-count 'todo 1)
1279 (when diary-item (todos-update-count 'diary 1))
1280 (todos-update-categories-sexp))))
1281
1269(defun todos-delete-item () 1282(defun todos-delete-item ()
1270 "Delete at least one item in this category. 1283 "Delete at least one item in this category.
1271 1284
@@ -6234,63 +6247,54 @@ Added to `window-configuration-change-hook' in `todos-mode'."
6234 (todos-modes-set-1) 6247 (todos-modes-set-1)
6235 (todos-modes-set-2)) 6248 (todos-modes-set-2))
6236 6249
6237;; -----------------------------------------------------------------------------
6238(provide 'todos)
6239
6240;;; todos.el ends here
6241
6242;; FIXME: remove when part of Emacs
6243;; -----------------------------------------------------------------------------
6244(add-to-list 'auto-mode-alist '("\\.todo\\'" . todos-mode)) 6250(add-to-list 'auto-mode-alist '("\\.todo\\'" . todos-mode))
6245(add-to-list 'auto-mode-alist '("\\.toda\\'" . todos-archive-mode)) 6251(add-to-list 'auto-mode-alist '("\\.toda\\'" . todos-archive-mode))
6246(add-to-list 'auto-mode-alist '("\\.tod[tyr]\\'" . todos-filtered-items-mode)) 6252(add-to-list 'auto-mode-alist '("\\.tod[tyr]\\'" . todos-filtered-items-mode))
6247 6253
6248;;; Addition to calendar.el 6254;; -----------------------------------------------------------------------------
6249;; FIXME: autoload when key-binding is defined in calendar.el 6255(provide 'todos)
6250(defun todos-insert-item-from-calendar (&optional arg)
6251 ""
6252 (interactive "P")
6253 (setq todos-date-from-calendar
6254 (calendar-date-string (calendar-cursor-to-date t) t t))
6255 (calendar-exit)
6256 (todos-show)
6257 (todos-insert-item arg nil nil todos-date-from-calendar))
6258 6256
6259(define-key calendar-mode-map "it" 'todos-insert-item-from-calendar) 6257;;; todos.el ends here
6260 6258
6261;;; necessitated adaptations to diary-lib.el 6259;;; necessitated adaptations to diary-lib.el
6262 6260
6263;; (defun diary-goto-entry (button) 6261(defun diary-goto-entry (button)
6264;; "Jump to the diary entry for the BUTTON at point." 6262 "Jump to the diary entry for the BUTTON at point."
6265;; (let* ((locator (button-get button 'locator)) 6263 (let* ((locator (button-get button 'locator))
6266;; (marker (car locator)) 6264 (marker (car locator))
6267;; markbuf file opoint) 6265 markbuf file opoint)
6268;; ;; If marker pointing to diary location is valid, use that. 6266 ;; If marker pointing to diary location is valid, use that.
6269;; (if (and marker (setq markbuf (marker-buffer marker))) 6267 (if (and marker (setq markbuf (marker-buffer marker)))
6270;; (progn 6268 (progn
6271;; (pop-to-buffer markbuf) 6269 (pop-to-buffer markbuf)
6272;; (goto-char (marker-position marker))) 6270 (when (eq major-mode 'todos-mode) (widen))
6273;; ;; Marker is invalid (eg buffer has been killed, as is the case with 6271 (goto-char (marker-position marker))
6274;; ;; included diary files). 6272 (when (eq major-mode 'todos-mode)
6275;; (or (and (setq file (cadr locator)) 6273 (re-search-backward (concat "^" (regexp-quote todos-category-beg)
6276;; (file-exists-p file) 6274 "\\(.*\\)\n") nil t)
6277;; (find-file-other-window file) 6275 (todos-category-number (match-string 1))
6278;; (progn 6276 (todos-category-select)
6279;; (when (eq major-mode (default-value 'major-mode)) (diary-mode)) 6277 (goto-char (marker-position marker))))
6280;; (when (eq major-mode 'todos-mode) (widen)) 6278 ;; Marker is invalid (eg buffer has been killed).
6281;; (goto-char (point-min)) 6279 (or (and (setq file (cadr locator))
6282;; (when (re-search-forward (format "%s.*\\(%s\\)" 6280 (file-exists-p file)
6283;; (regexp-quote (nth 2 locator)) 6281 (find-file-other-window file)
6284;; (regexp-quote (nth 3 locator))) 6282 (progn
6285;; nil t) 6283 (when (eq major-mode (default-value 'major-mode)) (diary-mode))
6286;; (goto-char (match-beginning 1)) 6284 (when (eq major-mode 'todos-mode) (widen))
6287;; (when (eq major-mode 'todos-mode) 6285 (goto-char (point-min))
6288;; (setq opoint (point)) 6286 (when (re-search-forward (format "%s.*\\(%s\\)"
6289;; (re-search-backward (concat "^" 6287 (regexp-quote (nth 2 locator))
6290;; (regexp-quote todos-category-beg) 6288 (regexp-quote (nth 3 locator)))
6291;; "\\(.*\\)\n") 6289 nil t)
6292;; nil t) 6290 (goto-char (match-beginning 1))
6293;; (todos-category-number (match-string 1)) 6291 (when (eq major-mode 'todos-mode)
6294;; (todos-category-select) 6292 (setq opoint (point))
6295;; (goto-char opoint))))) 6293 (re-search-backward (concat "^"
6296;; (message "Unable to locate this diary entry"))))) 6294 (regexp-quote todos-category-beg)
6295 "\\(.*\\)\n")
6296 nil t)
6297 (todos-category-number (match-string 1))
6298 (todos-category-select)
6299 (goto-char opoint)))))
6300 (message "Unable to locate this diary entry")))))