todo-filtered-items-mode))))
(if (funcall todo-files-function)
(todo-read-file-name "Choose a todo file to visit: "
- nil t)
+ nil t)
(user-error "There are no todo files")))
((and (eq major-mode 'todo-archive-mode)
;; Called noninteractively via todo-quit
(when (or (member file todo-visited)
(eq todo-show-first 'first))
(unless (todo-check-file file) (throw 'end nil))
- (set-window-buffer (selected-window)
+ ;; If todo-show is called from the minibuffer, don't visit
+ ;; the todo file there.
+ (set-window-buffer (if (minibufferp) (minibuffer-selected-window)
+ (selected-window))
(set-buffer (find-file-noselect file 'nowarn)))
(if (equal (file-name-extension (buffer-file-name)) "toda")
(unless (derived-mode-p 'todo-archive-mode) (todo-archive-mode))
(setq todo-category-number (todo-category-number cat)))
;; If this is a new todo file, add its first category.
(when (zerop (buffer-size))
+ ;; Don't confuse an erased buffer with a fresh buffer for
+ ;; adding a new todo file -- it might have been erased by
+ ;; mistake or due to a bug (e.g. Bug#20832).
+ (when (buffer-modified-p)
+ (error "Buffer is empty but modified, please report a bug"))
(let (cat-added)
(unwind-protect
(setq todo-category-number
;; separator.
(when (looking-back (concat "^"
(regexp-quote todo-category-done)
- "\n"))
+ "\n")
+ (line-beginning-position 0))
(todo-backward-item))))
(todo-insert-with-overlays item)
;; If item was marked, restore the mark.
(if (and (eobp)
(looking-back
(concat (regexp-quote todo-done-string)
- "\n")))
+ "\n")
+ (line-beginning-position 0)))
(delete-region (point) (progn
(forward-line -2)
(point))))))
;; If the item ends with a non-comment parenthesis not
;; followed by a period, we lose (but we inherit that
;; problem from the legacy code).
- (when (looking-back "(\\(.*\\)) ")
+ (when (looking-back "(\\(.*\\)) " (line-beginning-position))
(setq comment (match-string 1))
(replace-match "")
(insert "[" todo-comment-string ": " comment "]"))
(looking-at todo-done-string-start)
(looking-back (concat "^"
(regexp-quote todo-category-done)
- "\n")))
+ "\n")
+ (line-beginning-position 0)))
(setq num 1
done t))
(setq prefix (concat (propertize
The list consists of item insertion parameters that can be passed
as insertion command arguments in fixed positions. If a position
in the list is not occupied by the corresponding parameter, it is
-occupied by `nil'."
+occupied by nil."
(let* ((arg (list (car todo-insert-item--args)))
(args (nconc (cdr todo-insert-item--args)
(list (car (todo-insert-item--argsleft