From c64c5992212fd7acc11d3922b2a0bd5cd44fbf08 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Tue, 19 Feb 2013 09:48:11 +0100 Subject: [PATCH 1/4] org-agenda.el (org-agenda-format-item): Only set the breadcrumbs when `org-prefix-has-breadcrumbs' is non-nil * org-agenda.el (org-agenda-format-item): Only set the breadcrumbs when `org-prefix-has-breadcrumbs' is non-nil. --- lisp/org-agenda.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 86b6e0958..9371d301c 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -6636,6 +6636,10 @@ Any match of REMOVE-RE will be removed from TXT." (add-text-properties 0 (length txt) '(org-heading t) txt) ;; Prepare the variables needed in the eval of the compiled format + (if org-prefix-has-breadcrumbs + (setq breadcrumbs (org-with-point-at (org-get-at-bol 'org-marker) + (let ((s (org-display-outline-path nil nil "->" t))) + (if (eq "" s) "" (concat s "->")))))) (setq time (cond (s2 (concat (org-agenda-time-of-day-to-ampm-maybe s1) "-" (org-agenda-time-of-day-to-ampm-maybe s2) @@ -6647,9 +6651,6 @@ Any match of REMOVE-RE will be removed from TXT." "......"))) (t "")) extra (or (and (not habitp) extra) "") - breadcrumbs (org-with-point-at (org-get-at-bol 'org-marker) - (let ((s (org-display-outline-path nil nil "->" t))) - (if (eq "" s) "" (concat s "->")))) category (if (symbolp category) (symbol-name category) category) thecategory (copy-sequence category) level (or level "")) From efb2ce9c12feee122e61e153e65503a43b5138bf Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Tue, 19 Feb 2013 10:02:34 +0100 Subject: [PATCH 2/4] org.el: Fix `org-next-link' and use it for `org-previous-link' * org.el (org-next-link): New parameter `search-backward'. Fix bug when at a link with no 'org-link face, e.g., in a DONE headline. Throw a message instead of an error. (org-previous-link): Use `org-next-link'. --- lisp/org.el | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 5569c7e16..c80a16927 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -9870,45 +9870,35 @@ If it decides that it is not responsible for this link, it must return nil to indicate that that Org-mode can continue with other options like exact and fuzzy text search.") -(defun org-next-link () +(defun org-next-link (&optional search-backward) "Move forward to the next link. If the link is in hidden text, expose it." - (interactive) + (interactive "P") (when (and org-link-search-failed (eq this-command last-command)) (goto-char (point-min)) (message "Link search wrapped back to beginning of buffer")) (setq org-link-search-failed nil) (let* ((pos (point)) (ct (org-context)) - (a (assoc :link ct))) - (if a (goto-char (nth 2 a))) - (if (re-search-forward org-any-link-re nil t) + (a (assoc :link ct)) + (srch-fun (if search-backward 're-search-backward 're-search-forward))) + (cond (a (goto-char (nth (if search-backward 1 2) a))) + ((looking-at org-any-link-re) + ;; Don't stay stuck at link without an org-link face + (forward-char (if search-backward -1 1)))) + (if (funcall srch-fun org-any-link-re nil t) (progn (goto-char (match-beginning 0)) (if (outline-invisible-p) (org-show-context))) (goto-char pos) (setq org-link-search-failed t) - (error "No further link found")))) + (message "No further link found")))) (defun org-previous-link () "Move backward to the previous link. If the link is in hidden text, expose it." (interactive) - (when (and org-link-search-failed (eq this-command last-command)) - (goto-char (point-max)) - (message "Link search wrapped back to end of buffer")) - (setq org-link-search-failed nil) - (let* ((pos (point)) - (ct (org-context)) - (a (assoc :link ct))) - (if a (goto-char (nth 1 a))) - (if (re-search-backward org-any-link-re nil t) - (progn - (goto-char (match-beginning 0)) - (if (outline-invisible-p) (org-show-context))) - (goto-char pos) - (setq org-link-search-failed t) - (error "No further link found")))) + (funcall 'org-next-link t)) (defun org-translate-link (s) "Translate a link string if a translation function has been defined." From 66cba1c51f0d0c71f1bc2698d764401347646233 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Tue, 19 Feb 2013 10:33:07 +0100 Subject: [PATCH 3/4] org-agenda.el (org-agenda-set-restriction-lock): Fix restriction * org-agenda.el (org-agenda-set-restriction-lock): Fix restriction so that it ends at the beginning of the next headline at the same level. --- lisp/org-agenda.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 9371d301c..003008237 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -7166,10 +7166,10 @@ in the file. Otherwise, restriction will be to the current subtree." (list (buffer-file-name (buffer-base-buffer)))) (org-back-to-heading t) (move-overlay org-agenda-restriction-lock-overlay - (point) (save-excursion (org-end-of-subtree t) (point))) + (point) (save-excursion (org-end-of-subtree t t) (point))) (move-marker org-agenda-restrict-begin (point)) (move-marker org-agenda-restrict-end - (save-excursion (org-end-of-subtree t))) + (save-excursion (org-end-of-subtree t t))) (message "Locking agenda restriction to subtree")) (put 'org-agenda-files 'org-restrict (list (buffer-file-name (buffer-base-buffer)))) From 9bec2ec5d017caaf493d9f6c6757b32ce33c83d0 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Tue, 19 Feb 2013 11:04:26 +0100 Subject: [PATCH 4/4] org-agenda.el: Small bug fixes * org-agenda.el (org-agenda-unmark-clocking-task): New function. (org-agenda-mark-clocking-task): Use it. (org-agenda-clock-in): Let the cursor where it is. (org-agenda-clock-out): Ditto. Also remove the `org-agenda-clocking' overlay. --- lisp/org-agenda.el | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 003008237..b0514ff95 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -3765,10 +3765,7 @@ generating a new one." (defun org-agenda-mark-clocking-task () "Mark the current clock entry in the agenda if it is present." - (mapc (lambda (o) - (if (eq (overlay-get o 'type) 'org-agenda-clocking) - (delete-overlay o))) - (overlays-in (point-min) (point-max))) + (org-agenda-unmark-clocking-task) (when (marker-buffer org-clock-hd-marker) (save-excursion (goto-char (point-min)) @@ -3783,6 +3780,13 @@ generating a new one." (overlay-put ov 'help-echo "The clock is running in this item"))))))) +(defun org-agenda-unmark-clocking-task () + "Unmark the current clocking task." + (mapc (lambda (o) + (if (eq (overlay-get o 'type) 'org-agenda-clocking) + (delete-overlay o))) + (overlays-in (point-min) (point-max)))) + (defun org-agenda-fontify-priorities () "Make highest priority lines bold, and lowest italic." (interactive) @@ -9141,9 +9145,9 @@ ARG is passed through to `org-deadline'." (org-clock-in arg) (let* ((marker (or (org-get-at-bol 'org-marker) (org-agenda-error))) - (hdmarker (or (org-get-at-bol 'org-hd-marker) - marker)) + (hdmarker (or (org-get-at-bol 'org-hd-marker) marker)) (pos (marker-position marker)) + (col (current-column)) newhead) (org-with-remote-undo (marker-buffer marker) (with-current-buffer (marker-buffer marker) @@ -9154,14 +9158,15 @@ ARG is passed through to `org-deadline'." (org-cycle-hide-drawers 'children) (org-clock-in arg) (setq newhead (org-get-heading))) - (org-agenda-change-all-lines newhead hdmarker))))) + (org-agenda-change-all-lines newhead hdmarker)) + (org-move-to-column col)))) (defun org-agenda-clock-out () "Stop the currently running clock." (interactive) (unless (marker-buffer org-clock-marker) (error "No running clock")) - (let ((marker (make-marker)) newhead) + (let ((marker (make-marker)) (col (current-column)) newhead) (org-with-remote-undo (marker-buffer org-clock-marker) (with-current-buffer (marker-buffer org-clock-marker) (save-excursion @@ -9173,7 +9178,9 @@ ARG is passed through to `org-deadline'." (org-clock-out) (setq newhead (org-get-heading)))))) (org-agenda-change-all-lines newhead marker) - (move-marker marker nil))) + (move-marker marker nil) + (org-move-to-column col) + (org-agenda-unmark-clocking-task))) (defun org-agenda-clock-cancel (&optional arg) "Cancel the currently running clock."