Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 138 lines (107 sloc) 4.457 kb
530d89f @thierryvolpiatto Enable lexical-binding in all files.
thierryvolpiatto authored
1 ;;; helm-plugin.el --- Helm plugins -*- lexical-binding: t -*-
6cbdbb4 @thierryvolpiatto * helm-plugin.el: new
thierryvolpiatto authored
2
7c31479 @thierryvolpiatto Update copyrights.
thierryvolpiatto authored
3 ;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto <thierry.volpiatto@gmail.com>
6cbdbb4 @thierryvolpiatto * helm-plugin.el: new
thierryvolpiatto authored
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
b740a4b @thierryvolpiatto Finish replacing cl symbols and requiring cl-lib, no compile error.
thierryvolpiatto authored
20 (require 'cl-lib)
6cbdbb4 @thierryvolpiatto * helm-plugin.el: new
thierryvolpiatto authored
21 (require 'helm)
e2d112b @thierryvolpiatto * helm-plugin.el: Issue #215 require helm-utils.
thierryvolpiatto authored
22 (require 'helm-utils)
6cbdbb4 @thierryvolpiatto * helm-plugin.el: new
thierryvolpiatto authored
23
054b96b @thierryvolpiatto * helm-plugin.el: Remove obsolete plugins.
thierryvolpiatto authored
24
8fa7f6d @thierryvolpiatto * helm-plugin.el: Add comments, reorder.
thierryvolpiatto authored
25 ;;; Plug-in: `info-index'
6cbdbb4 @thierryvolpiatto * helm-plugin.el: new
thierryvolpiatto authored
26 ;;
27 ;;
4166d8a @thierryvolpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
28 (defun helm-make-info-source (source file)
6cbdbb4 @thierryvolpiatto * helm-plugin.el: new
thierryvolpiatto authored
29 `(,@source
30 (name . ,(concat "Info Index: " file))
31 (info-file . ,file)
4166d8a @thierryvolpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
32 (init . helm-info-init)
33 (display-to-real . helm-info-display-to-real)
6cbdbb4 @thierryvolpiatto * helm-plugin.el: new
thierryvolpiatto authored
34 (get-line . buffer-substring)
35 (candidates-in-buffer)
4166d8a @thierryvolpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
36 (action ("Goto node" . helm-info-goto))))
6cbdbb4 @thierryvolpiatto * helm-plugin.el: new
thierryvolpiatto authored
37
38 (defun helm-compile-source--info-index (source)
39 (helm-aif (helm-interpret-value (assoc-default 'info-index source))
4166d8a @thierryvolpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
40 (helm-make-info-source source it)
6cbdbb4 @thierryvolpiatto * helm-plugin.el: new
thierryvolpiatto authored
41 source))
8fa7f6d @thierryvolpiatto * helm-plugin.el: Add comments, reorder.
thierryvolpiatto authored
42
6cbdbb4 @thierryvolpiatto * helm-plugin.el: new
thierryvolpiatto authored
43 (add-to-list 'helm-compile-source-functions 'helm-compile-source--info-index)
44
45 (helm-document-attribute 'info-index "info-index plugin"
7eca6f0 * helm-plugin.el: Consistent formatting of doc-strings
Titus von der Malsburg authored
46 " Create a source of info index very easily.
6cbdbb4 @thierryvolpiatto * helm-plugin.el: new
thierryvolpiatto authored
47
7eca6f0 * helm-plugin.el: Consistent formatting of doc-strings
Titus von der Malsburg authored
48 Example:
49
50 (defvar helm-source-info-wget '((info-index . \"wget\"))")
6cbdbb4 @thierryvolpiatto * helm-plugin.el: new
thierryvolpiatto authored
51
054b96b @thierryvolpiatto * helm-plugin.el: Remove obsolete plugins.
thierryvolpiatto authored
52
8fa7f6d @thierryvolpiatto * helm-plugin.el: Add comments, reorder.
thierryvolpiatto authored
53 ;;; Plug-in: `candidates-file'
54 ;;
55 ;; List all lines in a file.
6cbdbb4 @thierryvolpiatto * helm-plugin.el: new
thierryvolpiatto authored
56 (defun helm-compile-source--candidates-file (source)
57 (if (assoc-default 'candidates-file source)
8fa7f6d @thierryvolpiatto * helm-plugin.el: Add comments, reorder.
thierryvolpiatto authored
58 `((init helm-p-candidates-file-init
6cbdbb4 @thierryvolpiatto * helm-plugin.el: new
thierryvolpiatto authored
59 ,@(let ((orig-init (assoc-default 'init source)))
9bc2702 @thierryvolpiatto Reindent all again.
thierryvolpiatto authored
60 (cond ((null orig-init) nil)
61 ((functionp orig-init) (list orig-init))
62 (t orig-init))))
6cbdbb4 @thierryvolpiatto * helm-plugin.el: new
thierryvolpiatto authored
63 (candidates-in-buffer)
64 ,@source)
bc4fb13 @thierryvolpiatto Finally reindent with the cl indentation behavior of 24.4.50.
thierryvolpiatto authored
65 source))
6cbdbb4 @thierryvolpiatto * helm-plugin.el: new
thierryvolpiatto authored
66 (add-to-list 'helm-compile-source-functions 'helm-compile-source--candidates-file)
67
8fa7f6d @thierryvolpiatto * helm-plugin.el: Add comments, reorder.
thierryvolpiatto authored
68 (defun helm-p-candidates-file-init ()
b82caa8 @thierryvolpiatto replace all cl symbol by their cl-lib equivalent.
thierryvolpiatto authored
69 (cl-destructuring-bind (file &optional updating)
6cbdbb4 @thierryvolpiatto * helm-plugin.el: new
thierryvolpiatto authored
70 (helm-mklist (helm-attr 'candidates-file))
71 (setq file (helm-interpret-value file))
6e0b27a @thierryvolpiatto * helm-plugin.el (helm-p-candidates-file-init): Don't use `helm-current-...
thierryvolpiatto authored
72 (with-current-buffer (helm-candidate-buffer 'global)
73 (insert-file-contents file)
6cbdbb4 @thierryvolpiatto * helm-plugin.el: new
thierryvolpiatto authored
74 (when updating
75 (buffer-disable-undo)
76 (font-lock-mode -1)
77 (auto-revert-mode 1)))))
78
79 (helm-document-attribute 'candidates-file "candidates-file plugin"
7eca6f0 * helm-plugin.el: Consistent formatting of doc-strings
Titus von der Malsburg authored
80 " Use a file as the candidates buffer.
6cbdbb4 @thierryvolpiatto * helm-plugin.el: new
thierryvolpiatto authored
81
7eca6f0 * helm-plugin.el: Consistent formatting of doc-strings
Titus von der Malsburg authored
82 1st argument is a filename, string or function name or variable
83 name. If optional 2nd argument is non-nil, the file is opened with
84 `auto-revert-mode' enabled.
8fa7f6d @thierryvolpiatto * helm-plugin.el: Add comments, reorder.
thierryvolpiatto authored
85
7eca6f0 * helm-plugin.el: Consistent formatting of doc-strings
Titus von der Malsburg authored
86 Example:
8fa7f6d @thierryvolpiatto * helm-plugin.el: Add comments, reorder.
thierryvolpiatto authored
87
7eca6f0 * helm-plugin.el: Consistent formatting of doc-strings
Titus von der Malsburg authored
88 \(defvar helm-source-test-file
89 '((name . \"test1\")
90 (candidates-file \"~/.emacs.el\" t)))
8fa7f6d @thierryvolpiatto * helm-plugin.el: Add comments, reorder.
thierryvolpiatto authored
91
7eca6f0 * helm-plugin.el: Consistent formatting of doc-strings
Titus von der Malsburg authored
92 Will list all lines in .emacs.el.")
6cbdbb4 @thierryvolpiatto * helm-plugin.el: new
thierryvolpiatto authored
93
054b96b @thierryvolpiatto * helm-plugin.el: Remove obsolete plugins.
thierryvolpiatto authored
94
8fa7f6d @thierryvolpiatto * helm-plugin.el: Add comments, reorder.
thierryvolpiatto authored
95 ;;; Plug-in: `persistent-help'
96 ;;
97 ;; Add help about persistent action in `helm-buffer' header.
6cbdbb4 @thierryvolpiatto * helm-plugin.el: new
thierryvolpiatto authored
98 (defun helm-compile-source--persistent-help (source)
4b8567d @thierryvolpiatto * helm-plugin.el: Fix header-line attr, the plugin shouldn't return nil.
thierryvolpiatto authored
99 (if (assoc 'header-line source)
100 source
101 (append source '((header-line . helm-persistent-help-string)))))
6cbdbb4 @thierryvolpiatto * helm-plugin.el: new
thierryvolpiatto authored
102 (add-to-list 'helm-compile-source-functions 'helm-compile-source--persistent-help)
103
104 (defun helm-persistent-help-string ()
5a765e6 @thierryvolpiatto * helm.el (helm-display-mode-line): Fix header-line-format.
thierryvolpiatto authored
105 (substitute-command-keys
106 (concat "\\<helm-map>\\[helm-execute-persistent-action]: "
107 (or (helm-interpret-value (helm-attr 'persistent-help))
108 (helm-aif (or (assoc-default
109 'persistent-action
110 (helm-get-current-source))
111 (assoc-default
112 'action (helm-get-current-source)))
113 (cond ((symbolp it)
114 (symbol-name it))
115 ((listp it)
116 (or (ignore-errors (caar it)) ""))))
117 "")
118 " (keeping session)")))
4f639c1 @thierryvolpiatto * helm-regexp.el: Move unused code to helm-plugin.el (#531).
thierryvolpiatto authored
119
054b96b @thierryvolpiatto * helm-plugin.el: Remove obsolete plugins.
thierryvolpiatto authored
120
121 ;;; Document new attributes
122 ;;
123 ;;
6cbdbb4 @thierryvolpiatto * helm-plugin.el: new
thierryvolpiatto authored
124 (helm-document-attribute 'persistent-help "persistent-help plug-in"
7eca6f0 * helm-plugin.el: Consistent formatting of doc-strings
Titus von der Malsburg authored
125 " A string to explain persistent-action of this source. It also
126 accepts a function or a variable name.")
6cbdbb4 @thierryvolpiatto * helm-plugin.el: new
thierryvolpiatto authored
127
128
129 (provide 'helm-plugin)
130
37b4201 @thierryvolpiatto Fix dependencies and autoloads. Reorder.
thierryvolpiatto authored
131 ;; Local Variables:
a7ee65b @thierryvolpiatto Disable compile warnings and add new keyword to helm.
thierryvolpiatto authored
132 ;; byte-compile-warnings: (not cl-functions obsolete)
37b4201 @thierryvolpiatto Fix dependencies and autoloads. Reorder.
thierryvolpiatto authored
133 ;; coding: utf-8
134 ;; indent-tabs-mode: nil
135 ;; End:
136
6cbdbb4 @thierryvolpiatto * helm-plugin.el: new
thierryvolpiatto authored
137 ;;; helm-plugin ends here
Something went wrong with that request. Please try again.