Skip to content

Commit

Permalink
Add a new feature that show mykie keywords by helm(but WIP yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuutayamada committed Jan 24, 2014
1 parent 1267904 commit affd811
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions lisp/helm-mykie-keywords.el
@@ -0,0 +1,72 @@
;;; helm-mykie-keywords.el --- Show mykie's keywords by helm.el

;; Copyright (C) 2014 by Yuta Yamada

;; Author: Yuta Yamada <cokesboy"at"gmail.com>

;;; License:
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:

;;; Code:
(eval-when-compile (require 'cl))
(require 'mykie)
(require 'helm)

(defvar helm-mykie-keywords-source nil)
(defvar helm-mykie-keywords-action
'(("Insert" .
(lambda (keyword) (insert keyword)))))

(defun mykie:set-helm-mykie-keyword ()
(setq helm-mykie-keywords-source
(loop with base = `((candidates-in-buffer)
(action . ,helm-mykie-keywords-action))
with make = (lambda (cond)
(loop for (kw . c) in (symbol-value cond)
collect (format "%s"
(typecase kw
(symbol (symbol-name kw))
(string kw)))))
for cond in mykie:group-conditions
for keywords = (funcall make cond)
for name = (list (cons 'name (symbol-name cond)))
for func = `(lambda ()
(helm-init-candidates-in-buffer
,cond
(with-temp-buffer
(loop for kw in (quote ,keywords)
do (insert (format "%s\n" kw)))
(buffer-string))))
collect (append base name
`((init . ,func))))))

;;;###autoload
(defun helm-show-mykie-keywords ()
"Show mykie.el keywords."
(interactive)
(unless helm-mykie-keywords-source
(mykie:set-helm-mykie-keyword))
(helm
:sources helm-mykie-keywords-source
:buffer "*helm mykie*"))

(provide 'helm-mykie-keywords)

;; Local Variables:
;; coding: utf-8
;; mode: emacs-lisp
;; End:

;;; helm-mykie-keywords.el ends here

0 comments on commit affd811

Please sign in to comment.