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.
This commit is contained in:
parent
5620d591ee
commit
6d24402d63
2 changed files with 30 additions and 3 deletions
|
|
@ -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))
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue