Browse Source

Merge branch 'master-fixes' into master-new

Bastien Guerry 12 years ago
parent
commit
8a910bd40b
2 changed files with 33 additions and 35 deletions
  1. 22 14
      lisp/org-agenda.el
  2. 11 21
      lisp/org.el

+ 22 - 14
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)
@@ -6636,6 +6640,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 +6655,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 ""))
@@ -7165,10 +7170,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))))
@@ -9140,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)
@@ -9153,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
@@ -9172,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."

+ 11 - 21
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."