From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jambunathan K Subject: [PATCH] agenda-view and custom sort Date: Mon, 19 Jul 2010 02:10:57 +0530 Message-ID: <4C4366D9.5080404@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------020508040602060604030505" Return-path: Received: from [140.186.70.92] (port=37984 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oaafe-0001l6-HI for emacs-orgmode@gnu.org; Sun, 18 Jul 2010 16:41:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Oaafd-0002nb-6p for emacs-orgmode@gnu.org; Sun, 18 Jul 2010 16:41:10 -0400 Received: from mail-pv0-f169.google.com ([74.125.83.169]:32920) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oaafd-0002nI-2H for emacs-orgmode@gnu.org; Sun, 18 Jul 2010 16:41:09 -0400 Received: by pvc30 with SMTP id 30so3667637pvc.0 for ; Sun, 18 Jul 2010 13:41:07 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Cc: Carsten Dominik This is a multi-part message in MIME format. --------------020508040602060604030505 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit BUG: Agenda view invokes custom sort routine even if not configured to do so. diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el old mode 100644 new mode 100755 index 1314eb2..f34f45d --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -5312,8 +5312,9 @@ HH:MM." (alpha-up (and (org-em 'alpha-up 'alpha-down ss) (org-cmp-alpha a b))) (alpha-down (if alpha-up (- alpha-up) nil)) + (need-user-cmp (org-em 'user-defined-up 'user-defined-down ss)) user-defined-up user-defined-down) - (if (and org-agenda-cmp-user-defined + (if (and need-user-cmp org-agenda-cmp-user-defined (functionp org-agenda-cmp-user-defined)) (setq user-defined-up (funcall org-agenda-cmp-user-defined a b) ;; Sample agenda file * Tasks ** Task1 <2010-07-19 Mon> ** Task2 <2010-07-19 Mon> ;; turn on custom comparison (org-agenda-cmp-user-defined (quote my-org-cmp-category)) ;; only todo-view requests custom comparison of categories. ;; agenda-view does *NOT* request custom compare function. Despite ;; this custom sort function is triggered on C-c a a. (org-agenda-sorting-strategy (quote ((agenda habit-down time-up priority-down category-keep) (todo priority-down user-defined-up) (tags priority-down category-keep) (search category-keep)))) ;; user-defined routine for sorting of categories. prints a message ;; to the console on being invoked. Rest of the details not relevant. (defun my-org-cmp-category (a b) "Compare the string values of categories of strings A and B." (let ( (uncategorized 0) (ca (or (get-text-property 1 'org-category a) "")) (cb (or (get-text-property 1 'org-category b) "")) ) (message "my-org-cmp-category") (setq ca (cdr (assoc ca org-CATEGORY-sort-order))) (setq cb (cdr (assoc cb org-CATEGORY-sort-order))) (unless ca (setq ca uncategorized) ) (unless cb (setq cb uncategorized) ) (cond ((< ca cb) -1) ((< cb ca) +1) (t nil)) ) ) ;; information down below is only for the sake of completion. ;; not relevant to the bug per se. ;; category to priority mappings (defcustom org-CATEGORY-sort-order nil "Map CATEGORY to Sort Order" :group 'org-jambu :type '(repeat (cons (string :tag "CATEGORY") (integer :tag "VALUE") ))) ;; example categories (org-CATEGORY-sort-order (quote ( ("PHONE" . 50) ("EMAIL" . 60) ("MISC" . 80) ) ) ) --------------020508040602060604030505 Content-Type: text/plain; name="org-agenda.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="org-agenda.diff" diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el old mode 100644 new mode 100755 index 1314eb2..f34f45d --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -5312,8 +5312,9 @@ HH:MM." (alpha-up (and (org-em 'alpha-up 'alpha-down ss) (org-cmp-alpha a b))) (alpha-down (if alpha-up (- alpha-up) nil)) + (need-user-cmp (org-em 'user-defined-up 'user-defined-down ss)) user-defined-up user-defined-down) - (if (and org-agenda-cmp-user-defined + (if (and need-user-cmp org-agenda-cmp-user-defined (functionp org-agenda-cmp-user-defined)) (setq user-defined-up (funcall org-agenda-cmp-user-defined a b) --------------020508040602060604030505 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --------------020508040602060604030505--