[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 6d24402: Fix last todo-edit-mode change
From: |
Stephen Berman |
Subject: |
[Emacs-diffs] master 6d24402: Fix last todo-edit-mode change |
Date: |
Tue, 14 Aug 2018 18:14:50 -0400 (EDT) |
branch: master
commit 6d24402d6358b2e6ccf78a6cb909723a5d18dd27
Author: Stephen Berman <address@hidden>
Commit: Stephen Berman <address@hidden>
Fix last todo-edit-mode change
* lisp/calendar/todo-mode.el (todo-edit-mode): For editing an item
instead of the whole file, the current todo-file must be set from
todo-global-current-todo-file.
* test/lisp/calendar/todo-mode-tests.el
(todo-test-current-file-in-edit-mode):
New test.
---
lisp/calendar/todo-mode.el | 10 +++++++---
test/lisp/calendar/todo-mode-tests.el | 23 +++++++++++++++++++++++
2 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el
index 1623c6e..08da75d 100644
--- a/lisp/calendar/todo-mode.el
+++ b/lisp/calendar/todo-mode.el
@@ -6726,9 +6726,13 @@ Added to `window-configuration-change-hook' in Todo
mode."
\\{todo-edit-mode-map}"
(todo-modes-set-1)
- (setq-local todo-current-todo-file (file-truename (buffer-file-name)))
- (when (= (buffer-size) (- (point-max) (point-min)))
- ;; Only need this when editing the whole file not just an item.
+ (if (> (buffer-size) (- (point-max) (point-min)))
+ ;; Editing one item in an indirect buffer, so buffer-file-name is nil.
+ (setq-local todo-current-todo-file todo-global-current-todo-file)
+ ;; When editing archive file, make sure it is current todo file.
+ (setq-local todo-current-todo-file (file-truename (buffer-file-name)))
+ ;; Need this when editing the whole file to return to the category
+ ;; editing was invoked from.
(setq-local todo-categories (todo-set-categories)))
(setq buffer-read-only nil))
diff --git a/test/lisp/calendar/todo-mode-tests.el
b/test/lisp/calendar/todo-mode-tests.el
index 9028204..6cd2bfe 100644
--- a/test/lisp/calendar/todo-mode-tests.el
+++ b/test/lisp/calendar/todo-mode-tests.el
@@ -763,6 +763,29 @@ The highlighting should remain enabled."
(ert-simulate-command '(forward-line)) ; Now on first done item.
(should (eq 'hl-line (get-char-property (point) 'face)))))
+(ert-deftest todo-test-current-file-in-edit-mode ()
+ "Test the value of todo-current-todo-file in todo-edit-mode."
+ (with-todo-test
+ (todo-test--show 1)
+ ;; The preceding call todo-mode but does not run pre-command-hook
+ ;; in the test environment, thus failing to set
+ ;; todo-global-current-todo-file, which is needed for the test
+ ;; after todo-edit-item--text. So force the hook function to run.
+ (ert-simulate-command '(todo-mode))
+ (let ((curfile todo-current-todo-file))
+ (should (equal curfile todo-test-file-1))
+ (todo-edit-item--text 'multiline)
+ (should (equal todo-current-todo-file curfile))
+ (todo-edit-quit)
+ (todo-edit-file)
+ (should (equal todo-current-todo-file curfile))
+ (todo-edit-quit))
+ (todo-find-archive)
+ (let ((curfile todo-current-todo-file))
+ (should (equal curfile todo-test-archive-1))
+ (todo-edit-file)
+ (should (equal todo-current-todo-file curfile)))))
+
(ert-deftest todo-test-edit-quit ()
"Test result of exiting todo-edit-mode on a whole file.
Exiting should return to the same todo-mode or todo-archive-mode
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 6d24402: Fix last todo-edit-mode change,
Stephen Berman <=