emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* for your amusement
@ 2012-08-02  9:41 Eric Abrahamsen
  2014-02-20 10:55 ` Nicolas Richard
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Abrahamsen @ 2012-08-02  9:41 UTC (permalink / raw)
  To: bbdb-info; +Cc: emacs-orgmode


For a while I've had a function for creating textual citations of my
BBDB contacts, that relied on `bbdb-dwim-mail'. I expanded that to make
use of org's link syntax, so that you can insert a BBDB link on the
spot, without having to first visit your *BBDB* buffer and create a link
there. I find this pretty helpful.

If anyone can think of more formatting possibilities, "formats" could be
broken out into a variable.

Incidentally, I'm using `ido-everywhere', and would like to write this
function so that it didn't _rely_ on ido, but made use of ido when
`ido-everywhere' was true. Ie, I'd like to replace the
`ido-completing-read' calls with something more generic that still made
use of ido when it was turned on. Any suggestions?

Eric

--8<---------------cut here---------------start------------->8---
(defun cite-bbdb-contact (name)
  (interactive "sName (regexp): ")
  (let ((rec)
	(records (bbdb-search (bbdb-records) name name name nil nil))
	(formats '(("text" . bbdb-dwim-mail)
		   ("orglink" . (lambda (x)
				  (let ((name (bbdb-record-name x)))
				    (format "[[%s][%s]]"
					    (org-make-link "bbdb:" name) name)))))))
    (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))))))
    (let ((func (cdr (assoc (ido-completing-read
			     "Format: " (mapcar #'car formats)) formats))))
      (insert (funcall func rec)))))
--8<---------------cut here---------------end--------------->8---


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/

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

* Re: for your amusement
  2012-08-02  9:41 for your amusement Eric Abrahamsen
@ 2014-02-20 10:55 ` Nicolas Richard
  2014-02-20 11:29   ` Eric Abrahamsen
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Richard @ 2014-02-20 10:55 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: bbdb-info

[fu2 gmane.emacs.bbdb.user]

Eric Abrahamsen <eric@ericabrahamsen.net> writes:
> Incidentally, I'm using `ido-everywhere', and would like to write this
> function so that it didn't _rely_ on ido, but made use of ido when
> `ido-everywhere' was true. Ie, I'd like to replace the
> `ido-completing-read' calls with something more generic that still made
> use of ido when it was turned on. Any suggestions?

ido-everywhere is only meant for buffer/file (see its docstring). People
who really want ido everywhere should probably use ido-ubiquitous which
sets completing-read-function to ido-completing-read (in fact, a wrapper
around it because it cannot handle all cases that completing-read should
handle).

Hence, my suggestion would be to use completing-read instead of
ido-completing-read in your code, and configure ido-ubiquitous
(available from marmalade and melpa) for controlling what to use.

Related package : ido-hacks (which also enables ido in more places)

I *guess* it'll then also work automagically with icomplete-mode
(shipped with recent emacs) if that is what the user enable instead of
ido-ubiquitous.

-- 
Nico.

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

* Re: for your amusement
  2014-02-20 10:55 ` Nicolas Richard
@ 2014-02-20 11:29   ` Eric Abrahamsen
  2014-02-20 12:08     ` Nicolas Richard
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Abrahamsen @ 2014-02-20 11:29 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: bbdb-info

"Nicolas Richard" <theonewiththeevillook@yahoo.fr> writes:

> [fu2 gmane.emacs.bbdb.user]
>
> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>> Incidentally, I'm using `ido-everywhere', and would like to write this
>> function so that it didn't _rely_ on ido, but made use of ido when
>> `ido-everywhere' was true. Ie, I'd like to replace the
>> `ido-completing-read' calls with something more generic that still made
>> use of ido when it was turned on. Any suggestions?
>
> ido-everywhere is only meant for buffer/file (see its docstring). People
> who really want ido everywhere should probably use ido-ubiquitous which
> sets completing-read-function to ido-completing-read (in fact, a wrapper
> around it because it cannot handle all cases that completing-read should
> handle).
>
> Hence, my suggestion would be to use completing-read instead of
> ido-completing-read in your code, and configure ido-ubiquitous
> (available from marmalade and melpa) for controlling what to use.
>
> Related package : ido-hacks (which also enables ido in more places)
>
> I *guess* it'll then also work automagically with icomplete-mode
> (shipped with recent emacs) if that is what the user enable instead of
> ido-ubiquitous.

Gosh, where did you guys dig this thread up from? :)

Thanks for the refinements on the original function, and for the tips on
ido related packages in elpa repos -- I hadn't been aware of that. I've
been a tiny bit annoyed with this function ever since I wrote it
(obviously not annoyed enough, since that was years ago), as progressive
narrowing didn't work the way I wanted it to. Kevin, I'll give your
version a whack, and maybe come back with some more refinements in a
bit.

Thanks!
E

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

* Re: for your amusement
  2014-02-20 11:29   ` Eric Abrahamsen
@ 2014-02-20 12:08     ` Nicolas Richard
  2014-02-20 13:42       ` Eric Abrahamsen
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Richard @ 2014-02-20 12:08 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: bbdb-info

Eric Abrahamsen <eric@ericabrahamsen.net> writes:
> Gosh, where did you guys dig this thread up from? :)

Oops, I didn't notice the date of your original message. I answered
because of Kevin's answer.

-- 
Nico.

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

* Re: for your amusement
  2014-02-20 12:08     ` Nicolas Richard
@ 2014-02-20 13:42       ` Eric Abrahamsen
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Abrahamsen @ 2014-02-20 13:42 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: bbdb-info

"Nicolas Richard" <theonewiththeevillook@yahoo.fr> writes:

> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>> Gosh, where did you guys dig this thread up from? :)
>
> Oops, I didn't notice the date of your original message. I answered
> because of Kevin's answer.

If we're still using (and improving) the snippet, it's still a relevant thread!

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

end of thread, other threads:[~2014-02-20 13:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-02  9:41 for your amusement Eric Abrahamsen
2014-02-20 10:55 ` Nicolas Richard
2014-02-20 11:29   ` Eric Abrahamsen
2014-02-20 12:08     ` Nicolas Richard
2014-02-20 13:42       ` Eric Abrahamsen

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