diff options
| author | Stephen Berman | 2013-12-20 18:16:47 +0100 |
|---|---|---|
| committer | Stephen Berman | 2013-12-20 18:16:47 +0100 |
| commit | 2f99433b944d602c382bfa87c8e3e27b1eaaed3b (patch) | |
| tree | 4105847b84e1507c726ed93b0d41e3371c889b07 | |
| parent | 3cbfb9354082c9e3466156d81da3dfe9d7d9f99f (diff) | |
| download | emacs-2f99433b944d602c382bfa87c8e3e27b1eaaed3b.tar.gz emacs-2f99433b944d602c382bfa87c8e3e27b1eaaed3b.zip | |
Todo mode bug fixes and new features.
* calendar/todo-mode.el: Bug fixes and new features.
(todo-toggle-item-highlighting): Use eval-and-compile instead of
eval-when-compile.
(todo-move-category): Allow choosing a non-existing todo file to
move the category to, and create that file.
(todo-default-priority): New user option.
(todo-set-item-priority): Use it.
(todo-desktop-save-buffer, todo-restore-desktop-buffer): New functions.
(desktop-restore-file-buffer): Declare.
(desktop-buffer-mode-handlers): Add todo-restore-desktop-buffer.
(todo-modes-set-2): Locally set desktop-save-buffer to
todo-desktop-save-buffer.
(todo-mode, todo-archive-mode, todo-filtered-items-mode)
(auto-mode-alist): Add autoload cookie.
Fixes: debbugs:15225
| -rw-r--r-- | lisp/ChangeLog | 17 | ||||
| -rw-r--r-- | lisp/calendar/todo-mode.el | 54 |
2 files changed, 64 insertions, 7 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b3315ca8c56..e367749fb39 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,20 @@ | |||
| 1 | 2013-12-20 Stephen Berman <stephen.berman@gmx.net> | ||
| 2 | |||
| 3 | * calendar/todo-mode.el: Bug fixes and new features (bug#15225). | ||
| 4 | (todo-toggle-item-highlighting): Use eval-and-compile instead of | ||
| 5 | eval-when-compile. | ||
| 6 | (todo-move-category): Allow choosing a non-existing todo file to | ||
| 7 | move the category to, and create that file. | ||
| 8 | (todo-default-priority): New user option. | ||
| 9 | (todo-set-item-priority): Use it. | ||
| 10 | (todo-desktop-save-buffer, todo-restore-desktop-buffer): New functions. | ||
| 11 | (desktop-restore-file-buffer): Declare. | ||
| 12 | (desktop-buffer-mode-handlers): Add todo-restore-desktop-buffer. | ||
| 13 | (todo-modes-set-2): Locally set desktop-save-buffer to | ||
| 14 | todo-desktop-save-buffer. | ||
| 15 | (todo-mode, todo-archive-mode, todo-filtered-items-mode) | ||
| 16 | (auto-mode-alist): Add autoload cookie. | ||
| 17 | |||
| 1 | 2013-12-20 Bozhidar Batsov <bozhidar@batsov.com> | 18 | 2013-12-20 Bozhidar Batsov <bozhidar@batsov.com> |
| 2 | 19 | ||
| 3 | * emacs-lisp/subr-x.el: Renamed from helpers.el. | 20 | * emacs-lisp/subr-x.el: Renamed from helpers.el. |
diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el index 943aa8b34b5..3dcb305f05a 100644 --- a/lisp/calendar/todo-mode.el +++ b/lisp/calendar/todo-mode.el | |||
| @@ -1040,7 +1040,7 @@ empty line above the done items separator." | |||
| 1040 | (defun todo-toggle-item-highlighting () | 1040 | (defun todo-toggle-item-highlighting () |
| 1041 | "Highlight or unhighlight the todo item the cursor is on." | 1041 | "Highlight or unhighlight the todo item the cursor is on." |
| 1042 | (interactive) | 1042 | (interactive) |
| 1043 | (eval-when-compile (require 'hl-line)) | 1043 | (eval-and-compile (require 'hl-line)) |
| 1044 | (when (memq major-mode | 1044 | (when (memq major-mode |
| 1045 | '(todo-mode todo-archive-mode todo-filtered-items-mode)) | 1045 | '(todo-mode todo-archive-mode todo-filtered-items-mode)) |
| 1046 | (if hl-line-mode | 1046 | (if hl-line-mode |
| @@ -1360,8 +1360,9 @@ todo or done items." | |||
| 1360 | 1360 | ||
| 1361 | (defun todo-move-category () | 1361 | (defun todo-move-category () |
| 1362 | "Move current category to a different todo file. | 1362 | "Move current category to a different todo file. |
| 1363 | If current category has archived items, also move those to the | 1363 | If the todo file chosen does not exist, it is created. |
| 1364 | archive of the file moved to, creating it if it does not exist." | 1364 | If the current category has archived items, also move those to |
| 1365 | the archive of the file moved to, creating it if it does not exist." | ||
| 1365 | (interactive) | 1366 | (interactive) |
| 1366 | (when (or (> (length todo-categories) 1) | 1367 | (when (or (> (length todo-categories) 1) |
| 1367 | (todo-y-or-n-p (concat "This is the only category in this file; " | 1368 | (todo-y-or-n-p (concat "This is the only category in this file; " |
| @@ -1370,15 +1371,22 @@ archive of the file moved to, creating it if it does not exist." | |||
| 1370 | (let* ((ofile todo-current-todo-file) | 1371 | (let* ((ofile todo-current-todo-file) |
| 1371 | (cat (todo-current-category)) | 1372 | (cat (todo-current-category)) |
| 1372 | (nfile (todo-read-file-name | 1373 | (nfile (todo-read-file-name |
| 1373 | "Choose a todo file to move this category to: " nil t)) | 1374 | "Todo file to move this category to: " nil)) |
| 1374 | (archive (concat (file-name-sans-extension ofile) ".toda")) | 1375 | (archive (concat (file-name-sans-extension ofile) ".toda")) |
| 1375 | (buffers (append (list ofile) | 1376 | (buffers (append (list ofile) |
| 1376 | (unless (zerop (todo-get-count 'archived cat)) | 1377 | (unless (zerop (todo-get-count 'archived cat)) |
| 1377 | (list archive)))) | 1378 | (list archive)))) |
| 1378 | new) | 1379 | new) |
| 1379 | (while (equal (file-truename nfile) (file-truename ofile)) | 1380 | (while (equal nfile (file-truename ofile)) |
| 1380 | (setq nfile (todo-read-file-name | 1381 | (setq nfile (todo-read-file-name |
| 1381 | "Choose a file distinct from this file: " nil t))) | 1382 | "Choose a file distinct from this file: " nil))) |
| 1383 | (unless (member nfile todo-files) | ||
| 1384 | (with-current-buffer (get-buffer-create nfile) | ||
| 1385 | (erase-buffer) | ||
| 1386 | (write-region (point-min) (point-max) nfile nil 'nomessage nil t) | ||
| 1387 | (kill-buffer nfile)) | ||
| 1388 | (setq todo-files (funcall todo-files-function)) | ||
| 1389 | (todo-reevaluate-filelist-defcustoms)) | ||
| 1382 | (dolist (buf buffers) | 1390 | (dolist (buf buffers) |
| 1383 | (with-current-buffer (find-file-noselect buf) | 1391 | (with-current-buffer (find-file-noselect buf) |
| 1384 | (widen) | 1392 | (widen) |
| @@ -1633,6 +1641,12 @@ current time, if nil, they include it." | |||
| 1633 | :type 'boolean | 1641 | :type 'boolean |
| 1634 | :group 'todo-edit) | 1642 | :group 'todo-edit) |
| 1635 | 1643 | ||
| 1644 | (defcustom todo-default-priority 'first | ||
| 1645 | "Default priority of new and moved items." | ||
| 1646 | :type '(choice (const :tag "Highest priority" first) | ||
| 1647 | (const :tag "Lowest priority" last)) | ||
| 1648 | :group 'todo-edit) | ||
| 1649 | |||
| 1636 | (defcustom todo-item-mark "*" | 1650 | (defcustom todo-item-mark "*" |
| 1637 | "String used to mark items. | 1651 | "String used to mark items. |
| 1638 | To ensure item marking works, change the value of this option | 1652 | To ensure item marking works, change the value of this option |
| @@ -2617,7 +2631,9 @@ meaning to raise or lower the item's priority by one." | |||
| 2617 | ;; todo item. | 2631 | ;; todo item. |
| 2618 | (when (> maxnum 1) | 2632 | (when (> maxnum 1) |
| 2619 | (while (not priority) | 2633 | (while (not priority) |
| 2620 | (setq candidate (read-number prompt)) | 2634 | (setq candidate (read-number prompt |
| 2635 | (if (eq todo-default-priority 'first) | ||
| 2636 | 1 maxnum))) | ||
| 2621 | (setq prompt (when (or (< candidate 1) (> candidate maxnum)) | 2637 | (setq prompt (when (or (< candidate 1) (> candidate maxnum)) |
| 2622 | (format "Priority must be an integer between 1 and %d.\n" | 2638 | (format "Priority must be an integer between 1 and %d.\n" |
| 2623 | maxnum))) | 2639 | maxnum))) |
| @@ -5263,6 +5279,22 @@ Overrides `diary-goto-entry'." | |||
| 5263 | 5279 | ||
| 5264 | (add-function :override diary-goto-entry-function #'todo-diary-goto-entry) | 5280 | (add-function :override diary-goto-entry-function #'todo-diary-goto-entry) |
| 5265 | 5281 | ||
| 5282 | (defun todo-desktop-save-buffer (_dir) | ||
| 5283 | `((catnum . ,(todo-category-number (todo-current-category))))) | ||
| 5284 | |||
| 5285 | (declare-function desktop-restore-file-buffer "desktop" | ||
| 5286 | (buffer-filename buffer-name buffer-misc)) | ||
| 5287 | |||
| 5288 | (defun todo-restore-desktop-buffer (file buffer misc) | ||
| 5289 | (desktop-restore-file-buffer file buffer misc) | ||
| 5290 | (with-current-buffer buffer | ||
| 5291 | (widen) | ||
| 5292 | (let ((todo-category-number (cdr (assq 'catnum misc)))) | ||
| 5293 | (todo-category-select)))) | ||
| 5294 | |||
| 5295 | (add-to-list 'desktop-buffer-mode-handlers | ||
| 5296 | '(todo-mode . todo-restore-desktop-buffer)) | ||
| 5297 | |||
| 5266 | (defun todo-done-item-p () | 5298 | (defun todo-done-item-p () |
| 5267 | "Return non-nil if item at point is a done item." | 5299 | "Return non-nil if item at point is a done item." |
| 5268 | (save-excursion | 5300 | (save-excursion |
| @@ -6480,6 +6512,8 @@ Added to `window-configuration-change-hook' in Todo mode." | |||
| 6480 | "Make some settings that apply to multiple Todo modes." | 6512 | "Make some settings that apply to multiple Todo modes." |
| 6481 | (add-to-invisibility-spec 'todo) | 6513 | (add-to-invisibility-spec 'todo) |
| 6482 | (setq buffer-read-only t) | 6514 | (setq buffer-read-only t) |
| 6515 | (when (and (boundp 'desktop-save-mode) desktop-save-mode) | ||
| 6516 | (setq-local desktop-save-buffer 'todo-desktop-save-buffer)) | ||
| 6483 | (when (boundp 'hl-line-range-function) | 6517 | (when (boundp 'hl-line-range-function) |
| 6484 | (setq-local hl-line-range-function | 6518 | (setq-local hl-line-range-function |
| 6485 | (lambda() (save-excursion | 6519 | (lambda() (save-excursion |
| @@ -6495,6 +6529,7 @@ Added to `window-configuration-change-hook' in Todo mode." | |||
| 6495 | 6529 | ||
| 6496 | (put 'todo-mode 'mode-class 'special) | 6530 | (put 'todo-mode 'mode-class 'special) |
| 6497 | 6531 | ||
| 6532 | ;;;###autoload | ||
| 6498 | (define-derived-mode todo-mode special-mode "Todo" | 6533 | (define-derived-mode todo-mode special-mode "Todo" |
| 6499 | "Major mode for displaying, navigating and editing todo lists. | 6534 | "Major mode for displaying, navigating and editing todo lists. |
| 6500 | 6535 | ||
| @@ -6521,6 +6556,7 @@ Added to `window-configuration-change-hook' in Todo mode." | |||
| 6521 | 6556 | ||
| 6522 | ;; If todo-mode is parent, all todo-mode key bindings appear to be | 6557 | ;; If todo-mode is parent, all todo-mode key bindings appear to be |
| 6523 | ;; available in todo-archive-mode (e.g. shown by C-h m). | 6558 | ;; available in todo-archive-mode (e.g. shown by C-h m). |
| 6559 | ;;;###autoload | ||
| 6524 | (define-derived-mode todo-archive-mode special-mode "Todo-Arch" | 6560 | (define-derived-mode todo-archive-mode special-mode "Todo-Arch" |
| 6525 | "Major mode for archived todo categories. | 6561 | "Major mode for archived todo categories. |
| 6526 | 6562 | ||
| @@ -6569,6 +6605,7 @@ Added to `window-configuration-change-hook' in Todo mode." | |||
| 6569 | 6605 | ||
| 6570 | (put 'todo-filtered-items-mode 'mode-class 'special) | 6606 | (put 'todo-filtered-items-mode 'mode-class 'special) |
| 6571 | 6607 | ||
| 6608 | ;;;###autoload | ||
| 6572 | (define-derived-mode todo-filtered-items-mode special-mode "Todo-Fltr" | 6609 | (define-derived-mode todo-filtered-items-mode special-mode "Todo-Fltr" |
| 6573 | "Mode for displaying and reprioritizing top priority Todo. | 6610 | "Mode for displaying and reprioritizing top priority Todo. |
| 6574 | 6611 | ||
| @@ -6576,8 +6613,11 @@ Added to `window-configuration-change-hook' in Todo mode." | |||
| 6576 | (todo-modes-set-1) | 6613 | (todo-modes-set-1) |
| 6577 | (todo-modes-set-2)) | 6614 | (todo-modes-set-2)) |
| 6578 | 6615 | ||
| 6616 | ;;;###autoload | ||
| 6579 | (add-to-list 'auto-mode-alist '("\\.todo\\'" . todo-mode)) | 6617 | (add-to-list 'auto-mode-alist '("\\.todo\\'" . todo-mode)) |
| 6618 | ;;;###autoload | ||
| 6580 | (add-to-list 'auto-mode-alist '("\\.toda\\'" . todo-archive-mode)) | 6619 | (add-to-list 'auto-mode-alist '("\\.toda\\'" . todo-archive-mode)) |
| 6620 | ;;;###autoload | ||
| 6581 | (add-to-list 'auto-mode-alist '("\\.tod[tyr]\\'" . todo-filtered-items-mode)) | 6621 | (add-to-list 'auto-mode-alist '("\\.tod[tyr]\\'" . todo-filtered-items-mode)) |
| 6582 | 6622 | ||
| 6583 | ;; ----------------------------------------------------------------------------- | 6623 | ;; ----------------------------------------------------------------------------- |