aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Berman2013-05-20 16:26:08 +0200
committerStephen Berman2013-05-20 16:26:08 +0200
commitd196d62507ea43a65456bf92f64601ba2d060250 (patch)
tree101513696486c9e431adb28b345c4f1b3c582c92
parent17de84fb54684da90fbaf41184a36d25e65688b3 (diff)
downloademacs-d196d62507ea43a65456bf92f64601ba2d060250.tar.gz
emacs-d196d62507ea43a65456bf92f64601ba2d060250.zip
* todos.el: Fixes concerning filtered items.
(todos-mode-line-control): Make doc string more precise. (todos-read-file-name): Default to current file when user hits RET without choosing a file, to avoid creating file with empty base name. (todos-filter-items): Rename buffer of filtered items files. (todos-find-item): Save match data to avoid arg out of range error. (todos-print-buffer): Fix header of filtered items buffer output.
-rw-r--r--lisp/calendar/ChangeLog10
-rw-r--r--lisp/calendar/todos.el23
2 files changed, 25 insertions, 8 deletions
diff --git a/lisp/calendar/ChangeLog b/lisp/calendar/ChangeLog
index 10ea01075ce..7cf8b2f9d15 100644
--- a/lisp/calendar/ChangeLog
+++ b/lisp/calendar/ChangeLog
@@ -1,3 +1,13 @@
12013-05-20 Stephen Berman <stephen.berman@gmx.net>
2
3 * todos.el: Fixes concerning filtered items.
4 (todos-mode-line-control): Make doc string more precise.
5 (todos-read-file-name): Default to current file when user hits RET
6 without choosing a file, to avoid creating file with empty base name.
7 (todos-filter-items): Rename buffer of filtered items files.
8 (todos-find-item): Save match data to avoid arg out of range error.
9 (todos-print-buffer): Fix header of filtered items buffer output.
10
12013-05-17 Stephen Berman <stephen.berman@gmx.net> 112013-05-17 Stephen Berman <stephen.berman@gmx.net>
2 12
3 * todos.el (todos-done-separator): Use window-width for length, in 13 * todos.el (todos-done-separator): Use window-width for length, in
diff --git a/lisp/calendar/todos.el b/lisp/calendar/todos.el
index 5b707de31dc..e7f619256c3 100644
--- a/lisp/calendar/todos.el
+++ b/lisp/calendar/todos.el
@@ -59,6 +59,9 @@ truenames (those with the extension \".toda\")."
59 (cis2 (upcase s2))) 59 (cis2 (upcase s2)))
60 (string< cis1 cis2)))))) 60 (string< cis1 cis2))))))
61 61
62;; (defun todos-filtered-items-files ()
63;; (directory-files todos-directory t "\.tod[rty]$" t))
64
62(defcustom todos-files-function 'todos-files 65(defcustom todos-files-function 'todos-files
63 "Function returning the value of the variable `todos-files'. 66 "Function returning the value of the variable `todos-files'.
64This function should take an optional argument that, if non-nil, 67This function should take an optional argument that, if non-nil,
@@ -330,7 +333,7 @@ the value of `todos-done-separator'."
330 :group 'todos-mode-display) 333 :group 'todos-mode-display)
331 334
332(defun todos-mode-line-control (cat) 335(defun todos-mode-line-control (cat)
333 "Return a mode line control for Todos buffers. 336 "Return a mode line control for todo or archive file buffers.
334Argument CAT is the name of the current Todos category. 337Argument CAT is the name of the current Todos category.
335This function is the value of the user variable 338This function is the value of the user variable
336`todos-mode-line-function'." 339`todos-mode-line-function'."
@@ -1653,7 +1656,11 @@ otherwise, a new file name is allowed."
1653 (files (mapcar 'todos-short-file-name 1656 (files (mapcar 'todos-short-file-name
1654 (if archive todos-archives todos-files))) 1657 (if archive todos-archives todos-files)))
1655 (file (completing-read prompt files nil mustmatch nil nil 1658 (file (completing-read prompt files nil mustmatch nil nil
1656 (unless files 1659 (if files
1660 ;; If user hit RET without choosing
1661 ;; a file, default to current file.
1662 (todos-short-file-name
1663 todos-current-todos-file)
1657 ;; Trigger prompt for initial file. 1664 ;; Trigger prompt for initial file.
1658 "")))) 1665 ""))))
1659 (unless (file-exists-p todos-directory) 1666 (unless (file-exists-p todos-directory)
@@ -2004,10 +2011,10 @@ corresponding multifile commands for further details. "
2004 (todos-check-filtered-items-file)) 2011 (todos-check-filtered-items-file))
2005 (t 2012 (t
2006 (todos-filter-items-1 filter flist))) 2013 (todos-filter-items-1 filter flist)))
2007 (when (or new (not file-exists)) 2014 (setq fname (replace-regexp-in-string "-" ", "
2008 (setq fname (replace-regexp-in-string "-" ", " fname)) 2015 (todos-short-file-name fname)))
2009 (rename-buffer (format (concat "%s for file" (if multi "s" "") 2016 (rename-buffer (format (concat "%s for file" (if multi "s" "")
2010 " \"%s\"") buf fname))))) 2017 " \"%s\"") buf fname))))
2011 2018
2012(defun todos-filter-items-1 (filter file-list) 2019(defun todos-filter-items-1 (filter file-list)
2013 "Internal subroutine called by `todos-filter-items'. 2020 "Internal subroutine called by `todos-filter-items'.
@@ -2241,7 +2248,7 @@ its priority has changed, and `same' otherwise."
2241 (archive (string= (match-string 3 str) "(archive) ")) 2248 (archive (string= (match-string 3 str) "(archive) "))
2242 (filcat (match-string 4 str)) 2249 (filcat (match-string 4 str))
2243 (tpriority 1) 2250 (tpriority 1)
2244 (tpbuf (string-match "top" (buffer-name))) 2251 (tpbuf (save-match-data (string-match "top" (buffer-name))))
2245 found) 2252 found)
2246 (setq str (replace-match "" nil nil str 4)) 2253 (setq str (replace-match "" nil nil str 4))
2247 (when tpbuf 2254 (when tpbuf
@@ -3390,7 +3397,7 @@ otherwise, send it to the default printer."
3390 (todos-short-file-name todos-current-todos-file) 3397 (todos-short-file-name todos-current-todos-file)
3391 "\nCategory: " (todos-current-category))) 3398 "\nCategory: " (todos-current-category)))
3392 ((eq major-mode 'todos-filtered-items-mode) 3399 ((eq major-mode 'todos-filtered-items-mode)
3393 "Todos Top Priorities"))) 3400 (buffer-name))))
3394 (prefix (propertize (concat todos-prefix " ") 3401 (prefix (propertize (concat todos-prefix " ")
3395 'face 'todos-prefix-string)) 3402 'face 'todos-prefix-string))
3396 (num 0) 3403 (num 0)