aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Berman2013-02-08 23:46:23 +0100
committerStephen Berman2013-02-08 23:46:23 +0100
commit65caf482fc63d8fe7b7e7d9fb376363bd4031a75 (patch)
tree4a10b611d0cd4f2eca86899b3f2166b982aaae9a
parent0ad8680abcd1007c2306e32bf729346cfb15440e (diff)
downloademacs-65caf482fc63d8fe7b7e7d9fb376363bd4031a75.tar.gz
emacs-65caf482fc63d8fe7b7e7d9fb376363bd4031a75.zip
* calendar/todos.el (todos-edit-multiline-item): Revert to using
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.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/calendar/todos.el52
2 files changed, 39 insertions, 21 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 5c4f707d81f..174c7fc4fa0 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12013-02-08 Stephen Berman <stephen.berman@gmx.net>
2
3 * calendar/todos.el (todos-edit-multiline-item): Revert to using
4 indirect buffer, which makes it easier to return to Todos mode.
5 (todos-edit-quit): Don't delete and reinsert items that don't need
6 indenting. Revert to just killing buffer on quitting single item
7 editing. On quitting file editing, select nearest category.
8
12013-02-07 Stephen Berman <stephen.berman@gmx.net> 92013-02-07 Stephen Berman <stephen.berman@gmx.net>
2 10
3 * calendar/todos.el: Bug fixes and improvements to item editing 11 * calendar/todos.el: Bug fixes and improvements to item editing
diff --git a/lisp/calendar/todos.el b/lisp/calendar/todos.el
index ef05521937f..b49b46fa64d 100644
--- a/lisp/calendar/todos.el
+++ b/lisp/calendar/todos.el
@@ -4867,12 +4867,14 @@ minibuffer; otherwise, edit it in Todos Edit mode."
4867Use of newlines invokes `todos-indent' to insure compliance with 4867Use of newlines invokes `todos-indent' to insure compliance with
4868the format of Diary entries." 4868the format of Diary entries."
4869 (interactive) 4869 (interactive)
4870 (narrow-to-region (todos-item-start) (todos-item-end)) 4870 (let ((buf todos-edit-buffer))
4871 (rename-buffer todos-edit-buffer) 4871 (set-window-buffer (selected-window)
4872 (todos-edit-mode) 4872 (set-buffer (make-indirect-buffer (buffer-name) buf)))
4873 (message "%s" (substitute-command-keys 4873 (narrow-to-region (todos-item-start) (todos-item-end))
4874 (concat "Type \\[todos-edit-quit] " 4874 (todos-edit-mode)
4875 "to return to Todos mode.\n")))) 4875 (message "%s" (substitute-command-keys
4876 (concat "Type \\[todos-edit-quit] "
4877 "to return to Todos mode.\n")))))
4876 4878
4877(defun todos-edit-multiline (&optional item) ;FIXME: not item editing command 4879(defun todos-edit-multiline (&optional item) ;FIXME: not item editing command
4878 "" ;FIXME 4880 "" ;FIXME
@@ -4896,7 +4898,17 @@ whether the file is still a valid Todos file and if so, also
4896recalculate the Todos categories sexp, in case changes were made 4898recalculate the Todos categories sexp, in case changes were made
4897in the number or names of categories." 4899in the number or names of categories."
4898 (interactive) 4900 (interactive)
4899 (if (eq (buffer-size) (- (point-max) (point-min))) 4901 (if (> (buffer-size) (- (point-max) (point-min)))
4902 (let ((item (buffer-string))
4903 (regex "\\(\n\\)[^[:blank:]]"))
4904 ;; Ensure lines following hard newlines are indented.
4905 (when (string-match regex (buffer-string))
4906 (replace-regexp-in-string
4907 regex (concat "\n" (make-string todos-indent-to-here 32))
4908 nil nil 1)
4909 (delete-region (point-min) (point-max))
4910 (insert item))
4911 (kill-buffer))
4900 (when (todos-check-format) 4912 (when (todos-check-format)
4901 ;; FIXME: separate out sexp check? 4913 ;; FIXME: separate out sexp check?
4902 ;; If manual editing makes e.g. item counts change, have to 4914 ;; If manual editing makes e.g. item counts change, have to
@@ -4906,20 +4918,18 @@ in the number or names of categories."
4906 ;; Compare (todos-make-categories-list t) with sexp and if 4918 ;; Compare (todos-make-categories-list t) with sexp and if
4907 ;; different ask (todos-update-categories-sexp) ? 4919 ;; different ask (todos-update-categories-sexp) ?
4908 (todos-mode) 4920 (todos-mode)
4909 (todos-category-select)) 4921 (let* ((cat-beg (concat "^" (regexp-quote todos-category-beg)
4910 ;; Ensure lines following hard newlines are indented. 4922 "\\(.*\\)$"))
4911 (let ((beg (save-excursion (todos-item-start))) 4923 (curline (buffer-substring-no-properties
4912 (item (replace-regexp-in-string 4924 (line-beginning-position) (line-end-position)))
4913 "\\(\n\\)[^[:blank:]]" 4925 (cat (cond ((string-match cat-beg curline)
4914 (concat "\n" (make-string todos-indent-to-here 32)) 4926 (match-string-no-properties 1 curline))
4915 (buffer-string) nil nil 1))) 4927 ((or (re-search-backward cat-beg nil t)
4916 (delete-region (point-min) (point-max)) 4928 (re-search-forward cat-beg nil t))
4917 (insert item) 4929 (match-string-no-properties 1)))))
4918 (todos-mode) 4930 (todos-category-number cat)
4919 (todos-category-select) 4931 (todos-category-select)
4920 (goto-char (point-min)) 4932 (recenter)))))
4921 (goto-char beg)
4922 (recenter))))
4923 4933
4924(defun todos-edit-item-header-1 (what &optional inc) 4934(defun todos-edit-item-header-1 (what &optional inc)
4925 "Function underlying commands to edit item date/time header. 4935 "Function underlying commands to edit item date/time header.