emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] org-contacts: Provide ordering when using cycle completion
@ 2013-06-10  9:29 Øyvind Stegard
  2013-06-11 18:45 ` Daimrod
  0 siblings, 1 reply; 2+ messages in thread
From: Øyvind Stegard @ 2013-06-10  9:29 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 967 bytes --]

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/


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: [PATCH] org-contacts: Provide ordering when using cycle completion --]
[-- Type: text/x-diff, Size: 1486 bytes --]

From 64623274f0a040c452df43b2a3f7b23b0af8fd57 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=98yvind=20Stegard?= <oyvind.stegard@ifi.uio.no>
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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] org-contacts: Provide ordering when using cycle completion
  2013-06-10  9:29 [PATCH] org-contacts: Provide ordering when using cycle completion Øyvind Stegard
@ 2013-06-11 18:45 ` Daimrod
  0 siblings, 0 replies; 2+ messages in thread
From: Daimrod @ 2013-06-11 18:45 UTC (permalink / raw)
  To: Øyvind Stegard; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 2702 bytes --]

Øyvind Stegard <oyvinst@ifi.uio.no> writes:

> Hello list,

Hello,

Merged into master, thanks for patch!

> 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?= <oyvind.stegard@ifi.uio.no>
> 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.

-- 
Daimrod/Greg

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-06-11 18:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-10  9:29 [PATCH] org-contacts: Provide ordering when using cycle completion Øyvind Stegard
2013-06-11 18:45 ` Daimrod

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).