-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.el
65 lines (61 loc) · 2.2 KB
/
utils.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
(defun toggle-comment-on-line ()
"comment or uncomment current line"
(interactive)
(comment-or-uncomment-region (line-beginning-position) (line-end-position)))
(defun what-face (pos)
"Show the face at the current position"
(interactive "d")
(let ((face (or (get-char-property (point) 'read-face-name)
(get-char-property (point) 'face))))
(if face (message "Face: %s" face) (message "No face at %d" pos))))
;; the source code of keyboard_leds can be found at
;; http://osxbook.com/book/bonus/chapter10/kbdleds/
;; Could enable by
;; (setq ring-bell-function caps-bell)
(defun caps-bell
(call-process-shell-command "keyboard_leds -c1; keyboard_leds -c0" nil 0 nil))
(defun ensure-package-installed (&rest packages)
"Download the package if it were not installed"
(mapcar
(lambda (package)
(if (not (package-installed-p package))
(progn
(package-refresh-contents)
(package-install package))))
packages))
;; Usage
;; (setq org-publish-project-alist
;; (build-org-publish-alist
;; '((notes "~/notes" "/var/www/html")
;; (org-math "~/org-math"))))
(defun build-org-publish-alist (lst)
(apply
#'append
(mapcar
(lambda (lst)
(let* ((project-org (concat (symbol-name (car lst)) "-org-files"))
(project-assets (concat (symbol-name (car lst)) "-assets"))
(base-dir (cadr lst))
(publishing-dir
(if (caddr lst)
(caddr lst)
(concat (file-name-as-directory base-dir)))))
(list
(list
project-org
:base-directory base-dir
:auto-sitemap t
:publishing-directory publishing-dir
:publishing-function 'org-html-publish-to-html)
(list
project-assets
:base-directory base-dir
:recursive 't
:exclude "public_html\\|org-html-themes\\|[.]git"
:base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
:publishing-directory publishing-dir
:publishing-function 'org-publish-attachment)
(list (symbol-name (car lst))
:components
(list project-org project-assets)))))
lst)))