Browse Source

org-agenda.el (org-agenda-goto-date): Put the cursor on the agenda line with the selected date

* org-agenda.el (org-agenda-goto-date): Put the cursor on the
agenda line with the selected date.
Bastien Guerry 4 years ago
parent
commit
c25566fec3
1 changed files with 8 additions and 3 deletions
  1. 8 3
      lisp/org-agenda.el

+ 8 - 3
lisp/org-agenda.el

@@ -7723,6 +7723,7 @@ Negative selection means regexp must not match for selection of an entry."
   (let* ((org-read-date-prefer-future
 	  (eval org-agenda-jump-prefer-future))
 	 (date (org-read-date))
+	 (day (time-to-days (org-time-string-to-time date)))
 	 (org-agenda-sticky-orig org-agenda-sticky)
 	 (org-agenda-buffer-tmp-name (buffer-name))
 	 (args (get-text-property (min (1- (point-max)) (point)) 'org-last-args))
@@ -7734,12 +7735,16 @@ Negative selection means regexp must not match for selection of an entry."
 	 (inhibit-read-only t)
 	 org-agenda-sticky)
     (if (not (org-agenda-check-type t 'agenda))
-	(error "Not available in non-agenda blocks")
+	(error "Not available in non-agenda views")
       (add-text-properties (point-min) (point-max)
 			   `(org-redo-cmd ,newcmd org-last-args ,newargs))
       (org-agenda-redo)
-    (setq org-agenda-sticky org-agenda-sticky-orig
-	  org-agenda-this-buffer-is-sticky org-agenda-sticky))))
+      (goto-char (point-min))
+      (while (not (or (= (or (get-text-property (point) 'day) 0) day)
+		      (save-excursion (move-beginning-of-line 2) (eobp))))
+	(move-beginning-of-line 2))
+      (setq org-agenda-sticky org-agenda-sticky-orig
+	    org-agenda-this-buffer-is-sticky org-agenda-sticky))))
 
 (defun org-agenda-goto-today ()
   "Go to today."