-
Notifications
You must be signed in to change notification settings - Fork 1
/
dkl-boot.el
68 lines (53 loc) · 1.83 KB
/
dkl-boot.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
;; Basic functions needed to run my customizations.
;; Partly here so others can use things like dkl-mh-mailfilter.el and
;; dkl-mh-e-fixes.el.
;;;; this doesn't make any sense, since I haven't started using
;;;; the cl- versions of anything yet...
;;;(condition-case nil (require 'cl-lib)
;;; (error (require 'cl)))
(require 'cl)
(defun dkl:probe-file (file)
(when (file-exists-p file) file))
;; used???
(defun dkl:safe-require (name)
(condition-case ()
(let ((debug-on-error nil)) (require name))
(error (message "Failed to require %s" name))))
;; used???
(defun dkl:safe-load (path)
(condition-case ()
(let ((debug-on-error nil)) (load path))
(error (message "Failed to load %s" path))))
(defun dkl:byte-compile-file (filename &optional load)
(let ((elc (byte-compile-dest-file filename)))
(cond ((file-newer-than-file-p elc filename)
(when load (load elc)))
(t (byte-compile-file filename load)))))
(defun dkl:read-objects-from-string (string)
(let ((objects '())
(read-start 0)
x)
(while (condition-case c
(setq x (read-from-string string read-start))
(end-of-file nil)
(error (error "%s" c)))
(push (car x) objects)
(setq read-start (cdr x)))
(nreverse objects)))
(defun dkl:short-system-name ()
(let ((s (system-name)))
(if (string-match "\\([^.]+\\)\\(\\..*$\\)?" s)
(match-string 1 s)
(error "Could not determine short system-name from '%s'." s))))
(defun dkl:filter (predicate list)
(let ((result '()))
(dolist (item list)
(when (funcall predicate item)
(push item result)))
(nreverse result)))
(defun dkl:on-macosx-p ()
(string-match "darwin" (symbol-name system-type)))
(defun dkl:on-linux-p ()
(string-match "linux" (symbol-name system-type)))
(defun dkl:on-windows-p ()
(memq system-type '(windows-nt ms-windows ms-dos win386)))