Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 173 lines (145 sloc) 6.415 kB
f9067e2 @thierryvolpiatto * helm-yaoddmuse.el: New file
thierryvolpiatto authored
1 ;;; helm-yaoddmuse.el --- Helm extension for yaoddmuse
2
3 ;; Copyright (C) 2012 Thierry Volpiatto <thierry.volpiatto@gmail.com>
4
5 ;; This program is free software; you can redistribute it and/or modify
6 ;; it under the terms of the GNU General Public License as published by
7 ;; the Free Software Foundation, either version 3 of the License, or
8 ;; (at your option) any later version.
9
10 ;; This program is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ;; GNU General Public License for more details.
14
15 ;; You should have received a copy of the GNU General Public License
16 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 ;;; Code:
19
20 (eval-when-compile (require 'cl))
21 (require 'helm)
22
7d8197a @thierryvolpiatto Fix warnings at compilation.
thierryvolpiatto authored
23 (declare-function yaoddmuse-update-pagename "ext:yaoddmuse.el" (&optional unforced))
24 (declare-function yaoddmuse-get-library-list "ext:yaoddmuse.el" (&optional dirs string))
25
f9067e2 @thierryvolpiatto * helm-yaoddmuse.el: New file
thierryvolpiatto authored
26 ;; Be sure to have yaoddmuse.el installed
27 ;; install-elisp may be required if you want to install elisp file from here.
28 (defvar helm-yaoddmuse-use-cache-file nil)
4166d8a @thierryvolpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
29 (defvar helm-yaoddmuse-cache-file "~/.emacs.d/yaoddmuse-cache.el")
30 (defvar helm-yaoddmuse-ew-cache nil)
f9067e2 @thierryvolpiatto * helm-yaoddmuse.el: New file
thierryvolpiatto authored
31
32 (defun helm-yaoddmuse-get-candidates ()
33 (declare (special yaoddmuse-pages-hash))
34 (if helm-yaoddmuse-use-cache-file
35 (ignore-errors
4166d8a @thierryvolpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
36 (unless helm-yaoddmuse-ew-cache
37 (load helm-yaoddmuse-cache-file)
38 (setq helm-yaoddmuse-ew-cache
f9067e2 @thierryvolpiatto * helm-yaoddmuse.el: New file
thierryvolpiatto authored
39 (gethash "EmacsWiki" yaoddmuse-pages-hash)))
4166d8a @thierryvolpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
40 helm-yaoddmuse-ew-cache)
f9067e2 @thierryvolpiatto * helm-yaoddmuse.el: New file
thierryvolpiatto authored
41 (yaoddmuse-update-pagename t)
42 (gethash "EmacsWiki" yaoddmuse-pages-hash)))
43
4166d8a @thierryvolpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
44 (defvar helm-source-yaoddmuse-emacswiki-edit-or-view
f9067e2 @thierryvolpiatto * helm-yaoddmuse.el: New file
thierryvolpiatto authored
45 '((name . "Yaoddmuse Edit or View (EmacsWiki)")
46 (candidates . helm-yaoddmuse-get-candidates)
47 (action . (("Edit page" . (lambda (candidate)
48 (yaoddmuse-edit "EmacsWiki" candidate)))
49 ("Browse page"
50 . (lambda (candidate)
51 (yaoddmuse-browse-page "EmacsWiki" candidate)))
52 ("Browse page other window"
53 . (lambda (candidate)
54 (if (one-window-p)
55 (split-window-vertically))
56 (yaoddmuse-browse-page "EmacsWiki" candidate)))
57 ("Browse diff"
58 . (lambda (candidate)
59 (yaoddmuse-browse-page-diff "EmacsWiki" candidate)))
60 ("Copy URL"
61 . (lambda (candidate)
62 (kill-new (yaoddmuse-url "EmacsWiki" candidate))
63 (message "Have copy page %s's URL to yank." candidate)))
64 ("Create page"
65 . (lambda (candidate)
66 (yaoddmuse-edit "EmacsWiki" helm-input)))
67 ("Update cache"
68 . (lambda (candidate)
69 (if helm-yaoddmuse-use-cache-file
70 (progn
71 (helm-yaoddmuse-cache-pages t)
4166d8a @thierryvolpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
72 (setq helm-yaoddmuse-ew-cache
f9067e2 @thierryvolpiatto * helm-yaoddmuse.el: New file
thierryvolpiatto authored
73 (gethash "EmacsWiki" yaoddmuse-pages-hash)))
74 (yaoddmuse-update-pagename))))))
4166d8a @thierryvolpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
75 (action-transformer helm-yaoddmuse-action-transformer))
f9067e2 @thierryvolpiatto * helm-yaoddmuse.el: New file
thierryvolpiatto authored
76 "Needs yaoddmuse.el.
77
78 http://www.emacswiki.org/emacs/download/yaoddmuse.el")
79
80
4166d8a @thierryvolpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
81 (defvar helm-source-yaoddmuse-emacswiki-post-library
f9067e2 @thierryvolpiatto * helm-yaoddmuse.el: New file
thierryvolpiatto authored
82 '((name . "Yaoddmuse Post library (EmacsWiki)")
83 (init . (helm-yaoddmuse-init))
84 (candidates-in-buffer)
85 (action . (("Post library and Browse"
86 . (lambda (candidate)
87 (yaoddmuse-post-file
88 (find-library-name candidate)
89 "EmacsWiki"
90 (file-name-nondirectory (find-library-name candidate))
91 nil t)))
92 ("Post library"
93 . (lambda (candidate)
94 (yaoddmuse-post-file
95 (find-library-name candidate)
96 "EmacsWiki"
97 (file-name-nondirectory
98 (find-library-name candidate))))))))
99 "Needs yaoddmuse.el.
100
101 http://www.emacswiki.org/emacs/download/yaoddmuse.el")
102
103
4166d8a @thierryvolpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
104 (defun helm-yaoddmuse-action-transformer (actions candidate)
f9067e2 @thierryvolpiatto * helm-yaoddmuse.el: New file
thierryvolpiatto authored
105 "Allow the use of `install-elisp' only on elisp files."
106 (if (string-match "\.el$" candidate)
107 (append actions '(("Install Elisp"
108 . (lambda (elm)
109 (install-elisp-from-emacswiki elm)))))
110 actions))
111
112 ;;;###autoload
113 (defun helm-yaoddmuse-cache-pages (&optional load)
114 "Fetch the list of files on emacswiki and create cache file.
115 If load is non--nil load the file and feed `yaoddmuse-pages-hash'."
116 (interactive)
117 (declare (special yaoddmuse-pages-hash))
118 (yaoddmuse-update-pagename)
119 (save-excursion
4166d8a @thierryvolpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
120 (find-file helm-yaoddmuse-cache-file)
f9067e2 @thierryvolpiatto * helm-yaoddmuse.el: New file
thierryvolpiatto authored
121 (erase-buffer)
122 (insert "(puthash \"EmacsWiki\" '(")
123 (loop for i in (gethash "EmacsWiki" yaoddmuse-pages-hash)
124 do
125 (insert (concat "(\"" (car i) "\") ")))
126 (insert ") yaoddmuse-pages-hash)\n")
127 (save-buffer)
128 (kill-buffer (current-buffer))
129 (when (or current-prefix-arg
130 load)
4166d8a @thierryvolpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
131 (load helm-yaoddmuse-cache-file))))
f9067e2 @thierryvolpiatto * helm-yaoddmuse.el: New file
thierryvolpiatto authored
132
133 (defun helm-yaoddmuse-init ()
134 "Init helm buffer status."
135 (let ((helm-buffer (helm-candidate-buffer 'global))
136 (library-list (yaoddmuse-get-library-list)))
137 (with-current-buffer helm-buffer
138 ;; Insert library name.
139 (dolist (library library-list)
140 (insert (format "%s\n" library)))
141 ;; Sort lines.
142 (sort-lines nil (point-min) (point-max)))))
143
144 ;;;###autoload
145 (defun helm-yaoddmuse-emacswiki-edit-or-view ()
146 "Preconfigured `helm' to edit or view EmacsWiki page.
147
148 Needs yaoddmuse.el.
149
150 http://www.emacswiki.org/emacs/download/yaoddmuse.el"
151 (interactive)
4166d8a @thierryvolpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
152 (helm :sources 'helm-source-yaoddmuse-emacswiki-edit-or-view))
f9067e2 @thierryvolpiatto * helm-yaoddmuse.el: New file
thierryvolpiatto authored
153
154 ;;;###autoload
155 (defun helm-yaoddmuse-emacswiki-post-library ()
156 "Preconfigured `helm' to post library to EmacsWiki.
157
158 Needs yaoddmuse.el.
159
160 http://www.emacswiki.org/emacs/download/yaoddmuse.el"
161 (interactive)
4166d8a @thierryvolpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
162 (helm :sources 'helm-source-yaoddmuse-emacswiki-post-library))
f9067e2 @thierryvolpiatto * helm-yaoddmuse.el: New file
thierryvolpiatto authored
163
164 (provide 'helm-yaoddmuse)
165
37b4201 @thierryvolpiatto Fix dependencies and autoloads. Reorder.
thierryvolpiatto authored
166 ;; Local Variables:
a7ee65b @thierryvolpiatto Disable compile warnings and add new keyword to helm.
thierryvolpiatto authored
167 ;; byte-compile-warnings: (not cl-functions obsolete)
37b4201 @thierryvolpiatto Fix dependencies and autoloads. Reorder.
thierryvolpiatto authored
168 ;; coding: utf-8
169 ;; indent-tabs-mode: nil
170 ;; End:
171
f9067e2 @thierryvolpiatto * helm-yaoddmuse.el: New file
thierryvolpiatto authored
172 ;;; helm-yaoddmuse.el ends here
Something went wrong with that request. Please try again.