Last active
April 11, 2016 13:46
-
-
Save shivamkalra/4475a415dabdc89a131a69feaa95a7b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; helm-goobook.el | |
;; Copyright 2016 Shivam Kalra | |
;; | |
;; Author: Shivam Kalra <skalra@gmx.ca> | |
;;; Code: | |
(defun goobook-search (search-term) | |
(message search-term) | |
(process-lines "goosearch" search-term)) | |
(defun helm-goobook-search () | |
(mapcar (lambda (entry) | |
(let* ((vals (split-string entry "\t")) | |
(email (car vals)) | |
(name (car (cdr vals))) | |
(key (format "%s <%s>" name email))) | |
`(,key | |
(name . ,name) | |
(email . ,email) | |
(val . ,key)))) (goobook-search helm-pattern))) | |
(defun helm-goobook-insert-key (entry) | |
(with-helm-current-buffer | |
(insert (cdr (assoc 'val entry))))) | |
(defun helm-goobook-insert-name (entry) | |
(with-helm-current-buffer | |
(insert (cdr (assoc 'name entry))))) | |
(defun helm-goobook-insert-email (entry) | |
(with-helm-current-buffer | |
(insert (cdr (assoc 'email entry))))) | |
(defvar helm-source-goobook | |
'((name . "Goobook Search") | |
(volatile) | |
(delayed) | |
(requires-pattern . 3) | |
(candidates . helm-goobook-search) | |
(action . (("Insert key" . helm-goobook-insert-key) | |
("Insert email" . helm-goobook-insert-email) | |
("Insert name" . helm-goobook-insert-name))))) | |
(defun helm-goobook () | |
(interactive) | |
(helm :sources '(helm-source-goobook) | |
:buffer "*helm-goobook*")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment