uses, change numerous key bindings, make some basic commands
noninteractive and use them to define the commands, unify
archiving commands.
(todos-directory): Rename from todos-files-directory.
(todos-print-buffer-function): Rename from todos-print-function.
(todos-number-prefix): Rename from todos-number-priorities.
(todos-top-priorities-overrides): Rename from todos-priorities-rules.
(todos-top-priorities): Rename from todos-show-priorities.
(todos-insertion-command-name, todos-insertion-key-bindings):
Use "todos-insert-item-".
(todos-key-bindings, todos-archive-mode-map)
(todos-categories-mode-map, todos-filtered-items-mode-map):
Adjust to renamed commands, make bindings more systematic,
reorder entries.
(todos-show-categories-table): Rename from todos-display-categories.
(todos-sort-categories-alphabetically-or-by-priority): Rename from
todos-display-categories-alphabetically-or-by-priority.
(todos-sort-categories-by-todo): Rename from
todos-display-categories-sorted-by-todo.
(todos-sort-categories-by-diary): Rename from
todos-display-categories-sorted-by-diary.
(todos-sort-categories-by-done): Rename from
todos-display-categories-sorted-by-done.
(todos-sort-categories-by-archived): Rename from
todos-display-categories-sorted-by-archived.
(todos-print-buffer): Rename function from todos-print.
(todos-print-buffer-to-file): Rename from todos-print-to-file.
(todos-go-to-source-item): Rename from todos-jump-to-item.
(todos-forward-item, todos-backward-item): Remove interactive form
and move most of doc string and prefix argument error checking to...
(todos-next-item, todos-previous-item): ...these new commands,
which use the preceding functions.
(todos-next-button): Rename from todos-forward-button.
(todos-previous-button): Rename from todos-backward-button.
(todos-toggle-prefix-numbers): Rename from
todos-hide-show-item-numbering.
(todos-toggle-view-done-items): Rename from todos-hide-show-done-items.
(todos-toggle-view-done-only): Rename from todos-show-done-only.
(todos-toggle-item-highlighting): Rename from todos-highlight-item.
(todos-toggle-item-header): Rename from todos-hide-show-date-time.
(todos-toggle-mark-item): Rename from todos-mark-unmark-item.
(todos-filter-top-priorities): Rename from todos-top-priorities.
(todos-filter-top-priorities-multifile): Rename from
todos-top-priorities-multifile.
(todos-filter-diary-items): Rename from todos-diary-items.
(todos-filter-diary-items-multifile): Rename from
todos-diary-items-multifile.
(todos-filter-regexp-items): Rename from todos-regexp-items.
(todos-filter-regexp-items-multifile): Rename from
todos-regexp-items-multifile.
(todos-insert-item-1): Remove interactive form, since
todos-insert-item is generated like other item insertion commands.
(todos-edit-file): Rename from todos-edit-multiline.
(todos-item-undone): Rename from todos-item-undo.
(todos-archive-done-item): Add raw prefix spec to interactive form
and use it to test for archiving all done items in category;
reorder tests in function body accordingly.
(todos-archive-category-done-items): Remove.
(todos-category-completions): On ensuring proper category display,
if done items in category are visible, keep them visible.
(todos-set-item-priority): Keep top of category in view while
setting priority.
(todos-move-item): Restore prevention of moving within the same
category. Move done items to top, not end, of done items section.
When user quits before setting priority, make sure to return to
starting file.
(todos-item-undo): Partly reimplement along lines of
todos-move-item, adding highlighting of single item as undo
target, setting priority of multiple undone items, improving
handling of quitting before setting priority.
(todos-unarchive-items): Restore items to top, not end, of
category's done section.
saved files of filtered items.
(todos-show-first): Add choices for diary and regexp items.
(todos-absolute-file-name): Handle file names for diary and regexp
items.
(todos-filter-items): New function abstracted from item filtering
commands, with handling of saved files of diary and regexp items.
(todos-filter-items-1): Rename from todos-filter-items.
(todos-filtered-buffer-name): Remove, since functionality is now
incorporated into new function todos-filter-items.
(todos-filtered-items-buffer, todos-top-priorities-buffer)
(todos-diary-items-buffer, todos-regexp-items-buffer):
Make defconsts instead of defcustoms.
(todos-find-item): Restrict calculation and comparison of
priorities to top priority items, in order to handle diary and
regexp items.
(todos-check-filtered-items-file): Rename from
todos-check-top-priorities and adjust message and callers.
(todos-filter-items-filename): Rename from
todos-top-priorities-filename, adjusting caller and extending to
files of filtered diary and regexp items.
(todos-save-filtered-items-buffer): Rename from
todos-save-top-priorities-buffer and adjust caller and uses. Use
write-file instead of write-region and use existing file name if
previously saved.
(todos-show): Handle initially displaying saved file of filtered
diary or regexp items.
(todos-top-priorities, todos-top-priorities-multifile)
(todos-diary-items, todos-diary-items-multifile)
(todos-regexp-items, todos-regexp-items-multifile): Use new
function todos-filter-items.
(auto-mode-alist): Extend regexp for files assigned to
todos-filtered-items-mode to handle saved diary and regexp items.
(todos-archive-mode-map): Add bindings for item and category
marking/unmarking; make todos-display-categories binding same as
in Todos mode; remove todos-unarchive-category binding.
(todos-unarchive-category): Remove.
(todos-unarchive-items): Fix handling of marked items. Remove
code for unarchiving whole category, since that is covered by
unarchiving marked items. Handle unarchiving items to a category
that had been deleted from the todo file by re-adding the
category. Use todos-category-select to display restored items,
not todos-show. Remove obsolete or superfluous code.
since it's superfluous and also wrongly removes items marks.
(todos-category-completions): Select current category on visiting
file, to ensure category is properly displayed if user switches to
file via a non-Todos command.
(todos-mark-category): Make implementation cleaner.
(todos-unmark-category): Improve implementation. Get overlay
property only when there is an overlay.
sure calling insertion "here" from outside goal todo items section
gives new item top priority. With priority insertion, if user
cancels before setting priority, restore display.
(todos-find-item): Restore narrowing after searching.
(todos-item-done): Allow adding (same) comment to marked items.
Don't add empty comment to done item.
todos-filtered-items-mode makes todos-mode current, don't call
todos-show, which (here wrongly) prompts for a new Todos file.
(todos-delete-category): Fix incorrect quotation mark.
(todos-set-item-priority): Make prefix argument a no-op with
commands for raising or lowering item priority. Move mistakenly
place right paren to end of defun, where it belongs.
(todos-insert-item): Maybe set the insertion file to
todos-global-current-todos-file. When inserting into a file that
was not being visited on invoking this command, ensure chosen
category is properly selected. Make item inserted "here" the
first todo item if the command was invoked with point in done
items section or outside of the current category.
(todos-item-done): When done items are shown, put cursor on first
just done item.
(todos-item-undo): Put cursor on undone item.
(todos-get-overlay): New function.
(todos-prefix-overlay): Remove, since subsumed by
todos-get-overlay, and replace by the latter in callers.
(todos-reset-prefix): Apply only to buffer visiting Todos files.
Simplify implementation and use `todos' overlay property.
(todos-reset-done-separator): Use todos-get-overlay and `todos'
overlay property. Fix logic.
(todos-category-select): Use todos-get-overlay and `todos' overlay
property.
(todos-remove-item): Use todos-get-overlay. Correct obsolete code.
(todos-prefix-overlays): Use todos-top-priority face also for
non-numerical prefix of top priority items. Add `todos' overlay
property.
(todos-hide-show-date-time): Simplify, using todos-get-overlay and
`todos' overlay property.
indirect buffer, which makes it easier to return to Todos mode.
(todos-edit-quit): Don't delete and reinsert items that don't need
indenting. Revert to just killing buffer on quitting single item
editing. On quitting file editing, select nearest category.
and insertion.
(todos-check-format): Compare current value of todos-categories
with actual categories sexp.
(todos-repair-categories-sexp): Add warning to doc string about
category order getting restored to list element order.
(todos-mode-external-set): When todos-categories is nil, as in
Todos Edit mode, set it by reading actual categories sexp.
(todos-edit-mode): Make buffer writeable.
(todos-done-item-section-p): New function.
(todos-insert-item): Use it as part of preventing insertion here
in done items section. Move check for display of done items only
to just before setting new item's priority, and if cancelled after
toggling to todo items, restore display of done items.
(todos-edit-multiline-item): Don't base on todos-edit-multiline
but just narrow and change mode.
(todos-edit-multiline): Don't make indirect buffer but just widen
and change mode; also remove overlays.
(todos-edit-quit): Restore Todos mode and category display; when
quitting multiline item editing, ensure items above edited item
are visible in window if possible.
(todos-done-item-add-edit-or-delete-comment): If user moved point
during editing, make sure it moves back to edited item before
returning.
Complete the implementation.
(todos-hide-show-done-items): If start of done items sections is
below the bottom of the window, make it visible.
(todos-insert-item): Allow inserting item here to work outside of
the current category, but then at top of category. After checking
whether only done items are shown, restore point to ensure
inserting item here works correctly.
(todos-set-item-priority): Delete leftover right paren at end.
(todos-done-separator): Make length of long separator one less
than window-width, in order to avoid following empty line.
(todos-forward-item, todos-backward-item): Make empty line below
last todo item accessible only by invoking without a numerical
prefix argument and make the latter invocations move only to items.
(todos-insert-item): Set todos-current-todos-file after selecting
buffer, in order not to set global value. If only done items are
shown when this command is invoked, toggle to show todo items to
avoid insertion into done items section. When done items are
shown, protect from cancelling before setting item priority: this
also needs recentering to display all items.
(todos-set-item-priority): Only call on (not done) todo items.
Check that done items are visible not because file is widened.
Use only `any' argument of called-interactively-p. Make sure that
giving an undone item lowest priority restores it to the todo
section.
(todos-item-done): If done items are visible on invoking this
command, keep them visible afterwards. Stop looking for marked
items on reaching the empty line below the last todo item.
(todos-done-separator-string): Change default value.
(todos-update-categories-sexp): Remove unnecessary and misquided
setq of todos-default-todos-file. Use delete-region instead of
kill-region to avoid polluting kill-ring.
(todos-unload-hook): Remove (was not used).
(todos-edit-multiline): Don't generate new edit buffer name on
each invocation---that can cause confusion due to indirect buffer.
(todos-edit-quit): Ensure lines in edit buffer that follow hard
newlines are indented in the file to conform to diary format.
(todos-set-item-priority): If done items in category are visible,
keep them visible.
FIXME comments.
(todos-reset-and-enable-done-separator): Remove commented out
workaround for done separator overlay bug; fix doc string.
(todos-reset-done-separator): Delete old overlay after adding new
overlay to fix done separator overlay bug; improve implementation.
(todos-prefix-overlays): Improve first line of doc string.
(todos-prefix): Add validator to ensure value differs from that of
todos-item-mark.
(todos-item-mark): New defcustom.
(todos-prefix-overlay): New function.
(todos-marked-item-p): Use it. Adapt implementation to new
handling of marked items.
(todos-insert-with-overlays): When inserting pushes down a marked
item, move its prefix overlay.
(todos-prefix-overlays): Add overlay even when prefix is empty string,
otherwise item marking fails. Improve handling of marked items.
(todos-mark-unmark-item): Adapt to new handling of marked items
and simplify by removing marking of all items in category.
(todos-mark-category): Adapt to new handling of marked items and
don't use todos-mark-unmark-item.
(todos-unmark-category): Adapt to new handling of marked items.
(todos-delete-item): Remove obsolete handling of marked items and
useless restoration of point.
(todos-set-item-priority): Use new handling of marked items.
(todos-move-item, todos-item-done, todos-item-undo)
(todos-archive-done-item): Remove obsolete handling of marked items.
(todos-top-priority): Use current definition of font-lock-constant-face.
(todos-diary-expired): Make default value contrast more with
default value of todos-date face.
(todos-nondiary, todos-category-string): New faces.
(todos-nondiary-face, todos-category-string-face): Corresponding
new variables.
(todos-done, todos-comment): Switch default values to go better
with default value of todos-date face.
(todos-done-sep): Change default value.
(todos-category-string-matcher-1)
(todos-category-string-matcher-2): Improve doc string.
(todos-font-lock-keywords): Use todos-nondiary-face and
todos-category-string-face.
(todos-done-separator): Propertize string with todos-done-sep face.
(todos-filtered-items-mode): Fix typo.
(todos-find-item): Find done items and items whose priority has
changed or whose text was truncated or augmented; add doc string.
(todos-check-top-priorities): Highlight each item that is not up
to date.
(todos-jump-to-item): Jump to items whose priority has changed or
whose text was truncated or augmented.
to top priorities file.
(todos-display-categories-first): Remove, replacing by this:
(todos-show-first): New defcustom.
(todos-first-visit): Remove, replacing by this:
(todos-visited): New variable.
(todos-absolute-file-name): Extend possible values of optional
argument to take top priorities files into account.
(todos-modes-set-3, todos-mode): Remove use of todos-first-visit.
(todos-mode-external-set): Call find-file-noselect instead of
find-buffer-visiting, since the latter may fail.
(todos-show): Revise handling of initial display using
todos-show-first and todos-visited and extend to top priorities
file.
(todos-quit): Adapt to new handling of initial display.
improve implementation of item filtering commands and
infrastucture, and fix two bugs.
(todos-prefix-overlays): Use todos-top-priority face only in Todos
mode.
(todos-multiple-filter-files): Get file-truename of Todos file.
(todos-filter-items): Pass a list of files from the caller instead
of building it here, and move handling of cancelled file selection
dialog to callers. Correct omission of file-wide default number
of top priorities.
(todos-filtered-buffer-name): Treat file-list argument only as a list.
(todos-find-item, todos-check-top-priorities)
(todos-top-priorities-filename)
(todos-save-top-priorities-buffer): New functions.
(todos-save): Use todos-save-top-priorities-buffer.
(todos-jump-to-item): Refactor and use todos-find-item.
(todos-top-priorities): Simplify semantics of prefix argument.
Check if top priorities file exists and if so, visit it, reporting
whether it is up to date. Add optional argument and use it to
handle multiple files.
(todos-diary-items, todos-regexp-items): Add optional argument and
use it to handle multiple files.
(todos-top-priorities-multifile, todos-diary-items-multifile)
(todos-regexp-items-multifile): Refactor, using corresponding
non-multifile command.
(auto-mode-alist): Add pattern for top priorities files to visit
these in Todos Filtered Items mode.
priority items in category in a distinctive face.
(todos-prefix-string): Make doc string more precise.
(todos-top-priority): New defface.
(todos-done, todos-done-sep): Use more compact face definition
\(taken from font-lock.el).
(todos-comment): Give a complete face definition, instead of
inheriting from todos-done.
(todos-font-lock-keywords): Use todos-comment-face for
todos-comment-string-matcher.
(todos-prefix-overlays): Use todos-top-priority as the face
property of top priority items; don't condition reapplying item
prefix overlay on whether the string changed, since that prevents
updating display after changing number of top priorities.
(todos-set-top-priorities): Call todos-prefix-overlays to update
display.
(todos-default-todos-file): Change default value to correct custom
type.
(todos-category-completions-files): New defcustom.
(todos-reevaluate-category-completions-files-defcustom)
(todos-absolute-file-name, todos-category-completions): New defuns.
(todos-reevaluate-filelist-defcustoms):
Add todos-category-completions-files and
todos-reevaluate-category-completions-files-defcustom.
(todos-allcats-file, todos-all-categories-alist)
(todos-jump-to-category-other-file, todos-jump-to-any-category)
(todos-move-item-to-file): Remove (todos-all-categories-alist both
as defvar and as defun).
(todos-read-category): Rewrite using extended category completions
and better handling of completion against existing or non-existing
categories.
(todos-validate-name): Correct doc string; use local instead of
dynamic variables in function body.
(todos-insert-category-line): Adjust use of todos-jump-to-category
to new argument list.
(todos-key-bindings, todos-menu): Delete entries for removed
commands.
(todos-show): Get absolute name of todos-default-todos-file;
add `nowarn' argument to find-file-noselect; adjust use of
todos-add-category to new argument list.
(todos-jump-to-category): Rewrite using extended category
completions; reverse argument list, adapting FILE argument to new
completion mechanism; add autoload cookie; call todos-show if
there are no Todos files.
(todos-add-category): Rewrite using extended category completions;
add FILE argument to accommodate new completion mechanism.
(todos-merge-category): Adapt to extended category completions,
adding prefix argument.
(todos-insert-item): Adapt to extended category completions; use
todos-read-category instead of todos-jump-to-category in prefix
argument calls; call todos-show if there are no Todos files; if
item is inserted at end of category, recenter to ensure the items
above it are displayed in the window.
(todos-move-item): Adapt to extended category completions, making
argument prefix argument; allow moving within category (for the
sake of code simplification); add `nowarn' argument to
find-file-noselect.
(todos-archive-done-item): Prevent error when attempting to
archive not-done todo item; adjust use of todos-add-category to
new argument list.
especially of date/time header.
(todos-month-name-array, todos-month-abbrev-array): New defconsts.
(todos-date-pattern): Use explicitly numbered groups.
(todos-read-date): Optionally read and return just one of the date
string components year, month or monthname, day.
(todos-key-bindings): Add bindings for new item header editing
commands.
(todos-edit-item): Exclude date/time header from minibuffer by
default; include it by passing a prefix argument.
(todos-edit-item-header-1): New function containing the guts of
the commands for editing item date/time headers.
(todos-edit-item-header): Use it. Condition editing of time
string on value of `todos-always-add-time-string'.
(todos-edit-item-date-from-calendar): Use todos-edit-item-header-1.
(todos-edit-item-date-to-today): Rename from
todos-edit-item-date-is-today and use todos-edit-item-header-1.
(todos-edit-item-date): Remove.
(todos-edit-item-date-day-name, todos-edit-item-date-year)
(todos-edit-item-date-month, todos-edit-item-date-day): New commands.
* calendar/todos.el (todos-make-categories-list)
(todos-convert-legacy-files, todos-jump-to-item)
(todos-move-category, todos-merge-category)
(todos-archive-done-item, todos-unarchive-items): Include end of
line in regex searches for beginning of category, in order not to
get a category whose name contains the searched for category name.
completing movement, restore display of initial category; If item
is moved to end of target category, make sure the items above it
are displayed in the window.
subroutines.
(todos-move-item): When there are marked items, point need not be
on an item; remove obsolete use of todos-add-category, since this
is now already done in todos-read-category; fix typo.
(todos-diary-item-p): Exclude empty lines.
(todos-read-category): Restore point and narrowing after adding
new category, to avoid moving to beginning of file when moving
marked items to a new category.
(todos-set-item-priority): Prompt for priority only when the
category has at least one todo item; only use non-nil priority to
calculate insertion location.
(todos-read-category): Don't reset todos-categories when a new
category is added due to todos-move-item or todos-jump-to-item.
(todos-item-undo): Use it.
(todos-allcats-file, todos-all-categories-alist): New variables.
(todos-all-categories-alist): New function.
(todos-jump-to-any-category): New command.
(todos-move-item): Remove mark overlays from buffer items were
moved from; update todos-categories-with-marks,
revised comments.
(todos-reevaluate-filelist-defcustoms): Rename from
todos-reevaluate-defcustoms and adjust callers.
(todos-date-pattern, todos-nondiary-start, todos-nondiary-end)
(todos-date-string-start, todos-done-string-start)
(todos-item-start): Change from defvar to defconst.
(todos-set-top-priorities): Use read-number and simplify.
(todos-insert-item): Check whether date-type argument is a string.
(todos-set-date-from-calendar): Check whether
todos-date-from-calendar is a string; simplify cond clause.
(todos-archive-done-item, todos-unarchive-items):
Use buffer-substring-no-properties.
cancelling; use buffer-substring-no-properties; comment out code
removing mark overlay; fix insertion of undone items; display any
remaining done items.
further comment revision.
(todos-mode-display): New defgroup.
(todos-prefix, todos-number-priorities)
(todos-done-separator-string, todos-done-string)
(todos-comment-string, todos-show-with-done)
(todos-mode-line-function, todos-skip-archived-categories)
(todos-highlight-item, todos-wrap-lines)
(todos-line-wrapping-function): Use it.
(todos-item-insertion): New defgroup.
(todos-include-in-diary, todos-diary-nonmarking)
(todos-nondiary-marker, todos-always-add-time-string)
(todos-use-only-highlighted-region): Use it.
(todos-forward-button, todos-backward-button): New commands.
(todos-categories-mode-map): Use them, replacing forward-button
and backward-button.
(todos-merge-category): Fix and improve implementation; handle
archived items.
(todos-insert-item, todos-set-date-from-calendar): Handle setting
date by calling todos-insert-item-from-calendar.
(todos-delete-item): Fix overlay handling.
(todos-move-item): Highlight item to be moved.
(todos-item-undo): Handle marked items.
(todos-insert-item-from-calendar): Rewrite using
todos-date-from-calendar.
(todos-sorted-column): Change default value, also taking tty into
account.
(todos-reset-done-separator): Fix faulty variable binding.
(todos-reset-and-enable-done-separator): Save match data; comment
out code that causes problems for Edebug.
(todos-item-start): Handle empty line between todo and done items
when done items are hidden.
(todos-read-date): Use a leap year for `*' to allow
calendar-last-day-of-month to return Feb. 29.
(todos-archive-mode, todos-edit-mode, todos-categories-mode)
(todos-filtered-items-mode): Delete faulty parentheses.
(todos-quit): Save Todos and archive files unconditionally.
(todos-forward-item): Accept only positive prefix argument.
(todos-backward-item): Accept only positive prefix argument; don't
move point to beginning of buffer if it is on the first item.
(todos-hide-show-date-time): Remove obsolete interactive spec.
(todos-move-category): Improve prompt string; ensure file moved to
is different from file moved from.
(todos-merge-categories): Remove.
(todos-set-category-priority): New command.
(todos-raise-category-priority, todos-lower-category-priority):
Use it to define these commands.
(todos-set-item-priority): Rewrite and generalize.
(todos-raise-item-priority, todos-lower-item-priority): Use it to
define these commands.
(todos-reset-and-enable-done-separator): New functions.
(todos-reset-done-separator-string): Rewrite using
todos-reset-done-separator for string longer than 1 character.
(todos-mode): Add todos-reset-and-enable-done-separator to
window-configuration-change-hook, replacing previous anonymous
function.
(todos-unload-hook): And remove it.