Skip to content

Instantly share code, notes, and snippets.

@shivamkalra
Last active April 11, 2016 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shivamkalra/4475a415dabdc89a131a69feaa95a7b6 to your computer and use it in GitHub Desktop.
Save shivamkalra/4475a415dabdc89a131a69feaa95a7b6 to your computer and use it in GitHub Desktop.
;;; 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