[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] [Patch] Fix date-based sorting of tags and tags-todo agenda views
From: |
Yuri D Lensky |
Subject: |
[O] [Patch] Fix date-based sorting of tags and tags-todo agenda views |
Date: |
Sat, 7 Feb 2015 19:05:52 +0000 |
An example to test this problem:
Evaluate:
(setq org-agenda-custom-commands
'(("t" "TEST" tags-todo "tag"
((org-agenda-sorting-strategy '(deadline-up))))))
then run the view. It will not be sorted properly before the patch, but will be
after.
I would also recommend factoring the code that I added out into a separate
function (as it also appears almost verbatim in org-agenda-get-todos), but I am
not sure the conventions or desire for this.
>From c8a7211639d9c138a3b3dcb7e3ce7c85264580f1 Mon Sep 17 00:00:00 2001
From: "Yuri D. Lensky" <address@hidden>
Date: Sat, 7 Feb 2015 13:37:46 -0500
Subject: [PATCH] Fix timestamp-based sorting of tags-based entries in agenda
* lisp/org.el (org-scan-tags): Fix agenda org tags scans to properly
add timestamp property, completely analogously to org-agenda-get-todos.
Before this fix, timestamps were ignored when sorting agenda views of
the 'tags' and 'tags-todo' types.
---
lisp/org.el | 34 ++++++++++++++++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index a095f8d..54b375e 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -14177,7 +14177,7 @@ headlines matching this string."
lspos tags tags-list
(tags-alist (list (cons 0 org-file-tags)))
(llast 0) rtn rtn1 level category i txt
- todo marker entry priority)
+ todo marker entry priority ts-date ts-date-type)
(when (not (or (member action '(agenda sparse-tree)) (functionp action)))
(setq action (list 'lambda nil action)))
(save-excursion
@@ -14194,6 +14194,34 @@ headlines matching this string."
(goto-char (setq lspos (match-beginning 0)))
(setq level (org-reduced-level (org-outline-level))
category (org-get-category))
+ (when (eq action 'agenda)
+ (setq ts-date (let (ts)
+ (save-match-data
+ (cond ((org-em 'scheduled-up 'scheduled-down
+ org-agenda-sorting-strategy-selected)
+ (setq ts (org-entry-get (point) "SCHEDULED")
+ ts-date-type " scheduled"))
+ ((org-em 'deadline-up 'deadline-down
+ org-agenda-sorting-strategy-selected)
+ (setq ts (org-entry-get (point) "DEADLINE")
+ ts-date-type " deadline"))
+ ((org-em 'ts-up 'ts-down
+ org-agenda-sorting-strategy-selected)
+ (setq ts (org-entry-get (point) "TIMESTAMP")
+ ts-date-type " timestamp"))
+ ((org-em 'tsia-up 'tsia-down
+ org-agenda-sorting-strategy-selected)
+ (setq ts (org-entry-get (point) "TIMESTAMP_IA")
+ ts-date-type " timestamp_ia"))
+ ((org-em 'timestamp-up 'timestamp-down
+ org-agenda-sorting-strategy-selected)
+ (setq ts (or (org-entry-get (point)
"SCHEDULED")
+ (org-entry-get (point) "DEADLINE")
+ (org-entry-get (point)
"TIMESTAMP")
+ (org-entry-get (point)
"TIMESTAMP_IA"))
+ ts-date-type ""))
+ (t (setq ts-date-type "")))
+ (when ts (ignore-errors (org-time-string-to-absolute
ts)))))))
(setq i llast llast level)
;; remove tag lists from same and sublevels
(while (>= i level)
@@ -14265,7 +14293,9 @@ headlines matching this string."
(org-add-props txt props
'org-marker marker 'org-hd-marker marker 'org-category category
'todo-state todo
- 'priority priority 'type "tagsmatch")
+ 'ts-date ts-date
+ 'priority priority
+ 'type (concat "tagsmatch" ts-date-type))
(push txt rtn))
((functionp action)
(setq org-map-continue-from nil)
--
1.9.4.msysgit.2
0001-Fix-timestamp-based-sorting-of-tags-based-entries-in.patch
Description: 0001-Fix-timestamp-based-sorting-of-tags-based-entries-in.patch
- [O] [Patch] Fix date-based sorting of tags and tags-todo agenda views,
Yuri D Lensky <=