From: Stephen Berman Date: Wed, 22 May 2013 11:23:36 +0000 (+0200) Subject: * todos.el (todos-edit-quit): Don't allow dateless item. X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~2045 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6a6394e6708d9598d77a4b138ba171bc81902ce2;p=emacs.git * todos.el (todos-edit-quit): Don't allow dateless item. --- diff --git a/lisp/calendar/ChangeLog b/lisp/calendar/ChangeLog index 029066176af..54e6e633345 100644 --- a/lisp/calendar/ChangeLog +++ b/lisp/calendar/ChangeLog @@ -1,3 +1,7 @@ +2013-05-22 Stephen Berman + + * todos.el (todos-edit-quit): Don't allow dateless item. + 2013-05-21 Stephen Berman * todos.el (todos-key-bindings, todos-archive-mode-map) diff --git a/lisp/calendar/todos.el b/lisp/calendar/todos.el index 3f34aee9430..54847c92a2f 100644 --- a/lisp/calendar/todos.el +++ b/lisp/calendar/todos.el @@ -5031,35 +5031,41 @@ recalculate the Todos categories sexp, in case changes were made in the number or names of categories." (interactive) (if (> (buffer-size) (- (point-max) (point-min))) + ;; We got here via `e m'. (let ((item (buffer-string)) (regex "\\(\n\\)[^[:blank:]]")) + (while (not (string-match (concat todos-date-string-start + todos-date-pattern) item)) + (setq item (read-from-minibuffer + "Item must start with a date: " item))) ;; Ensure lines following hard newlines are indented. (when (string-match regex (buffer-string)) (setq item (replace-regexp-in-string regex "\n\t" item nil nil 1)) (delete-region (point-min) (point-max)) (insert item)) (kill-buffer)) - (when (todos-check-format) - ;; FIXME: separate out sexp check? - ;; If manual editing makes e.g. item counts change, have to - ;; call this to update todos-categories, but it restores - ;; category order to list order. - ;; (todos-repair-categories-sexp) - ;; Compare (todos-make-categories-list t) with sexp and if - ;; different ask (todos-update-categories-sexp) ? - (todos-mode) - (let* ((cat-beg (concat "^" (regexp-quote todos-category-beg) - "\\(.*\\)$")) - (curline (buffer-substring-no-properties - (line-beginning-position) (line-end-position))) - (cat (cond ((string-match cat-beg curline) - (match-string-no-properties 1 curline)) - ((or (re-search-backward cat-beg nil t) - (re-search-forward cat-beg nil t)) - (match-string-no-properties 1))))) - (todos-category-number cat) - (todos-category-select) - (goto-char (point-min)))))) + ;; We got here via `F e'. + (when (todos-check-format) + ;; FIXME: separate out sexp check? + ;; If manual editing makes e.g. item counts change, have to + ;; call this to update todos-categories, but it restores + ;; category order to list order. + ;; (todos-repair-categories-sexp) + ;; Compare (todos-make-categories-list t) with sexp and if + ;; different ask (todos-update-categories-sexp) ? + (todos-mode) + (let* ((cat-beg (concat "^" (regexp-quote todos-category-beg) + "\\(.*\\)$")) + (curline (buffer-substring-no-properties + (line-beginning-position) (line-end-position))) + (cat (cond ((string-match cat-beg curline) + (match-string-no-properties 1 curline)) + ((or (re-search-backward cat-beg nil t) + (re-search-forward cat-beg nil t)) + (match-string-no-properties 1))))) + (todos-category-number cat) + (todos-category-select) + (goto-char (point-min)))))) (defun todos-edit-item-header-1 (what &optional inc) "Function underlying commands to edit item date/time header.