Explorar o código

Merge branch 'maint'

Conflicts:
	lisp/org-agenda.el
	lisp/org.el
	testing/lisp/test-org-element.el
Bastien Guerry %!s(int64=12) %!d(string=hai) anos
pai
achega
b54d6f5965
Modificáronse 7 ficheiros con 84 adicións e 48 borrados
  1. 3 1
      contrib/lisp/org-depend.el
  2. 2 2
      doc/org.texi
  3. 39 22
      lisp/org-agenda.el
  4. 4 2
      lisp/org-clock.el
  5. 2 1
      lisp/org-icalendar.el
  6. 32 18
      lisp/org.el
  7. 2 2
      testing/lisp/test-org-element.el

+ 3 - 1
contrib/lisp/org-depend.el

@@ -205,6 +205,8 @@ This does two different kinds of triggers:
   property is seen as an entry id.  Org-mode finds the entry with the
   corresponding ID property and switches it to the state TODO as well."
 
+  ;; Refresh the effort text properties
+  (org-refresh-effort-properties)
   ;; Get information from the plist
   (let* ((type (plist-get change-plist :type))
 	       (pos (plist-get change-plist :position))
@@ -268,7 +270,7 @@ This does two different kinds of triggers:
 			    (tags (match-string 5))
 			    (priority (org-get-priority (or (match-string 3) "")))
 			    (effort (when (or effort-up effort-down)
-				      (let ((effort (org-get-effort)))
+				      (let ((effort (get-text-property (point) 'org-effort)))
 					(when effort
 					  (org-duration-string-to-minutes effort))))))
 			(push (list (point) todo-kwd priority tags effort)

+ 2 - 2
doc/org.texi

@@ -5580,7 +5580,7 @@ example with optional time
 
 @example
 * 22:00-23:00 The nerd meeting on every 2nd Thursday of the month
-  <%%(org-float t 4 2)>
+  <%%(diary-float t 4 2)>
 @end example
 
 @item Time/Date range
@@ -5917,7 +5917,7 @@ entries.  Org mode will issue early and late warnings based on the
 assumption that the timestamp represents the @i{nearest instance} of
 the repeater.  However, the use of diary sexp entries like
 @c
-@code{<%%(org-float t 42)>}
+@code{<%%(diary-float t 42)>}
 @c
 in scheduling and deadline timestamps is limited.  Org mode does not
 know enough about the internals of each sexp function to issue early and

+ 39 - 22
lisp/org-agenda.el

@@ -1677,6 +1677,18 @@ When non-nil, this must be the number of minutes, e.g. 60 for one hour."
   :group 'org-agenda-line-format
   :type 'boolean)
 
+(defcustom org-agenda-use-tag-inheritance '(todo search timeline agenda)
+  "List of agenda view types where to use tag inheritance.
+
+In tags/tags-todo/tags-tree agenda views, tag inheritance is
+controlled by `org-use-tag-inheritance'.  In other agenda types,
+`org-use-tag-inheritance' is not used when selecting the agenda
+entries, but you may want the agenda to use the inherited tags
+anyway, e.g. for later tag filtering.
+
+Setting this to nil will speed up non-tags agenda view a lot."
+  :version "24.3")
+
 (defcustom org-agenda-hide-tags-regexp nil
   "Regular expression used to filter away specific tags in agenda views.
 This means that these tags will be present, but not be shown in the agenda
@@ -3577,9 +3589,20 @@ generating a new one."
       (if (and (functionp 'org-habit-insert-consistency-graphs)
 	       (save-excursion (next-single-property-change (point-min) 'org-habit-p)))
 	  (org-habit-insert-consistency-graphs))
+      (setq org-agenda-type (org-get-at-bol 'org-agenda-type))
+      (when (delq nil (mapcar (lambda (tp) (org-agenda-check-type nil tp))
+			      org-agenda-use-tag-inheritance))
+	(let (mrk)
+	  (save-excursion
+	    (goto-char (point-min))
+	    (while (equal (forward-line) 0)
+	      (when (setq mrk (or (get-text-property (point) 'org-hd-marker)
+				  (get-text-property (point) 'org-hd-marker)))
+		(put-text-property (point-at-bol) (point-at-eol)
+				   'tags (org-with-point-at mrk
+					   (delete-dups (org-get-tags-at)))))))))
       (let ((inhibit-read-only t))
 	(run-hooks 'org-agenda-finalize-hook))
-      (setq org-agenda-type (org-get-at-bol 'org-agenda-type))
       (when (or org-agenda-tag-filter (get 'org-agenda-tag-filter :preset-filter))
 	(org-agenda-filter-apply org-agenda-tag-filter 'tag))
       (when (or org-agenda-category-filter (get 'org-agenda-category-filter :preset-filter))
@@ -4456,7 +4479,7 @@ in `org-agenda-text-search-extra-files'."
 			      category (org-get-category)
 			      level (make-string (org-reduced-level (org-outline-level)) ? )
 			      category-pos (get-text-property (point) 'org-category-position)
-			      tags (org-get-tags-at (point))
+			      tags (org-get-tags-at nil t)
 			      txt (org-agenda-format-item
 				   ""
 				   (buffer-substring-no-properties
@@ -5292,7 +5315,7 @@ the documentation of `org-diary'."
 	      category-pos (get-text-property (point) 'org-category-position)
 	      txt (org-trim
 		   (buffer-substring (match-beginning 2) (match-end 0)))
-	      tags (org-get-tags-at (point))
+	      tags (org-get-tags-at nil t)
 	      level (make-string (org-reduced-level (org-outline-level)) ? )
 	      txt (org-agenda-format-item "" txt level category tags t)
 	      priority (1+ (org-get-priority txt))
@@ -5461,7 +5484,7 @@ Do we have a reason to ignore this TODO entry because it has a time stamp?
 	      clockp (and org-agenda-include-inactive-timestamps
 			  (or (string-match org-clock-string tmp)
 			      (string-match "]-+\\'" tmp)))
-	      warntime (org-entry-get (point) "APPT_WARNTIME")
+	      warntime (get-text-property (point) 'org-appt-warntime)
 	      donep (member todo-state org-done-keywords))
 	(if (or scheduledp deadlinep closedp clockp
 		(and donep org-agenda-skip-timestamp-if-done))
@@ -5480,7 +5503,7 @@ Do we have a reason to ignore this TODO entry because it has a time stamp?
 		     (assoc (point) deadline-position-alist))
 		(throw :skip nil))
 	    (setq hdmarker (org-agenda-new-marker)
-		  tags (org-get-tags-at)
+		  tags (org-get-tags-at nil t)
 		  level (make-string (org-reduced-level (org-outline-level)) ? ))
 	    (looking-at "\\*+[ \t]+\\([^\r\n]+\\)")
 	    (setq head (or (match-string 1) ""))
@@ -5532,10 +5555,9 @@ Do we have a reason to ignore this TODO entry because it has a time stamp?
 		level (make-string (org-reduced-level (org-outline-level)) ? )
 		category (org-get-category beg)
 		category-pos (get-text-property beg 'org-category-position)
-		tags (save-excursion (org-backward-heading-same-level 0)
-				     (org-get-tags-at))
+		tags (save-excursion (org-back-to-heading t) (org-get-tags-at nil t))
 		todo-state (org-get-todo-state)
-		warntime (org-entry-get (point) "APPT_WARNTIME")
+		warntime (get-text-property (point) 'org-appt-warntime)
 		extra nil)
 
 	  (dolist (r (if (stringp result)
@@ -5582,7 +5604,6 @@ Do we have a reason to ignore this TODO entry because it has a time stamp?
   (org-no-warnings
    (let ((calendar-date-style 'european)	(european-calendar-style t))
      (diary-date day month year mark))))
-(defalias 'org-float 'diary-float)
 
 ;; Define the` org-class' function
 (defun org-class (y1 m1 d1 y2 m2 d2 dayname &rest skip-weeks)
@@ -5703,7 +5724,7 @@ please use `org-class' instead."
 	      (setq txt org-agenda-no-heading-message)
 	    (goto-char (match-beginning 0))
 	    (setq hdmarker (org-agenda-new-marker)
-		  tags (org-get-tags-at)
+		  tags (org-get-tags-at nil t)
 		  level (make-string (org-reduced-level (org-outline-level)) ? ))
 	    (looking-at "\\*+[ \t]+\\([^\r\n]+\\)")
 	    (setq txt (match-string 1))
@@ -5922,14 +5943,14 @@ See also the user option `org-agenda-clock-consistency-checks'."
 			   (not (= diff 0))))
 		  (setq txt nil)
 		(setq category (org-get-category)
-		      warntime (org-entry-get (point) "APPT_WARNTIME")
+		      warntime (get-text-property (point) 'org-appt-warntime)
 		      category-pos (get-text-property (point) 'org-category-position))
 		(if (not (re-search-backward "^\\*+[ \t]+" nil t))
 		    (setq txt org-agenda-no-heading-message)
 		  (goto-char (match-end 0))
 		  (setq pos1 (match-beginning 0))
 		  (setq level (make-string (org-reduced-level (org-outline-level)) ? ))
-		  (setq tags (org-get-tags-at pos1))
+		  (setq tags (org-get-tags-at pos1 t))
 		  (setq head (buffer-substring-no-properties
 			      (point)
 			      (progn (skip-chars-forward "^\r\n")
@@ -6014,7 +6035,7 @@ FRACTION is what fraction of the head-warning time has passed."
 		  (match-string 1) d1 'past show-all
 		  (current-buffer) pos)
 	      diff (- d2 d1)
-	      warntime (org-entry-get (point) "APPT_WARNTIME"))
+	      warntime (get-text-property (point) 'org-appt-warntime))
 	(setq pastschedp (and todayp (< diff 0)))
 	(setq did-habit-check-p nil)
 	;; When to show a scheduled item in the calendar:
@@ -6060,7 +6081,7 @@ FRACTION is what fraction of the head-warning time has passed."
 				pastschedp))
 		       (setq mm (assoc pos1 deadline-position-alist)))
 		      (throw :skip nil)))
-		(setq tags (org-get-tags-at))
+		(setq tags (org-get-tags-at nil t))
 		(setq level (make-string (org-reduced-level (org-outline-level)) ? ))
 		(setq head (buffer-substring-no-properties
 			    (point)
@@ -6144,7 +6165,7 @@ FRACTION is what fraction of the head-warning time has passed."
 		    (setq txt org-agenda-no-heading-message)
 		  (goto-char (match-beginning 0))
 		  (setq hdmarker (org-agenda-new-marker (point)))
-		  (setq tags (org-get-tags-at))
+		  (setq tags (org-get-tags-at nil t))
 		  (setq level (make-string (org-reduced-level (org-outline-level)) ? ))
 		  (looking-at "\\*+[ \t]+\\([^\r\n]+\\)")
 		  (setq head (match-string 1))
@@ -6311,12 +6332,7 @@ Any match of REMOVE-RE will be removed from TXT."
 			       (match-string 2 txt))
 		       t t txt))))
 	(when (derived-mode-p 'org-mode)
-	  (setq effort
-		(condition-case nil
-		    (org-get-effort
-		     (or (get-text-property 0 'org-hd-marker txt)
-			 (get-text-property 0 'org-marker txt)))
-		  (error nil)))
+	  (setq effort (ignore-errors (get-text-property 0 'org-effort txt)))
 	  (when effort
 	    (setq neffort (org-duration-string-to-minutes effort)
 		  effort (setq effort (concat "[" effort "]")))))
@@ -6840,7 +6856,8 @@ in the file.  Otherwise, restriction will be to the current subtree."
 
 (defun org-agenda-check-type (error &rest types)
   "Check if agenda buffer is of allowed type.
-If ERROR is non-nil, throw an error, otherwise just return nil."
+If ERROR is non-nil, throw an error, otherwise just return nil.
+Allowed types are 'agenda 'timeline 'todo 'tags 'search."
   (if (not org-agenda-type)
       (error "No Org agenda currently displayed")
     (if (memq org-agenda-type types)

+ 4 - 2
lisp/org-clock.el

@@ -35,6 +35,7 @@
 (declare-function calendar-absolute-from-iso "cal-iso" (&optional date))
 (declare-function notifications-notify "notifications" (&rest params))
 (declare-function org-pop-to-buffer-same-window "org-compat" (&optional buffer-or-name norecord label))
+(declare-function org-refresh-properties "org" (dprop tprop))
 (defvar org-time-stamp-formats)
 (defvar org-ts-what)
 (defvar org-frame-title-format-backup frame-title-format)
@@ -1105,6 +1106,7 @@ time as the start time \(see `org-clock-continuously' to
 make this the default behavior.)"
   (interactive "P")
   (setq org-clock-notification-was-shown nil)
+  (org-refresh-properties org-effort-property 'org-effort)
   (catch 'abort
     (let ((interrupting (and (not org-clock-resolving-clocks-due-to-idleness)
 			     (org-clocking-p)))
@@ -1226,7 +1228,7 @@ make this the default behavior.)"
 	      (setq org-clock-start-time
 		    (apply 'encode-time
 			   (org-parse-time-string (match-string 1))))
-	      (setq org-clock-effort (org-get-effort))
+	      (setq org-clock-effort (get-text-property (point) 'org-effort))
 	      (setq org-clock-total-time (org-clock-sum-current-item
 					  (org-clock-get-sum-start))))
 	     ((eq org-clock-in-resume 'auto-restart)
@@ -1246,7 +1248,7 @@ make this the default behavior.)"
 		(beginning-of-line 1)
 		(org-indent-line-to (- (org-get-indentation) 2)))
 	      (insert org-clock-string " ")
-	      (setq org-clock-effort (org-get-effort))
+	      (setq org-clock-effort (get-text-property (point) 'org-effort))
 	      (setq org-clock-total-time (org-clock-sum-current-item
 					  (org-clock-get-sum-start)))
 	      (setq org-clock-start-time

+ 2 - 1
lisp/org-icalendar.el

@@ -327,6 +327,7 @@ When COMBINE is non nil, add the category to each line."
 	tmp pri categories location summary desc uid alarm alarm-time
 	(sexp-buffer (get-buffer-create "*ical-tmp*")))
     (org-refresh-category-properties)
+    (org-refresh-properties "APPT_WARNTIME" 'org-appt-warntime)
     (save-excursion
       (goto-char (point-min))
       (while (re-search-forward re1 nil t)
@@ -357,7 +358,7 @@ When COMBINE is non nil, add the category to each line."
 			(org-id-get-create)
 		      (or (org-id-get) (org-id-new)))
 		categories (org-export-get-categories)
-		alarm-time (org-entry-get nil "APPT_WARNTIME")
+		alarm-time (get-text-property (point) 'org-appt-warntime)
 		alarm-time (if alarm-time (string-to-number alarm-time) 0)
 		alarm ""
 		deadlinep nil scheduledp nil)

+ 32 - 18
lisp/org.el

@@ -3120,7 +3120,7 @@ When nil, only the tags directly given in a specific line apply there.
 This may also be a list of tags that should be inherited, or a regexp that
 matches tags that should be inherited.  Additional control is possible
 with the variable  `org-tags-exclude-from-inheritance' which gives an
-explicit list of tags to be excluded from inheritance., even if the value of
+explicit list of tags to be excluded from inheritance, even if the value of
 `org-use-tag-inheritance' would select it for inheritance.
 
 If this option is t, a match early-on in a tree can lead to a large
@@ -8815,6 +8815,24 @@ call CMD."
 	   (put-text-property beg end 'org-category-position beg)
 	   (goto-char pos)))))))
 
+(defun org-refresh-properties (dprop tprop)
+  "Refresh buffer text properties.
+DPROP is the drawer property and TPROP is the corresponding text
+property to set."
+  (let ((case-fold-search t)
+	(inhibit-read-only t) p)
+    (org-unmodified
+     (save-excursion
+       (save-restriction
+	 (widen)
+	 (goto-char (point-min))
+	 (while (re-search-forward (concat "^[ \t]*:" dprop ": +\\(.*\\)[ \t]*$") nil t)
+	   (setq p (org-match-string-no-properties 1))
+	   (save-excursion
+	     (org-back-to-heading t)
+	     (put-text-property
+	      (point-at-bol) (point-at-eol) tprop p))))))))
+
 
 ;;;; Link Stuff
 
@@ -8908,7 +8926,7 @@ type.  For a simple example of an export function, see `org-bbdb.el'."
     (push (list type follow export) org-link-protocols)))
 
 (defvar org-agenda-buffer-name) ; Defined in org-agenda.el
-(defvar org-link-to-org-use-id) ; Defined in org-id.el
+(defvar org-id-link-to-org-use-id) ; Defined in org-id.el
 
 ;;;###autoload
 (defun org-store-link (arg)
@@ -10142,12 +10160,6 @@ there is one, return it."
   '(add-hook 'org-export-preprocess-before-normalizing-links-hook
 	     'org-remove-file-link-modifiers))
 
-;;;; Time estimates
-
-(defun org-get-effort (&optional pom)
-  "Get the effort estimate for the current entry."
-  (org-entry-get pom org-effort-property))
-
 ;;; File search
 
 (defvar org-create-file-search-functions nil
@@ -13374,15 +13386,7 @@ headlines matching this string."
 		 (or (not todo-only)
 		     (and (member todo org-not-done-keywords)
 			  (or (not org-agenda-tags-todo-honor-ignore-options)
-			      (not (org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item)))))
-
-		 ;; Extra check for the archive tag
-		 ;; FIXME: Does the skipper already do this????
-		 (or
-		  (not (member org-archive-tag tags-list))
-		  ;; we have an archive tag, should we use this anyway?
-		  (or (not org-agenda-skip-archived-trees)
-		      (and (eq action 'agenda) org-agenda-archives-mode))))
+			      (not (org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item))))))
 
 	    ;; select this headline
 	    (cond
@@ -14536,6 +14540,9 @@ When INCREMENT is non-nil, set the property to the next allowed value."
 		   existing nil nil "" nil cur))))))
     (unless (equal (org-entry-get nil prop) val)
       (org-entry-put nil prop val))
+    (save-excursion
+      (org-back-to-heading t)
+      (put-text-property (point-at-bol) (point-at-eol) 'org-effort val))
     (message "%s is now %s" prop val)))
 
 (defun org-at-property-p ()
@@ -15283,7 +15290,8 @@ completion."
   (interactive)
   (unless (org-at-property-p)
     (error "Not at a property"))
-  (let* ((key (match-string 2))
+  (let* ((prop (car (save-match-data (org-split-string (match-string 1) ":"))))
+	 (key (match-string 2))
 	 (value (match-string 3))
 	 (allowed (or (org-property-get-allowed-values (point) key)
 		      (and (member value  '("[ ]" "[-]" "[X]"))
@@ -15302,6 +15310,10 @@ completion."
     (org-indent-line)
     (beginning-of-line 1)
     (skip-chars-forward " \t")
+    (when (equal prop org-effort-property)
+      (save-excursion
+	(org-back-to-heading t)
+	(put-text-property (point-at-bol) (point-at-eol) 'org-effort nval)))
     (run-hook-with-args 'org-property-changed-functions key nval)))
 
 (defun org-find-olp (path &optional this-buffer)
@@ -17362,6 +17374,8 @@ When a buffer is unmodified, it is just killed.  When modified, it is saved
 	    (widen)
 	    (setq bmp (buffer-modified-p))
 	    (org-refresh-category-properties)
+	    (org-refresh-properties org-effort-property 'org-effort)
+	    (org-refresh-properties "APPT_WARNTIME" 'org-appt-warntime)
 	    (setq org-todo-keywords-for-agenda
 		  (append org-todo-keywords-for-agenda org-todo-keywords-1))
 	    (setq org-done-keywords-for-agenda

+ 2 - 2
testing/lisp/test-org-element.el

@@ -2260,8 +2260,8 @@ DEADLINE: <2012-01-01> SCHEDULED: <2012-01-01> CLOSED: [2012-01-01]\n"))))
 	      :hour-start 16 :minute-start 40 :year-end 2012 :month-end 3
 	      :day-end 29 :hour-end 16 :minute-end 41)) nil)))
   ;; Diary.
-  (should (equal (org-test-parse-and-interpret "<%%(org-float t 4 2)>")
-		 "<%%(org-float t 4 2)>\n"))
+  (should (equal (org-test-parse-and-interpret "<%%diary-float t 4 2>")
+		 "<%%diary-float t 4 2>\n"))
   ;; Timestamp with repeater interval.
   (should (equal (org-test-parse-and-interpret "<2012-03-29 thu. +1y>")
 		 "<2012-03-29 thu. +1y>\n"))