Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a new feature that show mykie keywords by helm(but WIP yet)
- Loading branch information
1 parent
1267904
commit affd811
Showing
1 changed file
with
72 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |