File: anything-auto-install.el

package info (click to toggle)
anything-el 1.287-2.1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, sid, stretch
  • size: 824 kB
  • sloc: lisp: 13,158; sh: 43; makefile: 3
file content (222 lines) | stat: -rw-r--r-- 7,213 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
;;; anything-auto-install.el --- Integrate auto-install.el with anything.el

;; Filename: anything-auto-install.el
;; Description: Integrate auto-install.el with anything.el
;; Author: Andy Stewart <lazycat.manatee@gmail.com>
;; Maintainer: Andy Stewart <lazycat.manatee@gmail.com>
;; Copyright (C) 2009, Andy Stewart, all rights reserved.
;; Copyright (C) 2010, rubikitch, all rights reserved.
;; Created: 2009-02-09 17:48:01
;; Version: 0.2.3
;; Last-Updated: [2010/03/29 18:08]
;;           By: rubikitch
;; URL: http://www.emacswiki.org/emacs/download/anything-auto-install.el
;; Keywords: auto-install, anything
;; Compatibility: GNU Emacs 23.0.60.1
;;
;; Features that might be required by this library:
;;
;; `auto-install' `anything'
;;

;;; This file is NOT part of GNU Emacs

;;; 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, 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; see the file COPYING.  If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.

;;; Commentary:
;;
;; Integrate auto-install.el with anything.el.
;;
;; You can use command `anything-auto-install-from-emacswiki'
;; install package from EmacsWiki.org.
;;
;; You can use comamnd `anything-auto-install-from-library'
;; update library.
;;
;; You can also make this package integrate with `anything',
;; just setup like below:
;;
;; (setq anythign-sources
;;       (list
;;        anything-c-source-auto-install-from-emacswiki
;;        anything-c-source-auto-install-from-library
;;        ))
;;

;;; Commands:
;;
;; Below are complete command list:
;;
;;  `anything-auto-install-from-emacswiki'
;;    Launch anything with auto-install separately.
;;  `anything-auto-install-from-library'
;;    Update library with `anything'.
;;  `anything-auto-install-batch'
;;    Batch install elisp libraries.
;;  `anything-auto-install'
;;    All-in-one command for elisp installation.
;;
;;; Customizable Options:
;;
;; Below are customizable option list:
;;

;;; Installation:
;;
;; Put anything-auto-install.el to your load-path.
;; The load-path is usually ~/elisp/.
;; It's set in your ~/.emacs like this:
;; (add-to-list 'load-path (expand-file-name "~/elisp"))
;;
;; And the following to your ~/.emacs startup file.
;;
;; (require 'anything-auto-install)
;;
;; And this package need `auto-install' and `anything',
;; make sure you have add package `auto-install' `auto-install'
;; in your load-path.
;;

;;; Customize:
;;
;;
;;
;; All of the above can customize by:
;;      M-x customize-group RET anything-auto-install RET
;;

;;; Change log:
;;
;; 2009/05/30
;;      * All-in-one install command `anything-auto-install'.
;;
;; 2009/05/27
;;      * Support batch install.
;;
;; 2009/02/17
;;      * Clean up.
;;
;; 2009/02/12
;;      * Add `anything-c-source-auto-install-from-library'
;;      * Add new command `anything-auto-install-from-library'.
;;
;; 2009/02/09
;;      * First released.
;;

;;; Acknowledgements:
;;
;;
;;

;;; TODO
;;
;;
;;

;;; Require
(require 'anything)
(require 'auto-install)

;;; Code:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Variable ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar anything-c-source-auto-install-from-emacswiki
  '((name . "Auto Install from EmacsWiki")
    (candidates . (lambda ()
                    (auto-install-update-emacswiki-package-name t)
                    auto-install-package-name-list))
    (action . (("Install from EmacsWiki.org" . (lambda (candidate)
                                                 (auto-install-download (concat auto-install-emacswiki-base-url candidate))))
               ("Update package name from EmacsWiki.org" . (lambda (candidate)
                                                             (auto-install-update-emacswiki-package-name)))))))
(defvar anything-c-source-auto-install-from-library
  '((name . "Auto Install from Library")
    (init . (anything-auto-install-init))
    (candidates-in-buffer)
    (action . (("Update library" . (lambda (candidate)
                                     (auto-install-from-library candidate)))))))

(defvar anything-c-source-auto-install-batch
  '((name . "Auto Install Batch")
    (candidates . (lambda ()
                    (mapcar 'car auto-install-batch-list)))
    (action . (("Batch Install Emacs Extension" . (lambda (candidate)
                                                    (auto-install-batch candidate)))))))

(defvar anything-c-source-auto-install-from-url
  '((name . "Auto Install from URL")
    (dummy)
    (action . (("Install from URL" . (lambda (candidate)
                                       (auto-install-from-url candidate)))))))

(defvar anything-c-source-auto-install-from-gist
  '((name . "Auto Install from Gist")
    (dummy)
    (action . (("Install from Gist" . (lambda (candidate)
                                        (auto-install-from-gist candidate)))))))

(defvar anything-auto-install-buffer "*anything auto install*")


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Interactive Functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun anything-auto-install-from-emacswiki (&optional file)
  "Launch anything with auto-install separately."
  (interactive)
  (if file
      (auto-install-from-emacswiki file)
    (anything 'anything-c-source-auto-install-from-emacswiki
            nil nil nil nil anything-auto-install-buffer)))

(defun anything-auto-install-from-library ()
  "Update library with `anything'."
  (interactive)
  (anything 'anything-c-source-auto-install-from-library
            nil nil nil nil anything-auto-install-buffer))

(defun anything-auto-install-batch ()
  "Batch install elisp libraries."
  (interactive)
  (anything `anything-c-source-auto-install-batch
            nil nil nil nil anything-auto-install-buffer))

(defun anything-auto-install ()
  "All-in-one command for elisp installation."
  (interactive)
  (anything '(anything-c-source-auto-install-batch
              anything-c-source-auto-install-from-emacswiki
              anything-c-source-auto-install-from-library
              anything-c-source-auto-install-from-url
              anything-c-source-auto-install-from-gist)
            nil nil nil nil anything-auto-install-buffer))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Uilties Functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun anything-auto-install-init ()
  "Init anything buffer status."
  (let ((anything-buffer (anything-candidate-buffer 'global))
        (library-list (auto-install-get-library-list)))
    (with-current-buffer anything-buffer
      ;; Insert library.
      (dolist (library library-list)
        (insert (format "%s\n" library)))
      ;; Sort lines.
      (sort-lines nil (point-min) (point-max)))))

(provide 'anything-auto-install)

;;; anything-auto-install.el ends here