-;;; todo-mode.el --- facilities for making and maintaining todo lists
+;;; todo-mode.el --- facilities for making and maintaining todo lists -*- lexical-binding:t -*-
;; Copyright (C) 1997, 1999, 2001-2017 Free Software Foundation, Inc.
\".todo\". With non-nil ARCHIVES return the list of archive file
truenames (those with the extension \".toda\")."
(let ((files (if (file-exists-p todo-directory)
- (mapcar 'file-truename
+ (mapcar #'file-truename
(directory-files todo-directory t
- (if archives "\\.toda$" "\\.todo$") t)))))
+ (if archives "\\.toda\\'" "\\.todo\\'") t)))))
(sort files (lambda (s1 s2) (let ((cis1 (upcase s1))
(cis2 (upcase s2)))
(string< cis1 cis2))))))
-(defcustom todo-files-function 'todo-files
+(defcustom todo-files-function #'todo-files
"Function returning the value of the variable `todo-files'.
This function should take an optional argument that, if non-nil,
makes it return the value of the variable `todo-archives'."
"Array of abbreviated month names, in order.
The final element is \"*\", indicating an unspecified month.")
+(with-no-warnings
+ ;; FIXME: These vars lack a prefix, but this is out of our control, because
+ ;; they're defined by Calendar, e.g. for calendar-date-display-form.
+ (defvar dayname)
+ (defvar monthname)
+ (defvar day)
+ (defvar month)
+ (defvar year))
+
(defconst todo-date-pattern
(let ((dayname (diary-name-pattern calendar-day-name-array nil t)))
(concat "\\(?4:\\(?5:" dayname "\\)\\|"
(month "\\(?7:[0-9]+\\|\\*\\)")
(day "\\(?8:[0-9]+\\|\\*\\)")
(year "-?\\(?9:[0-9]+\\|\\*\\)"))
- (mapconcat 'eval calendar-date-display-form ""))
+ (mapconcat #'eval calendar-date-display-form ""))
"\\)"))
"Regular expression matching a todo item date header.")
(let ((file (todo-short-file-name todo-current-todo-file)))
(format "%s category %d: %s" file todo-category-number cat)))
-(defcustom todo-mode-line-function 'todo-mode-line-control
+(defcustom todo-mode-line-function #'todo-mode-line-control
"Function that returns a mode line control for Todo mode buffers.
The function expects one argument holding the name of the current
todo category. The resulting control becomes the local value of
(when (stringp file)
(file-name-sans-extension (file-name-nondirectory file))))
+(defun todo--files-type-list ()
+ (mapcar (lambda (f) (list 'const (todo-short-file-name f)))
+ (funcall todo-files-function)))
+
(defcustom todo-default-todo-file (todo-short-file-name
(car (funcall todo-files-function)))
"Todo file visited by first session invocation of `todo-show'."
:type (when todo-files
- `(radio ,@(mapcar (lambda (f) (list 'const f))
- (mapcar 'todo-short-file-name
- (funcall todo-files-function)))))
+ `(radio ,@(todo--files-type-list)))
:group 'todo)
(defcustom todo-show-current-file t
(defcustom todo-category-completions-files nil
"List of files for building `todo-read-category' completions."
- :type `(set ,@(mapcar (lambda (f) (list 'const f))
- (mapcar 'todo-short-file-name
- (funcall todo-files-function))))
+ :type `(set ,@(todo--files-type-list))
:group 'todo)
(defcustom todo-completion-ignore-case nil
(let ((rxfiles (directory-files todo-directory t
".*\\.todr$" t)))
(when (and rxfiles (> (length rxfiles) 1))
- (let ((rxf (mapcar 'todo-short-file-name rxfiles)))
+ (let ((rxf (mapcar #'todo-short-file-name rxfiles)))
(setq fi-file (todo-absolute-file-name
(completing-read
"Choose a regexp items file: "
- rxf) 'regexp))))))
+ rxf)
+ 'regexp))))))
(if (file-exists-p fi-file)
(progn
(set-window-buffer
(zerop (todo-get-count 'done))
(not (zerop (todo-get-count 'archived))))
(setq todo-category-number
- (apply (if back '1- '1+) (list todo-category-number)))))
+ (funcall (if back #'1- #'1+) todo-category-number))))
(todo-category-select)
(goto-char (point-min)))
(snname (todo-short-file-name nname))
(files (directory-files todo-directory t
(concat ".*" (regexp-quote soname)
- ".*\\.tod[aorty]$") t)))
+ ".*\\.tod[aorty]$")
+ t)))
(dolist (f files)
(let* ((sfname (todo-short-file-name f))
(fext (file-name-extension f t))
(let ((buffer-read-only)
(beg (re-search-backward
(concat "^" (regexp-quote (concat todo-category-beg cat))
- "\n") nil t))
+ "\n")
+ nil t))
(end (if (re-search-forward
(concat "\n\\(" (regexp-quote todo-category-beg)
- ".*\n\\)") nil t)
+ ".*\n\\)")
+ nil t)
(match-beginning 1)
(point-max))))
(remove-overlays beg end)
(goto-char (point-max))
(re-search-backward
(concat "^" (regexp-quote todo-category-beg)
- "\\(" (regexp-quote cat) "\\)$") nil t)
+ "\\(" (regexp-quote cat) "\\)$")
+ nil t)
(replace-match new nil nil nil 1))
(setq todo-categories
(append todo-categories (list (cons (or new cat) counts))))
(let ((cat (todo-current-category)))
(unless (> n 1) (setq n 1))
(catch 'end
- (dotimes (i n)
+ (dotimes (_ n)
(let* ((marks (assoc cat todo-categories-with-marks))
(ov (progn
(unless (looking-at todo-item-start)
(todo-item-start)
(re-search-forward
(concat " \\[" (regexp-quote todo-comment-string)
- ": \\([^]]+\\)\\]") end t)))
+ ": \\([^]]+\\)\\]")
+ end t)))
(prompt (if comment "Edit comment: " "Enter a comment: "))
(buffer-read-only nil))
;; When there are marked items, user can invoke todo-edit-item
(todo-item-start)
(if (re-search-forward (concat " \\["
(regexp-quote todo-comment-string)
- ": \\([^]]+\\)\\]") end t)
+ ": \\([^]]+\\)\\]")
+ end t)
(if comment-delete
(when (todo-y-or-n-p "Delete comment? ")
(delete-region (match-beginning 0) (match-end 0)))
(cons item 0))))))
(when include-header
(while (not (string-match (concat todo-date-string-start
- todo-date-pattern) new))
+ todo-date-pattern)
+ new))
(setq new (read-from-minibuffer
"Item must start with a date: " new))))
;; Ensure lines following hard newlines are indented.
(regex "\\(\n\\)[^[:blank:]]")
(buf (buffer-base-buffer)))
(while (not (string-match (concat todo-date-string-start
- todo-date-pattern) item))
+ todo-date-pattern)
+ item))
(setq item (read-from-minibuffer
"Item must start with a date: " item)))
;; Ensure lines following hard newlines are indented.
"\\)\\(?2: " diary-time-regexp "\\)?"
(regexp-quote todo-nondiary-end) "?")
(line-end-position) t)
- (let* ((odate (match-string-no-properties 1))
- (otime (match-string-no-properties 2))
+ (let* ((otime (match-string-no-properties 2))
(odayname (match-string-no-properties 5))
(omonthname (match-string-no-properties 6))
(omonth (match-string-no-properties 7))
(calendar-current-date))))
(date (calendar-gregorian-from-absolute
(+ (calendar-absolute-from-gregorian
- (list mm dd yy)) inc)))
+ (list mm dd yy))
+ inc)))
(adjmm (nth 0 date)))
;; Set year and month(name) to adjusted values.
(unless (string= year "*")
;; If year, month or day date string components were
;; changed, rebuild the date string.
(when (memq what '(year month day))
- (setq ndate (mapconcat 'eval calendar-date-display-form ""))))
+ (setq ndate (mapconcat #'eval calendar-date-display-form ""))))
(when ndate (replace-match ndate nil nil nil 1))
;; Add new time string to the header, if it was supplied.
(when ntime
(when marked (goto-char (point-min)))
(while (not (eobp))
(unless (and marked (not (todo-marked-item-p)))
- (let* ((beg (todo-item-start))
+ (let* ((_beg (todo-item-start))
(lim (save-excursion (todo-item-end)))
(end (save-excursion
(or (todo-time-string-matcher lim)
(while (not (eobp))
(if (todo-done-item-p) ; We've gone too far.
(throw 'stop nil)
- (let* ((beg (todo-item-start))
+ (let* ((_beg (todo-item-start))
(lim (save-excursion (todo-item-end)))
(end (save-excursion
(or (todo-time-string-matcher lim)
(not marked))
(let* ((buffer-read-only)
(file1 todo-current-todo-file)
- (num todo-category-number)
(item (todo-item-string))
- (diary-item (todo-diary-item-p))
(done-item (and (todo-done-item-p) item))
(omark (save-excursion (todo-item-start) (point-marker)))
(todo 0)
;; affirmed, omit subsequent comments without asking.
(when (re-search-forward
(concat " \\[" (regexp-quote todo-comment-string)
- ": [^]]+\\]") end t)
+ ": [^]]+\\]")
+ end t)
(unwind-protect
(if (eq first 'first)
(setq first
(let* ((cat (todo-current-category))
(tbuf (find-file-noselect
(concat (file-name-sans-extension todo-current-todo-file)
- ".todo") t))
+ ".todo")
+ t))
(marked (assoc cat todo-categories-with-marks))
(item (concat (todo-item-string) "\n"))
(marked-count 0)
;; one, add it.
(unless (re-search-forward
(concat "^" (regexp-quote (concat todo-category-beg cat))
- "$") nil t)
+ "$")
+ nil t)
(todo-add-category nil cat)
(setq newcat t))
;; Go to top of category's done section.
(unless prompt (setq priority candidate)))
(let* ((lower (< curnum priority)) ; Priority is being lowered.
(head (butlast todo-categories
- (apply (if lower 'identity '1+)
- (list (- maxnum priority)))))
- (tail (nthcdr (apply (if lower 'identity '1-) (list priority))
+ (funcall (if lower #'identity #'1+)
+ (- maxnum priority))))
+ (tail (nthcdr (funcall (if lower #'identity #'1-) priority)
todo-categories))
;; Category's name and items counts list.
(catcons (nth (1- curnum) todo-categories))
"Return adjusted length of category label button.
The adjustment ensures proper tabular alignment in Todo
Categories mode."
- (let* ((categories (mapcar 'car todo-categories))
+ (let* ((categories (mapcar #'car todo-categories))
(longest (todo-longest-category-name-length categories))
(catlablen (length todo-categories-category-label))
(lc-diff (- longest catlablen)))
ov)
(insert-button str 'face nil
'action
- `(lambda (button)
- (let ((key (todo-label-to-key ,label)))
- (if (and (member key todo-descending-counts)
- (eq key 'alpha))
- (progn
- ;; If display is alphabetical, switch back to
- ;; category priority order.
- (todo-display-sorted nil)
- (setq todo-descending-counts
- (delete key todo-descending-counts)))
- (todo-display-sorted key)))))
+ (lambda (_button)
+ (let ((key (todo-label-to-key label)))
+ (if (and (member key todo-descending-counts)
+ (eq key 'alpha))
+ (progn
+ ;; If display is alphabetical, switch back to
+ ;; category priority order.
+ (todo-display-sorted nil)
+ (setq todo-descending-counts
+ (delete key todo-descending-counts)))
+ (todo-display-sorted key)))))
(setq ov (make-overlay beg end))
(overlay-put ov 'face 'todo-button)))
(defun todo-total-item-counts ()
"Return a list of total item counts for the current file."
- (mapcar (lambda (i) (apply '+ (mapcar (lambda (l) (aref l i))
- (mapcar 'cdr todo-categories))))
+ (mapcar (lambda (i) (apply #'+ (mapcar (lambda (x) (aref (cdr x) i))
+ todo-categories)))
(list 0 1 2 3)))
(defvar todo-categories-category-number 0
(not (zerop (todo-get-count 'archived cat))))
'todo-archived-only
nil)
- 'action `(lambda (button) (let ((buf (current-buffer)))
- (todo-jump-to-category nil ,cat)
- (kill-buffer buf))))
+ 'action (lambda (_button)
+ (let ((buf (current-buffer)))
+ (todo-jump-to-category nil cat)
+ (kill-buffer buf))))
;; Highlight the sorted count column.
(let* ((beg (+ opoint 7 (length str)))
end ovl)
(delete-region (point) (point-max))
;; Fill in the table with buttonized lines, each showing a category and
;; its item counts.
- (mapc (lambda (cat) (todo-insert-category-line cat sortkey))
- (mapcar 'car cats))
+ (dolist (cat cats)
+ (todo-insert-category-line (car cat) sortkey))
(newline)
;; Add a line showing item count totals.
(insert (make-string (+ 4 (length todo-categories-number-separator)) 32)
(when (looking-at todo-done-string-start)
(setq in-done t))
(re-search-backward (concat "^" (regexp-quote todo-category-beg)
- "\\(.*\\)\n") nil t)
+ "\\(.*\\)\n")
+ nil t)
(setq cat (match-string-no-properties 1))
(todo-category-number cat)
(todo-category-select)
(defcustom todo-filter-files nil
"List of default files for multifile item filtering."
- :type `(set ,@(mapcar (lambda (f) (list 'const f))
- (mapcar 'todo-short-file-name
- (funcall todo-files-function))))
+ :type `(set ,@(todo--files-type-list))
:group 'todo-filtered)
(defcustom todo-filter-done-items nil
(widget-insert "Select files for generating the top priorities list.\n\n")
(setq todo-multiple-filter-files-widget
(widget-create
- `(set ,@(mapcar (lambda (x) (list 'const x))
- (mapcar 'todo-short-file-name
- (funcall todo-files-function))))))
+ `(set ,@(todo--files-type-list))))
(widget-insert "\n")
(widget-create 'push-button
- :notify (lambda (widget &rest ignore)
+ :notify (lambda (&rest _)
(setq todo-multiple-filter-files 'quit)
(quit-window t)
(exit-recursive-edit))
"Cancel")
(widget-insert " ")
(widget-create 'push-button
- :notify (lambda (&rest ignore)
+ :notify (lambda (&rest _)
(setq todo-multiple-filter-files
(mapcar (lambda (f)
(file-truename
;; Pressed `cancel' in t-m-f-f file selection dialog.
(keyboard-quit)
(concat todo-directory
- (mapconcat 'todo-short-file-name flist "-")
+ (mapconcat #'todo-short-file-name flist "-")
(cond (top ".todt")
(diary ".tody")
(regexp ".todr")))))
(todo-filter-items-1 (cons 'top new) flist))
((and (not new) file-exists)
(when (and rxfiles (> (length rxfiles) 1))
- (let ((rxf (mapcar 'todo-short-file-name rxfiles)))
+ (let ((rxf (mapcar #'todo-short-file-name rxfiles)))
(setq fname (todo-absolute-file-name
(completing-read "Choose a regexp items file: "
- rxf) 'regexp))))
+ rxf)
+ 'regexp))))
(find-file fname)
(unless (derived-mode-p 'todo-filtered-items-mode)
(todo-filtered-items-mode))
(dolist (s (split-string (todo-short-file-name fname) "-"))
(setq bufname (if bufname
(concat bufname (if (member s (mapcar
- 'todo-short-file-name
+ #'todo-short-file-name
todo-files))
- ", " "-") s)
+ ", " "-")
+ s)
s)))
- (rename-buffer (format (concat "%s for file" (if multi "s" "")
- " \"%s\"") buf bufname))))
+ (rename-buffer (format (concat "%s for file" (if multi "s" "") " \"%s\"")
+ buf bufname))))
(defun todo-filter-items-1 (filter file-list)
"Build a list of items by applying FILTER to FILE-LIST.
todo-top-priorities)))
(while (re-search-forward
(concat "^" (regexp-quote todo-category-beg)
- "\\(.+\\)\n") nil t)
+ "\\(.+\\)\n")
+ nil t)
(setq cat (match-string 1))
(let (cnum)
;; Unless the number of top priorities to show was
"\\]"
(regexp-quote todo-nondiary-end)) "?"
"\\(?4: \\[\\(?3:(archive) \\)?\\(?2:.*:\\)?"
- "\\(?1:.*\\)\\]\\).*$") str)
+ "\\(?1:.*\\)\\]\\).*$")
+ str)
(let ((cat (match-string 1 str))
(file (match-string 2 str))
(archive (string= (match-string 3 str) "(archive) "))
;;; Printing Todo mode buffers
;; -----------------------------------------------------------------------------
-(defcustom todo-print-buffer-function 'ps-print-buffer-with-faces
- "Function called by the command `todo-print-buffer'."
+(defcustom todo-print-buffer-function #'ps-print-buffer-with-faces
+ "Function called by `todo-print-buffer' to print Todo mode buffers.
+The function should take an optional argument whose non-nil value
+is a string naming a file to save the print image to; calling
+`todo-print-buffer-to-file' prompts for the file name, which is
+passed to this function. Calling this function with no or a nil
+argument sends the image to the printer."
:type 'symbol
:group 'todo)
'face 'todo-prefix-string))
(num 0)
(fill-prefix (make-string todo-indent-to-here 32))
- (content (buffer-string))
- file)
+ (content (buffer-string)))
(with-current-buffer (get-buffer-create buf)
(insert content)
(goto-char (point-min))
(goto-char (point-min))
(insert header)
(newline 2)
- (if to-file
- (let ((file (read-file-name "Print to file: ")))
- (funcall todo-print-buffer-function file))
- (funcall todo-print-buffer-function)))
+ (funcall todo-print-buffer-function
+ (if to-file nil
+ (read-file-name "Print to file: "))))
(kill-buffer buf)))
(defun todo-print-buffer-to-file ()
(time (match-string 4))
dayname)
(replace-match "")
- (insert (mapconcat 'eval calendar-date-display-form "")
+ (insert (mapconcat #'eval calendar-date-display-form "")
(when time (concat " " time)))))
(defun todo-convert-legacy-files ()
(unless (save-excursion
(re-search-backward
(concat "^" (regexp-quote todo-category-beg)
- "\\(.*\\)$") nil t)
+ "\\(.*\\)$")
+ nil t)
(string= (match-string 1) cat))
;; Else move it to its category.
(setq item (buffer-substring-no-properties beg end))
(forward-line)
(if (re-search-forward
(concat "^" (regexp-quote todo-category-beg)
- "\\(.*\\)$") nil t)
+ "\\(.*\\)$")
+ nil t)
(progn (goto-char (match-beginning 0))
(newline)
(forward-line -1))
(setq todo-files (funcall todo-files-function))
(setq todo-archives (funcall todo-files-function t))
t)
- (let* ((files (append todo-files todo-archives))
- (tctf todo-current-todo-file)
- (tgctf todo-global-current-todo-file)
- (tdtf (todo-absolute-file-name todo-default-todo-file)))
+ (let* ((files (append todo-files todo-archives)))
(unless (or (not todo-current-todo-file)
(member todo-current-todo-file files))
(setq todo-current-todo-file nil))
"Return the number of category CAT in this todo file.
The buffer-local variable `todo-category-number' holds this
number as its value."
- (let ((categories (mapcar 'car todo-categories)))
+ (let ((categories (mapcar #'car todo-categories)))
(setq todo-category-number
;; Increment by one, so that the number of the first
;; category is one rather than zero.
(todo-prefix-overlays)
(goto-char (point-min))
(if (re-search-forward (concat "\n\\(" (regexp-quote todo-category-done)
- "\\)") nil t)
+ "\\)")
+ nil t)
(progn
(setq done-start (match-beginning 0))
(setq done-sep-start (match-beginning 1))
(when (eq major-mode 'todo-mode)
(let ((opoint (point)))
(re-search-backward (concat "^" (regexp-quote todo-category-beg)
- "\\(.*\\)\n") nil t)
+ "\\(.*\\)\n")
+ nil t)
(todo-category-number (match-string 1))
(todo-category-select)
(goto-char opoint))))))
(defvar todo-edit-item--prompt "Press a key (so far `e'): ")
(defun todo-edit-item--next-key (params &optional arg)
- (let* ((map (make-sparse-keymap))
- (p->k (mapconcat (lambda (elt)
+ (let* ((p->k (mapconcat (lambda (elt)
(format "%s=>%s"
(propertize (cdr elt) 'face
'todo-key-prompt)
todo-global-current-todo-file)
(todo-absolute-file-name todo-default-todo-file)))
(files (or (unless archive
- (mapcar 'todo-absolute-file-name
+ (mapcar #'todo-absolute-file-name
todo-category-completions-files))
(list curfile)))
listall listf)
;; If file was just added, it has no category completions.
(unless (zerop (buffer-size (find-buffer-visiting curfile)))
(unless (member curfile todo-archives)
- (add-to-list 'files curfile))
+ (cl-pushnew curfile files :test #'equal))
(dolist (f files listall)
(with-current-buffer (find-file-noselect f 'nowarn)
(if archive
MUSTMATCH the name of an existing file must be chosen;
otherwise, a new file name is allowed."
(let* ((completion-ignore-case todo-completion-ignore-case)
- (files (mapcar 'todo-short-file-name
+ (files (mapcar #'todo-short-file-name
;; (funcall todo-files-function archive)))
(if archive todo-archives todo-files)))
(file (completing-read prompt files nil mustmatch nil nil
(todo-read-file-name (concat "Choose a" (if archive
"n archive"
" todo")
- " file: ") archive t)))
+ " file: ")
+ archive t)))
(completions (unless file0 (todo-category-completions archive)))
(categories (cond (file0
(with-current-buffer
(if (atom catfil)
catfil
(todo-absolute-file-name
- (let ((files (mapcar 'todo-short-file-name catfil)))
+ (let ((files (mapcar #'todo-short-file-name catfil)))
(completing-read (format str cat) files)))))))
;; Default to the current file.
(unless file0 (setq file0 todo-current-todo-file))
"Prompt for new NAME for TYPE until it is valid, then return it.
TYPE can be either of the symbols `file' or `category'."
(let ((categories todo-categories)
- (files (mapcar 'todo-short-file-name todo-files))
+ (files (mapcar #'todo-short-file-name todo-files))
prompt)
(while
(and
(setq monthname (completing-read
"Month name (RET for current month, * for any month): "
mlist nil t nil nil
- (calendar-month-name (calendar-extract-month
- (calendar-current-date)) t))
+ (calendar-month-name
+ (calendar-extract-month (calendar-current-date)) t))
month (1+ (- (length mlist)
(length (or (member monthname mlist)
(member monthname mablist))))))
(if (memq 'month calendar-date-display-form)
month
monthname)))
- (mapconcat 'eval calendar-date-display-form ""))))
+ (mapconcat #'eval calendar-date-display-form ""))))
(defun todo-read-dayname ()
"Choose name of a day of the week with completion and return it."
"The :set function for user option `todo-show-current-file'."
(custom-set-default symbol value)
(if value
- (add-hook 'pre-command-hook 'todo-show-current-file nil t)
- (remove-hook 'pre-command-hook 'todo-show-current-file t)))
+ (add-hook 'pre-command-hook #'todo-show-current-file nil t)
+ (remove-hook 'pre-command-hook #'todo-show-current-file t)))
(defun todo-reset-prefix (symbol value)
"The :set function for `todo-prefix' and `todo-number-prefix'."
(defun todo-reevaluate-filelist-defcustoms ()
"Reevaluate defcustoms that provide choice list of todo files."
+ ;; FIXME: This is hideous! I don't know enough about Custom to
+ ;; offer something better, but please ask on emacs-devel!
(custom-set-default 'todo-default-todo-file
(symbol-value 'todo-default-todo-file))
(todo-reevaluate-default-file-defcustom)
Called after adding or deleting a todo file. If the value of
`todo-default-todo-file' before calling this function was
associated with an existing file, keep that value."
+ ;; FIXME: This is hideous! I don't know enough about Custom to
+ ;; offer something better, but please ask on emacs-devel!
;; (let ((curval todo-default-todo-file))
(eval
(defcustom todo-default-todo-file (todo-short-file-name
(car (funcall todo-files-function)))
"Todo file visited by first session invocation of `todo-show'."
:type (when todo-files
- `(radio ,@(mapcar (lambda (f) (list 'const f))
- (mapcar 'todo-short-file-name
- (funcall todo-files-function)))))
+ `(radio ,@(todo--files-type-list)))
:group 'todo))
;; (when (and curval (file-exists-p (todo-absolute-file-name curval)))
;; (custom-set-default 'todo-default-todo-file curval)
(defun todo-reevaluate-category-completions-files-defcustom ()
"Reevaluate defcustom of `todo-category-completions-files'.
Called after adding or deleting a todo file."
+ ;; FIXME: This is hideous! I don't know enough about Custom to
+ ;; offer something better, but please ask on emacs-devel!
(eval (defcustom todo-category-completions-files nil
"List of files for building `todo-read-category' completions."
- :type `(set ,@(mapcar (lambda (f) (list 'const f))
- (mapcar 'todo-short-file-name
- (funcall todo-files-function))))
+ :type `(set ,@(todo--files-type-list))
:group 'todo)))
(defun todo-reevaluate-filter-files-defcustom ()
"Reevaluate defcustom of `todo-filter-files'.
Called after adding or deleting a todo file."
+ ;; FIXME: This is hideous! I don't know enough about Custom to
+ ;; offer something better, but please ask on emacs-devel!
(eval (defcustom todo-filter-files nil
"List of files for multifile item filtering."
- :type `(set ,@(mapcar (lambda (f) (list 'const f))
- (mapcar 'todo-short-file-name
- (funcall todo-files-function))))
+ :type `(set ,@(todo--files-type-list))
:group 'todo)))
;; -----------------------------------------------------------------------------
(defun todo-diary-nonmarking-matcher (lim)
"Search for diary nonmarking symbol within LIM for font-locking."
(re-search-forward (concat "^\\(?1:" (regexp-quote diary-nonmarking-symbol)
- "\\)" todo-date-pattern) lim t))
+ "\\)" todo-date-pattern)
+ lim t))
(defun todo-date-string-matcher (lim)
"Search for todo item date string within LIM for font-locking."
(defun todo-time-string-matcher (lim)
"Search for todo item time string within LIM for font-locking."
(re-search-forward (concat todo-date-string-start todo-date-pattern
- " \\(?1:" diary-time-regexp "\\)") lim t))
+ " \\(?1:" diary-time-regexp "\\)")
+ lim t))
(defun todo-diary-expired-matcher (lim)
"Search for expired diary item date within LIM for font-locking."
(when (re-search-forward (concat "^\\(?:"
(regexp-quote diary-nonmarking-symbol)
"\\)?\\(?1:" todo-date-pattern "\\) \\(?2:"
- diary-time-regexp "\\)?") lim t)
+ diary-time-regexp "\\)?")
+ lim t)
(let* ((date (match-string-no-properties 1))
(time (match-string-no-properties 2))
;; Function days-between requires a non-empty time string.
(defvar todo-mode-map
(let ((map (make-keymap)))
- ;; Don't suppress digit keys, so they can supply prefix arguments.
- (suppress-keymap map)
(dolist (kb todo-key-bindings-t)
(define-key map (nth 0 kb) (nth 1 kb)))
(dolist (kb todo-key-bindings-t+a+f)
(defvar todo-archive-mode-map
(let ((map (make-sparse-keymap)))
- (suppress-keymap map)
(dolist (kb todo-key-bindings-t+a+f)
(define-key map (nth 0 kb) (nth 1 kb)))
(dolist (kb todo-key-bindings-t+a)
(defvar todo-categories-mode-map
(let ((map (make-sparse-keymap)))
- (suppress-keymap map)
(define-key map "c" 'todo-sort-categories-alphabetically-or-numerically)
(define-key map "t" 'todo-sort-categories-by-todo)
(define-key map "y" 'todo-sort-categories-by-diary)
(defvar todo-filtered-items-mode-map
(let ((map (make-sparse-keymap)))
- (suppress-keymap map)
(dolist (kb todo-key-bindings-t+a+f)
(define-key map (nth 0 kb) (nth 1 kb)))
(dolist (kb todo-key-bindings-t+f)
(defun todo-modes-set-1 ()
"Make some settings that apply to multiple Todo modes."
(setq-local font-lock-defaults '(todo-font-lock-keywords t))
- (setq-local revert-buffer-function 'todo-revert-buffer)
+ (setq-local revert-buffer-function #'todo-revert-buffer)
(setq-local tab-width todo-indent-to-here)
- (setq-local indent-line-function 'todo-indent)
+ (setq-local indent-line-function #'todo-indent)
(when todo-wrap-lines
(visual-line-mode)
(setq wrap-prefix (make-string todo-indent-to-here 32))))
(setq buffer-read-only t)
(setq-local todo--item-headers-hidden nil)
(setq-local desktop-save-buffer 'todo-desktop-save-buffer)
- (setq-local hl-line-range-function 'todo-hl-line-range))
+ (setq-local hl-line-range-function #'todo-hl-line-range))
(defun todo-modes-set-3 ()
"Make some settings that apply to multiple Todo modes."
(setq-local todo-categories (todo-set-categories))
(setq-local todo-category-number 1)
- ;; (add-hook 'find-file-hook 'todo-display-as-todo-file nil t)
+ ;; (add-hook 'find-file-hook #'todo-display-as-todo-file nil t)
)
(put 'todo-mode 'mode-class 'special)
(setq-local todo-current-todo-file (file-truename (buffer-file-name))))
(setq-local todo-show-done-only nil)
(setq-local todo-categories-with-marks nil)
- ;; (add-hook 'find-file-hook 'todo-add-to-buffer-list nil t)
- (add-hook 'post-command-hook 'todo-update-buffer-list nil t)
+ ;; (add-hook 'find-file-hook #'todo-add-to-buffer-list nil t)
+ (add-hook 'post-command-hook #'todo-update-buffer-list nil t)
(when todo-show-current-file
- (add-hook 'pre-command-hook 'todo-show-current-file nil t))
+ (add-hook 'pre-command-hook #'todo-show-current-file nil t))
(add-hook 'window-configuration-change-hook
- 'todo-reset-and-enable-done-separator nil t)
- (add-hook 'kill-buffer-hook 'todo-reset-global-current-todo-file nil t)))
+ #'todo-reset-and-enable-done-separator nil t)
+ (add-hook 'kill-buffer-hook #'todo-reset-global-current-todo-file nil t)))
(put 'todo-archive-mode 'mode-class 'special)