From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yuri D Lensky Subject: [Patch] Fix date-based sorting of tags and tags-todo agenda views Date: Sat, 7 Feb 2015 19:05:52 +0000 Message-ID: <1D119613313E504D8C7FDD06E9B6DD40C951ADE8@OC11expo28.exchange.mit.edu> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="_002_1D119613313E504D8C7FDD06E9B6DD40C951ADE8OC11expo28excha_" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:36930) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKAhf-0006jO-7J for emacs-orgmode@gnu.org; Sat, 07 Feb 2015 14:06:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YKAhb-0008TE-VN for emacs-orgmode@gnu.org; Sat, 07 Feb 2015 14:06:03 -0500 Received: from dmz-mailsec-scanner-8.mit.edu ([18.7.68.37]:51288) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKAhb-0008T4-Rj for emacs-orgmode@gnu.org; Sat, 07 Feb 2015 14:05:59 -0500 Received: from outgoing-exchange-1.mit.edu (outgoing-exchange-1.mit.edu [18.9.28.15]) by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id t17J5vg2029739 for ; Sat, 7 Feb 2015 14:05:57 -0500 Received: from W92EXEDGE6.EXCHANGE.MIT.EDU (w92exedge6.exchange.mit.edu [18.7.73.28]) by outgoing-exchange-1.mit.edu (8.13.8/8.12.4) with ESMTP id t17J5qp1025160 for ; Sat, 7 Feb 2015 14:05:57 -0500 Content-Language: en-US List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: "emacs-orgmode@gnu.org" --_002_1D119613313E504D8C7FDD06E9B6DD40C951ADE8OC11expo28excha_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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 wil= l 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" Date: Sat, 7 Feb 2015 13:37:46 -0500 Subject: [PATCH] Fix timestamp-based sorting of tags-based entries in agend= a * 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 (>=3D 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) --=20 1.9.4.msysgit.2 --_002_1D119613313E504D8C7FDD06E9B6DD40C951ADE8OC11expo28excha_ Content-Type: application/octet-stream; name="0001-Fix-timestamp-based-sorting-of-tags-based-entries-in.patch" Content-Description: 0001-Fix-timestamp-based-sorting-of-tags-based-entries-in.patch Content-Disposition: attachment; filename="0001-Fix-timestamp-based-sorting-of-tags-based-entries-in.patch"; size=3057; creation-date="Sat, 07 Feb 2015 18:50:49 GMT"; modification-date="Sat, 07 Feb 2015 18:50:49 GMT" Content-Transfer-Encoding: base64 RnJvbSBjOGE3MjExNjM5ZDljMTM4YTNiM2RjYjdlM2NlN2M4NTI2NDU4MGYxIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiAiWXVyaSBELiBMZW5za3kiIDx5ZGxAeWRsLmNtPgpEYXRlOiBT YXQsIDcgRmViIDIwMTUgMTM6Mzc6NDYgLTA1MDAKU3ViamVjdDogW1BBVENIXSBGaXggdGltZXN0 YW1wLWJhc2VkIHNvcnRpbmcgb2YgdGFncy1iYXNlZC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