From e5259962f61c398d84d43d33c29a6f021c9b326a Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Mon, 20 Jan 2014 22:34:18 +0100 Subject: [PATCH] org-agenda.el: Fix buglets * org-agenda.el (org-agenda-next-item) (org-agenda-previous-item, org-agenda-toggle-archive-tag) (org-agenda-todo, org-agenda-priority, org-agenda-clock-in) (org-agenda-clock-out): Put the cursor back on the correct column, when possible. (org-agenda-todo): When `org-clock-out-when-done' is `t', also remove the current clock overlay. --- lisp/org-agenda.el | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index d885b4bc1..a14c5e7e9 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -8273,7 +8273,7 @@ When called with a prefix argument, include all archive files as well." (when (next-single-property-change (point-at-eol) 'org-marker) (move-end-of-line 1) (goto-char (next-single-property-change (point) 'org-marker)))) - (org-move-to-column col)) + (org-move-to-column col nil nil t)) (org-agenda-do-context-action)) (defun org-agenda-previous-item (n) @@ -8285,7 +8285,7 @@ When called with a prefix argument, include all archive files as well." (move-end-of-line 0) (previous-single-property-change (point) 'org-marker)))) (if goto (goto-char goto)) - (org-move-to-column col))) + (org-move-to-column col nil nil t))) (org-agenda-do-context-action)) (defun org-agenda-do-context-action () @@ -8770,6 +8770,7 @@ the same tree node, and the headline of the tree node in the Org-mode file." (with-current-buffer buffer (widen) (goto-char pos) + (setq col (current-column)) (org-show-context 'agenda) (save-excursion (and (outline-next-heading) @@ -8791,7 +8792,11 @@ the same tree node, and the headline of the tree node in the Org-mode file." (beginning-of-line 1) (save-excursion (org-agenda-change-all-lines newhead hdmarker 'fixface just-one)) - (org-move-to-column col)))) + (when (org-bound-and-true-p org-clock-out-when-done) + (string-match (concat "^" (regexp-opt org-done-keywords-for-agenda)) + newhead) + (org-agenda-unmark-clocking-task)) + (org-move-to-column col nil nil t)))) (defun org-agenda-add-note (&optional arg) "Add a time-stamped note to the entry at point." @@ -8927,7 +8932,8 @@ Called with a universal prefix arg, show the priority instead of setting it." (unless org-enable-priority-commands (error "Priority commands are disabled")) (org-agenda-check-no-diary) - (let* ((marker (or (org-get-at-bol 'org-marker) + (let* ((col (current-column)) + (marker (or (org-get-at-bol 'org-marker) (org-agenda-error))) (hdmarker (org-get-at-bol 'org-hd-marker)) (buffer (marker-buffer hdmarker)) @@ -8946,7 +8952,7 @@ Called with a universal prefix arg, show the priority instead of setting it." (end-of-line 1) (setq newhead (org-get-heading))) (org-agenda-change-all-lines newhead hdmarker) - (beginning-of-line 1))))) + (org-move-to-column col nil nil t))))) ;; FIXME: should fix the tags property of the agenda line. (defun org-agenda-set-tags (&optional tag onoff) @@ -9257,7 +9263,7 @@ ARG is passed through to `org-deadline'." (org-clock-in arg) (setq newhead (org-get-heading))) (org-agenda-change-all-lines newhead hdmarker)) - (org-move-to-column col)))) + (org-move-to-column col nil nil t)))) (defun org-agenda-clock-out () "Stop the currently running clock." @@ -9277,7 +9283,7 @@ ARG is passed through to `org-deadline'." (setq newhead (org-get-heading)))))) (org-agenda-change-all-lines newhead marker) (move-marker marker nil) - (org-move-to-column col) + (org-move-to-column col nil nil t) (org-agenda-unmark-clocking-task))) (defun org-agenda-clock-cancel (&optional arg) -- 2.11.4.GIT