* [PATCH] agenda-view and custom sort
@ 2010-07-18 20:40 Jambunathan K
0 siblings, 0 replies; only message in thread
From: Jambunathan K @ 2010-07-18 20:40 UTC (permalink / raw)
To: emacs-orgmode; +Cc: Carsten Dominik
[-- Attachment #1: Type: text/plain, Size: 2560 bytes --]
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)
)
)
)
[-- Attachment #2: org-agenda.diff --]
[-- Type: text/plain, Size: 660 bytes --]
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)
[-- Attachment #3: Type: text/plain, Size: 201 bytes --]
_______________________________________________
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2010-07-18 20:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-18 20:40 [PATCH] agenda-view and custom sort Jambunathan K
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).