emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] [PATCH] org-contacts: Provide ordering when using cycle completion


From: Øyvind Stegard
Subject: [O] [PATCH] org-contacts: Provide ordering when using cycle completion
Date: Mon, 10 Jun 2013 11:29:13 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Hello list,

I have recently switched to using org-contacts, after several years of
BBDB usage. When completing contacts in message-mode, I prefer cycling
the completion alternatives, for instance when a single contact has
multiple email addresses. So I set `completion-cycle-threshold' to some
value other than nil.

However, the cycle ordering was not consistent with the order in which
email addresses appeared in the contact (actually, cycle order was
shortest candidate first, which I understand is a default). So the
"preferred" email address (or the first one defined in :EMAIL: property
of contact node) was typically not always chosen as first completion
suggestion in the cycle.

I attach a patch here (against current org-mode git) which also provides
the display sort function for cycle completions in metadata. That seems
to resolve the problem for me.


Regards,

Øyvind Stegard
-- 
< Øyvind Stegard
 < http://stegard.net/

>From 64623274f0a040c452df43b2a3f7b23b0af8fd57 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=98yvind=20Stegard?= <address@hidden>
Date: Mon, 10 Jun 2013 11:08:56 +0200
Subject: [PATCH] org-contacts: Provide ordering when using cycle completion

* contrib/lisp/org-contacts.el (org-contacts-metadata-prefix):
Provide same function for cycle ordering as is used for display ordering
in completion metadata.

When using cycle completion style for contacts, by setting
`completion-cycle-threshold' to some value, the ordering was not consistent
with order of email addresses in contact definition, nor the order
which was used for regular display completion. Fix that by also
supplying sort function for cycle completion in metadata.
---
 contrib/lisp/org-contacts.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/contrib/lisp/org-contacts.el b/contrib/lisp/org-contacts.el
index 5d63fcc..71f7bf4 100644
--- a/contrib/lisp/org-contacts.el
+++ b/contrib/lisp/org-contacts.el
@@ -452,7 +452,8 @@ prefixes rather than just the beginning of the string."
 
 (defun org-contacts-metadata-prefix (string collection predicate)
   '(metadata .
-            ((display-sort-function . org-contacts-display-sort-function))))
+            ((cycle-sort-function . org-contacts-display-sort-function)
+             (display-sort-function . org-contacts-display-sort-function))))
 
 (defun org-contacts-complete-group (start end string)
   "Complete text at START from a group.
-- 
1.8.1.2


reply via email to

[Prev in Thread] Current Thread [Next in Thread]