+2013-05-20 Stephen Berman <stephen.berman@gmx.net>
+
+ * 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.
+
2013-05-17 Stephen Berman <stephen.berman@gmx.net>
* todos.el (todos-done-separator): Use window-width for length, in
(cis2 (upcase s2)))
(string< cis1 cis2))))))
+;; (defun todos-filtered-items-files ()
+;; (directory-files todos-directory t "\.tod[rty]$" t))
+
(defcustom todos-files-function 'todos-files
"Function returning the value of the variable `todos-files'.
This function should take an optional argument that, if non-nil,
:group 'todos-mode-display)
(defun todos-mode-line-control (cat)
- "Return a mode line control for Todos buffers.
+ "Return a mode line control for todo or archive file buffers.
Argument CAT is the name of the current Todos category.
This function is the value of the user variable
`todos-mode-line-function'."
(files (mapcar 'todos-short-file-name
(if archive todos-archives todos-files)))
(file (completing-read prompt files nil mustmatch nil nil
- (unless files
+ (if files
+ ;; If user hit RET without choosing
+ ;; a file, default to current file.
+ (todos-short-file-name
+ todos-current-todos-file)
;; Trigger prompt for initial file.
""))))
(unless (file-exists-p todos-directory)
(todos-check-filtered-items-file))
(t
(todos-filter-items-1 filter flist)))
- (when (or new (not file-exists))
- (setq fname (replace-regexp-in-string "-" ", " fname))
- (rename-buffer (format (concat "%s for file" (if multi "s" "")
- " \"%s\"") buf fname)))))
+ (setq fname (replace-regexp-in-string "-" ", "
+ (todos-short-file-name fname)))
+ (rename-buffer (format (concat "%s for file" (if multi "s" "")
+ " \"%s\"") buf fname))))
(defun todos-filter-items-1 (filter file-list)
"Internal subroutine called by `todos-filter-items'.
(archive (string= (match-string 3 str) "(archive) "))
(filcat (match-string 4 str))
(tpriority 1)
- (tpbuf (string-match "top" (buffer-name)))
+ (tpbuf (save-match-data (string-match "top" (buffer-name))))
found)
(setq str (replace-match "" nil nil str 4))
(when tpbuf
(todos-short-file-name todos-current-todos-file)
"\nCategory: " (todos-current-category)))
((eq major-mode 'todos-filtered-items-mode)
- "Todos Top Priorities")))
+ (buffer-name))))
(prefix (propertize (concat todos-prefix " ")
'face 'todos-prefix-string))
(num 0)