forked from dimitri/el-get
-
Notifications
You must be signed in to change notification settings - Fork 0
/
el-get.el
3646 lines (3130 loc) · 132 KB
/
el-get.el
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;; el-get.el --- Manage the external elisp bits and pieces you depend upon
;;
;; Copyright (C) 2010 Dimitri Fontaine
;;
;; Author: Dimitri Fontaine <dim@tapoueh.org>
;; URL: http://www.emacswiki.org/emacs/el-get.el
;; Version: 2.2
;; Created: 2010-06-17
;; Keywords: emacs package elisp install elpa git git-svn bzr cvs svn darcs hg
;; apt-get fink pacman http http-tar emacswiki
;; Licence: WTFPL, grab your copy here: http://sam.zoy.org/wtfpl/
;;
;; This file is NOT part of GNU Emacs.
;;
;; Install
;; Please see the README.asciidoc file from the same distribution
;;; Commentary:
;;
;; Version String are now inspired by how Emacs itself numbers its version.
;; First is the major version number, then a dot, then the minor version
;; number. The minor version number is 0 when still developping the next
;; major version.
;;
;; So 2.0 is a developer release while 2.1 will be the next stable release.
;;
;; Please note that this versioning policy has been picked while backing
;; 1.2~dev, so 1.0 was a "stable" release in fact. Ah, history.
;;; Change Log:
;;
;; 3.0 - WIP - Get a fix
;;
;; - support fo package dependencies
;; - rely on package status for `el-get' to install and init them
;; - M-x el-get-list-packages
;; - support for :branch in git
;; - new recipes, galore
;; - bug fixes, byte compiling, windows compatibility, etc
;; - recipe files are now *.rcp rather than *.el (el still supported)
;;
;; 2.2 - 2011-05-26 - Fix the merge
;;
;; - Revert changes introduced by a merge done by mistake
;;
;; 2.1 - 2011-05-25 - Still growing, getting lazy
;;
;; - Add support for autoloads, per Dave Abrahams
;; - fix 'wait support for http (using sync retrieval)
;; - code cleanup per Dave Abrahams, lots of it
;; - add function M-x el-get-update-all
;; - Implement M-x el-get-make-recipes
;; - byte-compile at build time rather than at init time
;; - and use a "clean room" external emacs -Q for byte compiling
;; - allow to skip autoloads either globally or per-package
;; - better checks and errors for commands used when installing packages
;; - register `el-get-sources' against the custom interface
;; - el-get will now accept a list of sources to install or init
;; - open el-get-{install,init,remove,update} from `el-get-sources' only
;; - add :prepare and :post-init and :lazy, and `el-get-is-lazy'
;; - add support for :repo for ELPA packages
;;
;; 1.1 - 2010-12-20 - Nobody's testing until the release
;;
;; - Adapt to package.el from Emacs24 by using relative symlinks to ELPA
;; packages ((package-user-dir) is "~/.emacs.d/elpa" now, so needs to
;; get expanded at least)
;; - Allow to bypass byte compiling entirely with a single global var
;; - Have http local file default to something sane, not package.el
;; - Implement support for svn and darcs too
;; - Still more recipes
;; - Add support for the `pacman' package manager (ARCH Linux)
;; - Add support for mercurial
;; - (el-get 'sync) now really means synchronous, and serialized too
;; - el-get-start-process-list implements :sync, defaults to nil (async)
;; - Implement a :localname package property to help with some kind of URLs
;; - Add el-get-post-init-hooks
;; - Allow build commands to be evaluated, hence using some emacs variables
;; - Finaly walk the extra mile and remove "required" packages at install
;; - Implement support for the "Do you want to continue" apt-get prompt
;; - implement :before user defined function to run before init
;;
;; 1.0 - 2010-10-07 - Can I haz your recipes?
;;
;; - Implement el-get recipes so that el-get-sources can be a simple list
;; of symbols. Now that there's an authoritative git repository, where
;; to share the recipes is easy.
;; - Add support for emacswiki directly, save from having to enter the URL
;; - Implement package status on-disk saving so that installing over a
;; previously failed install is in theory possible. Currently `el-get'
;; will refrain from removing your package automatically, though.
;; - Fix ELPA remove method, adding a "removed" state too.
;; - Implement CVS login support.
;; - Add lots of recipes
;; - Add support for `system-type' specific build commands
;; - Byte compile files from the load-path entries or :compile files
;; - Implement support for git submodules with the command
;; `git submodule update --init --recursive`
;; - Add catch-all post-install and post-update hooks
;; - Add desktop notification on install/update.
;;
;; 0.9 - 2010-08-24 - build me a shell
;;
;; - have `el-get-build' use start-process-shell-command so that you can
;; pass-in shell commands. Beware of poor command argument "parsing"
;; though, done with a simple `split-string'.
;;
;; 0.8 - 2010-08-23 - listen to the users
;;
;; - implement :after user defined function to run at the end of init
;; - add CVS support (no login support)
;; - improve el-get-build to use async building
;; - fix el-get-update doing so
;;
;; 0.7 - 2010-08-23 - archive
;;
;; - http support is extended to `tar' archives, via the http-tar type
;;
;; 0.6 - 2010-08-12 - towards a stable version
;;
;; - fix when asynchronous http support call post-install-fun
;; - fix el-get-remove calling convention
;; - add support for bzr, thanks to Kevin Fletcher
;;
;; 0.5 - 2010-08-06 - release early, fix often
;;
;; - fix apt-get and fink install hooks to call el-get-dpkg-symlink
;; - fix elpa and http support to follow the new call convention
;; - use asynchronous url-retrieve facility so that http is async too
;;
;; 0.4 - 2010-08-04 - foxy release
;;
;; - support asynchronous processes for system commands
;; apt-get, fink, git and git-svn are run in background
;; - support `sudo' password prompts (classic and ubuntu variants)
;; - fix fink support
;; - ELPA support is an option so that you can install ELPA from el-get
;; - implement el-get-rmdir
;;; Code:
(require 'dired)
(require 'package nil t) ; that's ELPA, but you can use el-get to install it
(require 'cl) ; needed for `remove-duplicates'
(require 'simple) ; needed for `apply-partially'
(require 'bytecomp)
(require 'autoload)
(require 'help-mode) ; byte-compiling needs to know about xref-type buttons
(defgroup el-get nil "el-get customization group"
:group 'convenience)
(defconst el-get-version "3.0" "el-get version number")
(defcustom el-get-post-init-hooks nil
"Hooks to run after a package init.
Each hook is a unary function accepting a package"
:group 'el-get
:type 'hook)
(defcustom el-get-post-install-hooks nil
"Hooks to run after installing a package.
Each hook is a unary function accepting a package"
:group 'el-get
:type 'hook)
(defcustom el-get-post-update-hooks nil
"Hooks to run after updating a package.
Each hook is a unary function accepting a package"
:group 'el-get
:type 'hook)
(defcustom el-get-post-error-hooks nil
"Hooks to run after package installation fails.
Each hook is a binay function accepting a package and error data"
:group 'el-get
:type 'hook)
(defcustom el-get-byte-compile t
"Whether or not to byte-compile packages. Can be used to
disable byte-compilation globally, unless this process is not
controlled by `el-get' itself.
The cases when `el-get' loses control are with \"advanced\"
packaging systems (apt-get, fink, pacman, elpa) or when the
recipe contains a :build rule (using a Makefile for example)."
:group 'el-get
:type 'boolean)
(defcustom el-get-verbose nil
"Non-nil means print messages describing progress of el-get even for fast operations."
:group 'el-get
:type 'boolean)
(defun el-get-verbose-message (format &rest arguments)
(when el-get-verbose (apply 'message format arguments)))
(defcustom el-get-byte-compile-at-init nil
"Whether or not to byte-compile packages at init.
Turn this to t if you happen to update your packages from under
`el-get', e.g. doing `cd el-get-dir/package && git pull`
directly."
:group 'el-get
:type 'boolean)
(defcustom el-get-generate-autoloads t
"Whether or not to generate autoloads for packages. Can be used
to disable autoloads globally."
:group 'el-get
:type 'boolean)
(defcustom el-get-is-lazy nil
"Whether or not to defer evaluation of :post-init and :after
functions until libraries are required. Will also have el-get
skip the :load and :features properties when set. See :lazy to
force their evaluation on some packages only."
:group 'el-get
:type 'boolean)
(defcustom el-get-git-clone-hook nil
"Hook run after git clone."
:group 'el-get
:type 'hook)
(defcustom el-get-git-svn-clone-hook nil
"Hook run after git svn clone."
:group 'el-get
:type 'hook)
(defcustom el-get-bzr-branch-hook nil
"Hook run after bzr branch."
:group 'el-get
:type 'hook)
(defcustom el-get-cvs-checkout-hook nil
"Hook run after cvs checkout."
:group 'el-get
:type 'hook)
(defcustom el-get-svn-checkout-hook nil
"Hook run after svn checkout."
:group 'el-get
:type 'hook)
(defcustom el-get-darcs-get-hook nil
"Hook run after darcs get."
:group 'el-get
:type 'hook)
(defcustom el-get-apt-get-install-hook nil
"Hook run after apt-get install."
:group 'el-get
:type 'hook)
(defcustom el-get-apt-get-remove-hook nil
"Hook run after apt-get remove."
:group 'el-get
:type 'hook)
(defcustom el-get-fink-install-hook nil
"Hook run after fink install."
:group 'el-get
:type 'hook)
(defcustom el-get-fink-remove-hook nil
"Hook run after fink remove."
:group 'el-get
:type 'hook)
(defcustom el-get-elpa-install-hook nil
"Hook run after ELPA package install."
:group 'el-get
:type 'hook)
(defcustom el-get-elpa-remove-hook nil
"Hook run after ELPA package remove."
:group 'el-get
:type 'hook)
(defcustom el-get-http-install-hook nil
"Hook run after http retrieve."
:group 'el-get
:type 'hook)
(defcustom el-get-http-tar-install-hook nil
"Hook run after http-tar package install."
:group 'el-get
:type 'hook)
(defcustom el-get-pacman-install-hook nil
"Hook run after pacman install."
:group 'el-get
:type 'hook)
(defcustom el-get-pacman-remove-hook nil
"Hook run after pacman remove."
:group 'el-get
:type 'hook)
(defcustom el-get-hg-clone-hook nil
"Hook run after hg clone."
:group 'el-get
:type 'hook)
(defcustom el-get-methods
'(:git (:install el-get-git-clone
:install-hook el-get-git-clone-hook
:update el-get-git-pull
:remove el-get-rmdir)
:emacsmirror (:install el-get-emacsmirror-clone
:install-hook el-get-git-clone-hook
:update el-get-git-pull
:remove el-get-rmdir)
:git-svn (:install el-get-git-svn-clone
:install-hook el-get-git-svn-clone-hook
:update el-get-git-svn-update
:remove el-get-rmdir)
:bzr (:install el-get-bzr-branch
:install-hook el-get-bzr-branch-hook
:update el-get-bzr-pull
:remove el-get-rmdir)
:svn (:install el-get-svn-checkout
:install-hook el-get-svn-checkout-hook
:update el-get-svn-update
:remove el-get-rmdir)
:cvs (:install el-get-cvs-checkout
:install-hook el-get-cvs-checkout-hook
:update el-get-cvs-update
:remove el-get-rmdir)
:darcs (:install el-get-darcs-get
:install-hook el-get-darcs-get-hook
:update el-get-darcs-pull
:remove el-get-rmdir)
:apt-get (:install el-get-apt-get-install
:install-hook el-get-apt-get-install-hook
:update el-get-apt-get-install
:remove el-get-apt-get-remove
:remove-hook el-get-apt-get-remove-hook)
:fink (:install el-get-fink-install
:install-hook el-get-fink-install-hook
:update el-get-fink-install
:remove el-get-fink-remove
:remove-hook el-get-fink-remove-hook)
:elpa (:install el-get-elpa-install
:install-hook el-get-elpa-install-hook
:update el-get-elpa-update
:remove el-get-elpa-remove
:remove-hook el-get-elpa-remove-hook)
:http (:install el-get-http-install
:install-hook el-get-http-install-hook
:update el-get-http-install
:remove el-get-rmdir)
:ftp (:install el-get-http-install
:install-hook el-get-http-install-hook
:update el-get-http-install
:remove el-get-rmdir)
:emacswiki (:install el-get-emacswiki-install
:install-hook el-get-http-install-hook
:update el-get-emacswiki-install
:remove el-get-rmdir)
:http-tar (:install el-get-http-tar-install
:install-hook el-get-http-tar-install-hook
:update el-get-http-tar-install
:remove el-get-rmdir)
:pacman (:install el-get-pacman-install
:install-hook el-get-pacman-install-hook
:update el-get-pacman-install
:remove el-get-pacman-remove
:remove-hook el-get-pacman-remove-hook)
:hg (:install el-get-hg-clone
:install-hook el-get-hg-clone-hook
:update el-get-hg-pull
:remove el-get-rmdir))
"Register methods that el-get can use to fetch and update a given package.
The methods list is a PLIST, each entry has a method name
property which value is another PLIST, which must contain values
for :install, :install-hook, :update and :remove
properties. Those should be the elisp functions to call for doing
the named package action in the given method."
:type '(repeat (cons symbol function))
:group 'el-get)
(defconst el-get-script (or load-file-name buffer-file-name))
(defcustom el-get-dir "~/.emacs.d/el-get/"
"Path where to install the packages."
:group 'el-get
:type 'directory)
(defcustom el-get-recipe-path-emacswiki
(concat (file-name-directory el-get-dir) "el-get/recipes/emacswiki/")
"Define where to keep a local copy of emacswiki recipes"
:group 'el-get
:type 'directory)
(defcustom el-get-recipe-path
(list (concat (file-name-directory el-get-script) "recipes")
el-get-recipe-path-emacswiki)
"Define where to look for the recipes, that's a list of directories"
:group 'el-get
:type '(repeat (directory)))
(defcustom el-get-configs-dir nil
"Define where to look for init-pkgname.el configurations. Disabled if nil."
:group 'el-get
:type '(choice (const :tag "Off" nil) directory))
(defun el-get-package-user-init-file (package)
(expand-file-name (concat "init-" package ".el") el-get-configs-dir))
(defun el-get-recipe-dirs ()
"Return the elements of el-get-recipe-path that actually exist.
Used to avoid errors when exploring the path for recipes"
(reduce (lambda (dir result)
(if (file-directory-p dir) (cons dir result) result))
el-get-recipe-path :from-end t :initial-value nil))
;; recipe files are elisp data, you can't byte-compile or eval them on their
;; own, but having elisp indenting and colors make sense
(eval-and-compile
(add-to-list 'auto-mode-alist '("\\.rcp\\'" . emacs-lisp-mode)))
(defcustom el-get-status-file
(concat (file-name-as-directory el-get-dir) ".status.el")
"Define where to store and read the package statuses")
(defvar el-get-autoload-file
(concat (file-name-as-directory el-get-dir) ".loaddefs.el")
"Where generated autoloads are saved")
(defvar el-get-outdated-autoloads nil
"List of package names whose autoloads are outdated")
(defvar el-get-emacs (concat invocation-directory invocation-name)
"Where to find the currently running emacs, a facility for :build commands")
(defcustom el-get-apt-get (executable-find "apt-get")
"The apt-get executable."
:group 'el-get
:type 'file)
(defcustom el-get-apt-get-base "/usr/share/emacs/site-lisp"
"Where to link the el-get symlink to, /<package> will get appended."
:group 'el-get
:type 'directory)
(defcustom el-get-fink (executable-find "fink")
"The fink executable."
:group 'el-get
:type 'directory)
(defcustom el-get-svn (executable-find "svn")
"The svn executable."
:group 'el-get
:type 'file)
(defcustom el-get-fink-base "/sw/share/doc"
"Where to link the el-get symlink to, /<package> will get appended."
:group 'el-get
:type 'file)
(defcustom el-get-emacswiki-base-url
"http://www.emacswiki.org/emacs/download/%s.el"
"The base URL where to fetch :emacswiki packages"
:group 'el-get
:type 'string)
(defcustom el-get-emacswiki-elisp-index-url
"http://www.emacswiki.org/cgi-bin/wiki?action=index;match=%5C.(el%7Ctar)(%5C.gz)%3F%24"
"The emacswiki index URL of elisp pages"
:group 'el-get
:type 'string)
(defcustom el-get-emacswiki-elisp-index-base-url
"http://www.emacswiki.org/emacs/"
"The emacswiki base URL used in the index"
:group 'el-get
:type 'string)
(defcustom el-get-emacsmirror-base-url
"http://github.com/emacsmirror/%s.git"
"The base URL where to fetch :emacsmirror packages. Consider using
\"git://github.com/emacsmirror/%s.git\"."
:group 'el-get
:type '(choice (const "http://github.com/emacsmirror/%s.git")
(const "https://github.com/emacsmirror/%s.git")
(const "git://github.com/emacsmirror/%s.git")
string))
(defcustom el-get-pacman-base "/usr/share/emacs/site-lisp"
"Where to link the el-get symlink to, /<package> will get appended."
:group 'el-get
:type 'directory)
;; debian uses ginstall-info and it's compatible to fink's install-info on
;; MacOSX, so:
(defvar el-get-install-info (or (executable-find "ginstall-info")
(executable-find "install-info")))
;; we support notifications on darwin too, thanks to growlnotify
(defcustom el-get-growl-notify "/usr/local/bin/growlnotify"
"Absolute path of the growlnotify tool"
:group 'el-get
:type 'file)
(defconst el-get-build-recipe-body
'(choice :tag "Format"
(repeat :tag "List of shell commands"
(string :doc "Note: arguments will not be shell-quoted.
Choose `Evaluated expression' format for a more portable recipe" :format "%v%h"))
(sexp :tag "Evaluated expression" :format "%t: %v%h"
:value `(("./configure" ,(concat "--with-emacs=" el-get-emacs)) ("make") ("make" ("install")))
:doc "Evaluation should yield a list of lists.
Each sub-list, representing a single shell command, is expected to have
strings and/or lists as elements, sub-sub-lists can have string and/or
list elements, and so on. Each sub-list will be \"flattened\" to produce
a list of strings, each of which will be `shell-quote-argument'ed before
being sent to the underlying shell."
)
))
;;
;; Support for tracking package states
;;
(defvar el-get-pkg-state
(make-hash-table)
"A hash mapping el-get package name symbols to their installation states")
(defun el-get-package-state (package)
"Return the installation state of PACKAGE.
- nil indicates that installation of the package has not been requested
- 'installing indicates that the package's installation is in progress
- 'init indicates that the package has been initialized
- ('error . <data>) indicates that there was an installation error"
(gethash (el-get-as-symbol package) el-get-pkg-state))
(defun el-get-currently-installing-p (package)
(eq (el-get-package-state package) 'installing))
(defun el-get-currently-installing-packages ()
"Return the packages that are currently installing"
(loop
for pkg being the hash-keys of el-get-pkg-state
if (el-get-currently-installing-p pkg)
collect pkg))
(defun el-get-set-package-state (package state)
"Set the installation state of PACKAGE to STATE"
(puthash (el-get-as-symbol package) state el-get-pkg-state))
(defun el-get-mark-initialized (package)
"Record the fact that the given PACKAGE has been initialized."
(el-get-set-package-state package 'init))
(add-hook 'el-get-post-init-hooks 'el-get-mark-initialized)
(defun el-get-mark-removed (package)
"Record the fact that the given PACKAGE has been initialized."
(el-get-set-package-state package nil))
(add-hook 'el-get-post-remove-hooks 'el-get-mark-removed)
(defun el-get-mark-failed (package info)
"Record the fact that the given PACKAGE has failed to install
for reasons described in INFO."
(el-get-verbose-message "el-get-mark-failed: %s %s" package info)
(el-get-set-package-state package `(error ,info)))
(add-hook 'el-get-post-error-hooks 'el-get-mark-failed)
;;
;; "Fuzzy" data structure handling
;;
;; In el-get-sources, single elements are often allowed instead of a
;; list, and strings and symbols are often interchangeable.
;; Presumably it's easier for users who don't use the customization
;; interface to write such structures as raw elisp.
;;
;;; "Fuzzy" data structure conversion utilities
(defun el-get-as-string (symbol-or-string)
"If STRING-OR-SYMBOL is already a string, return it. Otherwise
convert it to a string and return that."
(if (stringp symbol-or-string) symbol-or-string
(symbol-name symbol-or-string)))
(defun el-get-as-symbol (string-or-symbol)
"If STRING-OR-SYMBOL is already a symbol, return it. Otherwise
convert it to a symbol and return that."
(if (symbolp string-or-symbol) string-or-symbol
(intern string-or-symbol)))
(defun el-get-as-list (element-or-list)
"If ELEMENT-OR-LIST is already a list, return it. Otherwise
returning a list that contains it (and only it)."
(if (listp element-or-list) element-or-list
(list element-or-list)))
;;; "Fuzzy" data structure customization widgets
(defun el-get-repeat-value-to-internal (widget element-or-list)
(el-get-as-list element-or-list))
(defun el-get-repeat-match (widget value)
(widget-editable-list-match widget (el-get-repeat-value-to-internal widget value)))
(define-widget 'el-get-repeat 'repeat
"A variable length list of non-lists that can also be represented as a single element"
:value-to-internal 'el-get-repeat-value-to-internal
:match 'el-get-repeat-match)
(defun el-get-symbol-match (widget value)
(or (symbolp value) (stringp value)))
(define-widget 'el-get-symbol 'symbol
"A string or a symbol, rendered as a symbol"
:match 'el-get-symbol-match
)
;;; END "Fuzzy" data structure support
(defun el-get-source-name (source)
"Return the package name (stringp) given an `el-get-sources'
entry."
(if (symbolp source) (symbol-name source)
(format "%s" (plist-get source :name))))
(defcustom el-get-sources nil
"Additional package recipes
Each entry is a PLIST where the following properties are
supported.
If your property list is missing the :type property, then it's
merged with the recipe one, so that you can override any
definition provided by `el-get' recipes locally.
:name
The name of the package. It can be different from the name of
the directory where the package is stored (after a `git
clone' for example, in which case a symlink will be created.
:depends
A single package name, or a list of package names, on which
the package depends. All of a packages dependencies will be
installed before the package is installed.
:pkgname
The name of the package for the underlying package management
system (`apt-get', `fink' or `pacman', also supported by
`emacsmirror'), which can be different from the Emacs package
name.
:type
The type of the package, currently el-get offers support for
`apt-get', `elpa', `git', `emacsmirror', `git-svn', `bzr' `svn',
`cvs', `darcs', `fink', `ftp', `emacswiki', `http-tar', `pacman',
`hg' and `http'. You can easily support your own types here,
see the variable `el-get-methods'.
:branch
Which branch to fetch when using `git'. Also supported in
the installer in `el-get-install'.
:url
Where to fetch the package, only meaningful for `git' and `http' types.
:build
Your build recipe, a list.
A recipe R whose `car' is not a string will be replaced
by (eval R).
Then, each element of the recipe will be interpreted as
a command:
* If the element is a string, it will be interpreted directly
by the shell.
* Otherwise, if it is a list, any list sub-elements will be
recursively \"flattened\" (see `el-get-flatten'). The
resulting strings will be interpreted as individual shell
arguments, appropriately quoted.
:build/system-type
Your specific build recipe for a given `system-type' gets
there and looks like :build.
:load-path
A directory or a list of directories you want `el-get' to add
to your `load-path'. Those directories are relative to where
the package gets installed.
:compile
Allow to restrict what to byte-compile: by default, `el-get'
will compile all elisp files in the :load-path directories,
unless a :build command exists for the package source. Given
a :compile property, `el-get' will only byte-compile those
given files, directories or filename-regexpes in the property
value. This property can be a `listp' or a `stringp' if you
want to compile only one of those.
:info
This string allows you to setup a directory where to find a
'package.info' file, or a path/to/whatever.info file. It will
even run `ginstall-info' for you to create the `dir' entry so
that C-h i will be able to list the newly installed
documentation. Note that you might need to kill (C-x k) your
info buffer then C-h i again to be able to see the new menu
entry.
:load
List of files to load, or a single file to load after having
installed the source but before `require'ing its features.
:features
List of features el-get will `require' for you.
:autoloads
Control whether el-get should generate autoloads for this
package. Setting this to nil prevents el-get from generating
autoloads for the package. Default is t. Setting this to a
string or a list of string will load the named autoload
files.
:library
When using :after but not using :features, :library allows to
set the library against which to register the :after function
against `eval-after-load'. It defaults to either :pkgname
or :package, in this order. See also `el-get-eval-after-load'.
:options
Currently used by http-tar and cvs support.
When using http-tar, it allows you to give the tar options
you want to use. Typically would be \"xzf\", but you might
want to choose \"xjf\" for handling .tar.bz files e.g.
When using CVS, when it's set to \"login\", `el-get' will
first issue a `cvs login' against the server, asking you
interactively (in the minibuffer) any password you might to
enter, and only then it will run the `cvs checkout' command.
:module
Currently only used by the `cvs' support, allow you to
configure the module you want to checkout in the given URL.
:repo
Only used by the `elpa' support, a cons cell with the
form (NAME . URL), as in `package-archives'. If the package
source only specifies a URL, the URL will be used for NAME as
well.
:prepare
Intended for use from recipes, it will run once both the
`Info-directory-list' and the `load-path' variables have been
taken care of, but before any further action from
`el-get-init'.
:before
A pre-init function to run once before `el-get-init' calls
`load' and `require'. It gets to run with `load-path'
already set, and after :prepare has been called. It's not
intended for use from recipes.
:post-init
Intended for use from recipes. This function is registered
for `eval-after-load' against the recipe library by
`el-get-init' once the :load and :features have been setup.
:after
A function to register for `eval-after-load' against the
recipe library, after :post-init. That's not intended for
recipe use.
:lazy
Default to nil. Allows to override `el-get-is-lazy' per
package.
:localname
Currently only used by both `http' and `ftp' supports, allows
to specify the target name of the downloaded file.
This option is useful if the package should be retrieved using
a presentation interface (such as as web SCM tool).
For example, destination should be set to \"package.el\" if
the package url has the following scheme:
\"http://www.example.com/show-as-text?file=path/package.el\"
:website
The website of the project.
:description
A short description of the project.
"
:type
`(repeat
(choice
:tag "Entry"
:value (:name "")
(el-get-symbol :tag "Name of EL-Get Package")
(list
:tag "Full Recipe (or Recipe Override)"
(group :inline t :tag "EL-Get Package Name" :format "%t: %v"
(const :format "" :name) (el-get-symbol :format "%v"))
(set
:inline t :format "%v\n"
(group
:inline t (const :format "" :depends)
(el-get-repeat
:tag "Names of packages on which this one depends" el-get-symbol))
(group
:inline t :format "%t: %v%h"
:tag "Underlying Package Name"
:doc "When there is an underlying package manager (e.g. `apt')
this is the name to fetch in that system"
(const :format "" :pkgname) (string :format "%v"))
(group
:inline t :tag "Type" :format "%t: %v%h"
:doc "(If omitted, this recipe provides overrides for one in recipes/)"
(const :format "" :type)
,(append '(choice :value emacswiki :format "%[Value Menu%] %v"
)
;; A sorted list of method names
(sort
(reduce
(lambda (r e)
(if (symbolp e)
(cons
(list 'const
(intern (substring (prin1-to-string e) 1)))
r)
r))
el-get-methods
:initial-value nil)
(lambda (x y)
(string< (prin1-to-string (cadr x))
(prin1-to-string (cadr y)))))))
(group :inline t :format "Source URL: %v"
(const :format "" :url) (string :format "%v"))
(group :inline t :format "Package Website: %v"
(const :format "" :website) (string :format "%v"))
(group :inline t :format "Description: %v"
(const :format "" :description) (string :format "%v"))
(group :inline t :format "General Build Recipe\n%v"
(const :format "" :build) ,el-get-build-recipe-body)
(group :inline t (const :format "" :load-path)
(el-get-repeat
:tag "Subdirectories to add to load-path" directory))
(group :inline t (const :format "" :compile)
(el-get-repeat
:tag "File/directory regexps to compile" regexp))
(group :inline t :format "%v" (const :format "" :info)
(string :tag "Path to .info file or to its directory"))
(group :inline t (const :format "" :load)
(el-get-repeat :tag "Relative paths to force-load" string))
(group :inline t :format "%v" (const :format "" :features)
(repeat :tag "Features to `require'" el-get-symbol))
(group :inline t :format "Autoloads: %v" :value (:autoloads t)
(const :format "" :autoloads)
(choice
:tag "Type"
(boolean :format "generation %[Toggle%] %v\n")
(el-get-repeat
:tag "Relative paths to force-load" string)))
(group :inline t :format "Options (`http-tar' and `cvs' only): %v"
(const :format "" :options) (string :format "%v"))
(group :inline t :format "CVS Module: %v"
(const :format "" :module)
(string :format "%v"))
(group :inline t :format "`Prepare' Function: %v"
(const :format "" :prepare) (function :format "%v"))
(group :inline t :format "`Post-Init' Function: %v"
(const :format "" :post-init) (function :format "%v"))
(group :inline t
:format "Name of downloaded file (`http' and `ftp' only): %v"
(const :format "" :localname) (string :format "%v"))
(group :inline t :format "Lazy: %v" :value (:lazy t)
(const :format "" :lazy) (boolean :format "%[Toggle%] %v\n"))
(group :inline t
:format "Repository specification (`elpa' only): %v"
(const :format "" :repo)
(cons :format "\n%v"
(string :tag "Name")
(string :tag "URL")))
(group :inline t
:format "`Before' Function (`Prepare' recommended instead): %v"
(const :format "" :before) (function :format "%v"))
(group :inline t
:format "`After' Function (`Post-Init' recommended instead): %v"
(const :format "" :after) (function :format "%v")))
(repeat
:inline t :tag "System-Specific Build Recipes"
(group :inline t
(symbol :value ,(concat ":build/"
(prin1-to-string system-type))
:format "Build Tag: %v%h"
:doc "Must be of the form `:build/<system-type>',
where `<system-type>' is the value of `system-type' on
platforms where this recipe should apply"
)
,el-get-build-recipe-body))))))
(defun el-get-flatten (arg)
"Return a version of ARG as a one-level list
(el-get-flatten 'x) => '(x)
(el-get-flatten '(a (b c (d)) e)) => '(a b c d e)"
(if (listp arg)
(apply 'append (mapcar 'el-get-flatten arg))
(list arg)))
(defun el-get-load-path (package)
"Return the list of absolute directory names to be added to
`load-path' by the named PACKAGE."
(let* ((source (el-get-package-def package))
(el-path (el-get-flatten (or (plist-get source :load-path) ".")))
(pkg-dir (el-get-package-directory package)))
(mapcar (lambda (p) (expand-file-name p pkg-dir)) el-path)))
(defun el-get-method (method-name action)
"Return the function to call for doing action (e.g. install) in
given method."
(let* ((method (intern (concat ":" (format "%s" method-name))))
(actions (plist-get el-get-methods method)))
(plist-get actions action)))
(defun el-get-check-init ()
"Check that we can run el-get."
(unless (file-directory-p el-get-dir)
(make-directory el-get-dir)))
(defun el-get-package-directory (package)
"Return the absolute directory name of the named PACKAGE."
(file-name-as-directory
(expand-file-name package (expand-file-name el-get-dir))))
(defun el-get-add-path-to-list (package list path)
"(add-to-list LIST PATH) checking for path existence within
given package directory."
(let* ((pdir (el-get-package-directory package))
(fullpath (expand-file-name (or path ".") pdir)))
(unless (file-directory-p fullpath)
(error "el-get could not find directory `%s' for package %s, at %s"
path package fullpath))
(add-to-list list fullpath)))
(defun el-get-package-exists-p (package)
"Return true only when the given package name is either a
directory or a symlink in el-get-dir."
(let ((pdir (el-get-package-directory package)))
;; seems overkill as file-directory-p will always be true
(or (file-directory-p pdir)
(file-symlink-p pdir))))
;;
;; generic one-shot event support
;;
(defvar el-get-generic-event-tasks (make-hash-table :test 'equal)
"A hash mapping event triggers to lists of functions to be called")
(defun el-get-generic-event-occurred (event &optional data)
"Fire all tasks added for the given EVENT (a hash key), passing DATA."
(let (tasks)
(while (setq tasks (gethash event el-get-generic-event-tasks))
(puthash event (cdr tasks) el-get-generic-event-tasks)
(ignore-errors (funcall (car tasks) data)))))