Function: todo-find-item
todo-find-item is a byte-compiled function defined in todo-mode.el.gz.
Signature
(todo-find-item STR)
Documentation
Search for filtered item STR in its saved todo file.
Return the list (FOUND FILE CAT), where CAT and FILE are the
item's category and file, and FOUND is a cons cell if the search
succeeds, whose car is the start of the item in FILE and whose
cdr is done, if the item is now a done item, changed, if its
text was truncated or augmented or, for a top priority item, if
its priority has changed, and same otherwise.
Source Code
;; Defined in /usr/src/emacs/lisp/calendar/todo-mode.el.gz
(defun todo-find-item (str)
"Search for filtered item STR in its saved todo file.
Return the list (FOUND FILE CAT), where CAT and FILE are the
item's category and file, and FOUND is a cons cell if the search
succeeds, whose car is the start of the item in FILE and whose
cdr is `done', if the item is now a done item, `changed', if its
text was truncated or augmented or, for a top priority item, if
its priority has changed, and `same' otherwise."
(string-match (concat (if todo-filter-done-items
(concat "\\(?:" todo-done-string-start "\\|"
todo-date-string-start "\\)")
todo-date-string-start)
todo-date-pattern "\\(?: " diary-time-regexp "\\)?"
(if todo-filter-done-items
"\\]"
(regexp-quote todo-nondiary-end)) "?"
"\\(?4: \\[\\(?3:(archive) \\)?\\(?2:.*:\\)?"
"\\(?1:.*\\)\\]\\).*$")
str)
(let ((cat (match-string 1 str))
(file (match-string 2 str))
(archive (string= (match-string 3 str) "(archive) "))
(filcat (match-string 4 str))
(tpriority 1)
(tpbuf (save-match-data (string-match "top" (buffer-name))))
found)
(setq str (replace-match "" nil nil str 4))
(when tpbuf
;; Calculate priority of STR wrt its category.
(save-excursion
(while (search-backward filcat nil t)
(setq tpriority (1+ tpriority)))))
(setq file (if file
(concat todo-directory (substring file 0 -1)
(if archive ".toda" ".todo"))
(if archive
(concat (file-name-sans-extension
todo-global-current-todo-file) ".toda")
todo-global-current-todo-file)))
(find-file-noselect file)
(with-current-buffer (find-buffer-visiting file)
(if archive
(unless (derived-mode-p 'todo-archive-mode) (todo-archive-mode))
(unless (derived-mode-p 'todo-mode) (todo-mode)))
(save-restriction
(widen)
(goto-char (point-min))
(let ((beg (re-search-forward
(concat "^" (regexp-quote (concat todo-category-beg cat))
"$")
nil t))
(done (save-excursion
(re-search-forward
(concat "^" (regexp-quote todo-category-done)) nil t)))
(end (save-excursion
(or (re-search-forward
(concat "^" (regexp-quote todo-category-beg))
nil t)
(point-max)))))
(setq found (when (search-forward str end t)
(goto-char (match-beginning 0))))
(when found
(setq found
(cons found (if (> (point) done)
'done
(let ((cpriority 1))
(when tpbuf
(save-excursion
;; Not top item in category.
(while (> (point) (1+ beg))
(let ((opoint (point)))
(todo-backward-item)
;; Can't move backward beyond
;; first item in file.
(unless (= (point) opoint)
(setq cpriority (1+ cpriority)))))))
(if (and (= tpriority cpriority)
;; Proper substring is not the same.
(string= (todo-item-string)
str))
'same
'changed)))))))))
(list found file cat)))