Browse Source

org-agenda.el: Make sure to get a property from (1- (point-max)), not (point-max))

* org-agenda.el (org-agenda-manipulate-query)
(org-agenda-goto-date, org-agenda-goto-today)
(org-agenda-find-same-or-today-or-agenda, )
(org-agenda-later, org-agenda-change-time-span)
(org-agenda-change-all-lines)
(org-agenda-execute-calendar-command)
(org-agenda-goto-calendar, org-agenda-convert-date): Make sure
to get a property from (1- (point-max)), not (point-max)).

Thanks to Juan Pechiar for reporting a related problem.
Bastien Guerry 13 years ago
parent
commit
d43f7eb475
1 changed files with 15 additions and 15 deletions
  1. 15 15
      lisp/org-agenda.el

+ 15 - 15
lisp/org-agenda.el

@@ -6967,7 +6967,8 @@ Negative selection means regexp must not match for selection of an entry."
        " "))
        " "))
     (setq org-agenda-redo-command
     (setq org-agenda-redo-command
 	  (list 'org-search-view
 	  (list 'org-search-view
-		(car (get-text-property (point) 'org-last-args))
+		(car (get-text-property (min (1- (point-max)) (point))
+					'org-last-args))
 		org-agenda-query-string
 		org-agenda-query-string
 		(+ (length org-agenda-query-string)
 		(+ (length org-agenda-query-string)
 		   (if (member char '(?\{ ?\})) 0 1))))
 		   (if (member char '(?\{ ?\})) 0 1))))
@@ -6989,7 +6990,7 @@ Negative selection means regexp must not match for selection of an entry."
 	 (date (org-read-date))
 	 (date (org-read-date))
 	 (org-agenda-sticky-orig org-agenda-sticky)
 	 (org-agenda-sticky-orig org-agenda-sticky)
 	 (org-agenda-buffer-tmp-name (buffer-name))
 	 (org-agenda-buffer-tmp-name (buffer-name))
-	 (args (get-text-property (point) 'org-last-args))
+	 (args (get-text-property (min (1- (point-max)) (point)) 'org-last-args))
 	 (0-arg (or current-prefix-arg (car args)))
 	 (0-arg (or current-prefix-arg (car args)))
 	 (2-arg (nth 2 args))
 	 (2-arg (nth 2 args))
 	 (newcmd (list 'org-agenda-list 0-arg date
 	 (newcmd (list 'org-agenda-list 0-arg date
@@ -7009,7 +7010,7 @@ Negative selection means regexp must not match for selection of an entry."
   "Go to today."
   "Go to today."
   (interactive)
   (interactive)
   (org-agenda-check-type t 'timeline 'agenda)
   (org-agenda-check-type t 'timeline 'agenda)
-  (let* ((args (get-text-property (point) 'org-last-args))
+  (let* ((args (get-text-property (min (1- (point-max)) (point)) 'org-last-args))
 	 (curspan (nth 2 args))
 	 (curspan (nth 2 args))
 	 (tdpos (text-property-any (point-min) (point-max) 'org-today t)))
 	 (tdpos (text-property-any (point-min) (point-max) 'org-today t)))
     (cond
     (cond
@@ -7028,7 +7029,7 @@ Negative selection means regexp must not match for selection of an entry."
    (or (and cnt (text-property-any (point-min) (point-max) 'org-day-cnt cnt))
    (or (and cnt (text-property-any (point-min) (point-max) 'org-day-cnt cnt))
        (text-property-any (point-min) (point-max) 'org-today t)
        (text-property-any (point-min) (point-max) 'org-today t)
        (text-property-any (point-min) (point-max) 'org-agenda-type 'agenda)
        (text-property-any (point-min) (point-max) 'org-agenda-type 'agenda)
-       (and (get-text-property (point) 'org-serie)
+       (and (get-text-property (min (1- (point-max)) (point)) 'org-serie)
 	    (org-agenda-goto-block-beginning))
 	    (org-agenda-goto-block-beginning))
        (point-min))))
        (point-min))))
 
 
@@ -7056,7 +7057,7 @@ Negative selection means regexp must not match for selection of an entry."
 With prefix ARG, go forward that many times the current span."
 With prefix ARG, go forward that many times the current span."
   (interactive "p")
   (interactive "p")
   (org-agenda-check-type t 'agenda)
   (org-agenda-check-type t 'agenda)
-  (let* ((args (get-text-property (point) 'org-last-args))
+  (let* ((args (get-text-property (min (1- (point-max)) (point)) 'org-last-args))
 	 (span (or (nth 2 args) org-agenda-current-span))
 	 (span (or (nth 2 args) org-agenda-current-span))
 	 (sd (or (nth 1 args) (org-get-at-bol 'day) org-starting-day))
 	 (sd (or (nth 1 args) (org-get-at-bol 'day) org-starting-day))
 	 (greg (calendar-gregorian-from-absolute sd))
 	 (greg (calendar-gregorian-from-absolute sd))
@@ -7083,7 +7084,7 @@ With prefix ARG, go forward that many times the current span."
 	   ;; `cmd' may have been set by `org-agenda-run-series' which
 	   ;; `cmd' may have been set by `org-agenda-run-series' which
 	   ;; uses `org-agenda-overriding-cmd' to decide whether
 	   ;; uses `org-agenda-overriding-cmd' to decide whether
 	   ;; overriding is allowed for `cmd'
 	   ;; overriding is allowed for `cmd'
-	   (get-text-property (point) 'org-serie-cmd))
+	   (get-text-property (min (1- (point-max)) (point)) 'org-serie-cmd))
 	  (org-agenda-overriding-arguments
 	  (org-agenda-overriding-arguments
 	   (list (car args) sd span)))
 	   (list (car args) sd span)))
       (org-agenda-redo)
       (org-agenda-redo)
@@ -7167,7 +7168,7 @@ written as 2-digit years."
   "Change the agenda view to SPAN.
   "Change the agenda view to SPAN.
 SPAN may be `day', `week', `month', `year'."
 SPAN may be `day', `week', `month', `year'."
   (org-agenda-check-type t 'agenda)
   (org-agenda-check-type t 'agenda)
-  (let* ((args (get-text-property (point) 'org-last-args))
+  (let* ((args (get-text-property (min (1- (point-max)) (point)) 'org-last-args))
 	 (curspan (nth 2 args)))
 	 (curspan (nth 2 args)))
     (if (and (not n) (equal curspan span))
     (if (and (not n) (equal curspan span))
 	(error "Viewing span is already \"%s\"" span))
 	(error "Viewing span is already \"%s\"" span))
@@ -7176,7 +7177,7 @@ SPAN may be `day', `week', `month', `year'."
 		   org-starting-day))
 		   org-starting-day))
 	   (sd (org-agenda-compute-starting-span sd span n))
 	   (sd (org-agenda-compute-starting-span sd span n))
 	   (org-agenda-overriding-cmd
 	   (org-agenda-overriding-cmd
-	    (get-text-property (point) 'org-serie-cmd))
+	    (get-text-property (min (1- (point-max)) (point)) 'org-serie-cmd))
 	   (org-agenda-overriding-arguments
 	   (org-agenda-overriding-arguments
 	    (list (car args) sd span)))
 	    (list (car args) sd span)))
       (org-agenda-redo)
       (org-agenda-redo)
@@ -8005,7 +8006,7 @@ If FORCE-TAGS is non nil, the car of it returns the new tags."
 		tags thetags
 		tags thetags
 		new
 		new
 		(let ((org-prefix-format-compiled
 		(let ((org-prefix-format-compiled
-		       (or (get-text-property (point) 'format)
+		       (or (get-text-property (min (1- (point-max)) (point)) 'format)
 			   org-prefix-format-compiled))
 			   org-prefix-format-compiled))
 		      (extra (org-get-at-bol 'extra)))
 		      (extra (org-get-at-bol 'extra)))
 		  (with-current-buffer (marker-buffer hdmarker)
 		  (with-current-buffer (marker-buffer hdmarker)
@@ -8681,12 +8682,11 @@ entries in that Org-mode file."
 	  (fset 'calendar-cursor-to-date oldf))))))
 	  (fset 'calendar-cursor-to-date oldf))))))
 
 
 (defun org-agenda-execute-calendar-command (cmd)
 (defun org-agenda-execute-calendar-command (cmd)
-  "Execute a calendar command from the agenda, with the date associated to
-the cursor position."
+  "Execute a calendar command from the agenda with date from cursor."
   (org-agenda-check-type t 'agenda 'timeline)
   (org-agenda-check-type t 'agenda 'timeline)
   (require 'diary-lib)
   (require 'diary-lib)
-  (unless (get-text-property (point) 'day)
-    (error "Don't know which date to use for calendar command"))
+  (unless (get-text-property (min (1- (point-max)) (point)) 'day)
+    (error "Don't know which date to use for the calendar command"))
   (let* ((oldf (symbol-function 'calendar-cursor-to-date))
   (let* ((oldf (symbol-function 'calendar-cursor-to-date))
 	 (point (point))
 	 (point (point))
 	 (date (calendar-gregorian-from-absolute
 	 (date (calendar-gregorian-from-absolute
@@ -8734,7 +8734,7 @@ argument, latitude and longitude will be prompted for."
   "Open the Emacs calendar with the date at the cursor."
   "Open the Emacs calendar with the date at the cursor."
   (interactive)
   (interactive)
   (org-agenda-check-type t 'agenda 'timeline)
   (org-agenda-check-type t 'agenda 'timeline)
-  (let* ((day (or (get-text-property (point) 'day)
+  (let* ((day (or (get-text-property (min (1- (point-max)) (point)) 'day)
 		  (error "Don't know which date to open in calendar")))
 		  (error "Don't know which date to open in calendar")))
 	 (date (calendar-gregorian-from-absolute day))
 	 (date (calendar-gregorian-from-absolute day))
 	 (calendar-move-hook nil)
 	 (calendar-move-hook nil)
@@ -8755,7 +8755,7 @@ This is a command that has to be installed in `calendar-mode-map'."
 (defun org-agenda-convert-date ()
 (defun org-agenda-convert-date ()
   (interactive)
   (interactive)
   (org-agenda-check-type t 'agenda 'timeline)
   (org-agenda-check-type t 'agenda 'timeline)
-  (let ((day (get-text-property (point) 'day))
+  (let ((day (get-text-property (min (1- (point-max)) (point)) 'day))
 	date s)
 	date s)
     (unless day
     (unless day
       (error "Don't know which date to convert"))
       (error "Don't know which date to convert"))