forked from hasu/notdeft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
notdeft-install.el
68 lines (57 loc) · 2.18 KB
/
notdeft-install.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
;;; notdeft-install.el --- NotDeft installer -*- lexical-binding: t; -*-
;; Copyright (C) 2020 by the authors.
;; All rights reserved.
;; Author: Tero Hasu <[email protected]>
;; See "notdeft.el" for licensing information.
;;; Commentary:
;; Functionality for setting up NotDeft from its source distribution,
;; without using a package manager.
;;
;; Suggested use:
;; (require 'notdeft-install)
;; (notdeft-install)
;;; Code:
(require 'autoload)
(require 'bytecomp)
(declare-function notdeft-xapian-make-program "notdeft-xapian-make")
(defun notdeft-install-autoloads ()
"Generate NotDeft autoloads and load them."
(let ((home (file-name-directory
(locate-library "notdeft-install"))))
(let ((generated-autoload-file
(expand-file-name "notdeft-autoloads.el" home)))
(update-directory-autoloads home))
(load "notdeft-autoloads.el" nil nil t)))
(defun notdeft-install-bytecode (&optional force)
"Generate NotDeft Emacs Lisp \".elc\" files.
Optionally FORCE byte-compilation even when existing bytecode
files appear to be up-to-date."
(let ((dir (file-name-directory
(locate-library "notdeft-install"))))
(notdeft-install--byte-compile dir "./" t force)
(notdeft-install--byte-compile dir "extras/" nil force)))
(defun notdeft-install--byte-compile (dir subdir must force)
"Byte-compile NotDeft sources in DIR SUBDIR.
If so indicated, the directory MUST exist. Optionally FORCE the
compilation."
(let ((home (expand-file-name subdir dir)))
(when (or must (file-exists-p home))
(let ((files (directory-files home nil "^notdeft.*\\.el$")))
(dolist (file files)
(unless (member file '("notdeft-autoloads.el"
"notdeft-example.el"))
(let ((file (concat home file)))
(byte-recompile-file file force 0))))))))
;;;###autoload
(defun notdeft-install (&optional force)
"Generate NotDeft autoloads and binaries.
Optionally FORCE byte-compilation even when existing bytecode
files appear to be up-to-date."
(interactive "P")
(notdeft-install-autoloads)
(require 'notdeft-autoloads)
(notdeft-install-bytecode force)
(require 'notdeft-xapian-make)
(notdeft-xapian-make-program force))
(provide 'notdeft-install)
;;; notdeft-install.el ends here