From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Abrahamsen Subject: Re: Completing with anything Date: Tue, 22 Mar 2011 23:02:33 +0800 Message-ID: <87wrjrp59y.fsf@ericabrahamsen.net> References: <87r5bhysp6.fsf@keller.adm.naquadah.org> <878vxovsym.fsf@keller.adm.naquadah.org> <87k4h7ua23.fsf@member.fsf.org> <87vd0romky.fsf@keller.adm.naquadah.org> <87mxm2na63.fsf@member.fsf.org> <87vd0qfhu3.fsf@member.fsf.org> <87lj08fxge.fsf@member.fsf.org> <87wrjr7t9e.fsf@ericabrahamsen.net> <87oc53meeh.fsf@ucl.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from [140.186.70.92] (port=36888 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q236w-0005iv-44 for emacs-orgmode@gnu.org; Tue, 22 Mar 2011 11:03:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q236s-00013n-6H for emacs-orgmode@gnu.org; Tue, 22 Mar 2011 11:03:06 -0400 Received: from lo.gmane.org ([80.91.229.12]:51238) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q236r-00013O-H4 for emacs-orgmode@gnu.org; Tue, 22 Mar 2011 11:03:02 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Q236p-0000Wc-L7 for emacs-orgmode@gnu.org; Tue, 22 Mar 2011 16:02:59 +0100 Received: from 123.121.199.176 ([123.121.199.176]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 22 Mar 2011 16:02:59 +0100 Received: from eric by 123.121.199.176 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 22 Mar 2011 16:02:59 +0100 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 Eric S Fraga writes: > Eric Abrahamsen writes: > > [...] > >> This is what I've been using to insert other people's contact >> information into emails. Probably no good for general use, but maybe >> will provide food for thought. >> >> #+BEGIN_SRC emacs-lisp >> (defun my-cite-contact (name) >> (interactive "sName (regexp): ") >> (let ((rec) >> (records (bbdb-search (bbdb-records) name name name nil nil))) >> (if (= (length records) 1) >> (setq rec (car records)) >> (if (zerop (length records)) >> (error "No matching records") >> (setq rec >> (let ((int-name (ido-completing-read "Pick one: " >> (mapcar 'bbdb-record-name records)))) >> (car (bbdb-search (bbdb-records) int-name)))))) >> (insert (bbdb-dwim-net-address rec)))) >> #+END_SRC > > This looks quite nice; I have been missing the possibility of a regex > search for mail addresses and the combination with ido is quite > appealing. > > How do you invoke it? I am currently struggling with the interactions > between .mailrc (emacs mail aliases, expanding as abbrevs) and bbdb > (expanding with TAB). This is partly why I haven't even considered > using org-contacts yet... > > As always, with Emacs, too many choices, too little time! ;-) I only ever invoke it through M-x, as I only ever use it to paste other people's contact details into an email (something I find myself doing surprisingly often). The trick was definitely figuring out at what "level" to let ido do its thing. The key was that bbdb came with both its own generic search function, and its own formatting function—ido is just the glue between, if necessary. I don't really like the fact that you first produce a collection of records, then pick *the name* of one record and essentially re-search all the records for that particular name, but I couldn't figure out a way to have ido select from among *representations* of actual records, and then return the record directly. I think that's where ido will trip you up: it's only made to select from strings. E