Re: [Ebib-users] external search in ebib?
Brought to you by:
joostkremers
From: Joost K. <joo...@fa...> - 2012-10-08 13:26:59
|
Hi Petro, On Sat, Oct 06 2012, Petro Khoroshyy <x....@gm...> wrote: > Hi ebib list. > I try to develop a way to annotate my articles using doc-view, ebib and > org-mode capture templates. I have little experience in elisp and > shamelessly ask if someone can develop a function (of show the way for > it). The function should run from emacs search in a pre-loaded ebib > database by one bibtex field (file in my case ) and return bibkey (or > other field) of corresponding record. I hope it is not complex thing to > do. > Thanks. > Petro I think this function *should* do what you want: ==================== (defun pk-ebib-search-for-field-value (field search-string) "Search the Ebib databases for SEARCH-STRING. Return the entry key of the first entry found to contain SEARCH-STRING in FIELD." (catch 'found (mapc #'(lambda (db) (maphash #'(lambda (key val) (let ((field-value (gethash field val))) (if (and field-value (string-match search-string field-value)) (throw 'found key)))) (edb-database db))) ebib-databases))) ==================== Note that the first argument, FIELD, should be a symbol, so in your case, you want to call the function in this way: (pk-ebib-search-for-field-value 'file "Some_File.pdf") Let me know if you run into any problems. J. -- Joost Kremers Life has its moments |