summary refs log tree commit diff stats
path: root/lisp/+tempo.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/+tempo.el')
-rw-r--r--lisp/+tempo.el44
1 files changed, 44 insertions, 0 deletions
diff --git a/lisp/+tempo.el b/lisp/+tempo.el new file mode 100644 index 0000000..2324665 --- /dev/null +++ b/lisp/+tempo.el
@@ -0,0 +1,44 @@
1;;; +tempo.el --- easier tempo definition -*- lexical-binding: t -*-
2
3(require 'tempo)
4
5;; TODO: I need to figure out where this function goes.
6(defun delete2 (list &rest elems)
7 "Delete each element of ELEMS, and the next item, from LIST."
8 (let ((r nil))
9 (while (consp list)
10 (if (member (car list) elems)
11 (setf list (cdr list))
12 (setf r (cons (car list) r)))
13 (setf list (cdr list)))
14 (reverse r)))
15
16(defmacro define-tempo (tag doc &rest elements)
17 "Define a template and add its tag to MODE's abbrev-table.
18TAG, DOC, and ELEMENTS are passed to `tempo-define-template', which see.
19ABBREV, if given, is the abbrev string to use for template expansion
20under MODE's abbrev-table. If ABBREV isn't given, TAG will be used."
21 (declare (indent 1))
22 (let* ((template (gensym))
23 (tag (cond ((stringp tag) tag)
24 ((symbolp tag) (symbol-name tag))
25 (t (user-error "TAG must be a string or symbol: %S" tag))))
26 (mode (or (plist-get elements :mode) nil))
27 (abbrev (or (plist-get elements :abbrev) tag))
28 (taglist (or (plist-get elements :taglist) nil))
29 (table (let ((tname (and mode (derived-mode-abbrev-table-name mode))))
30 (while (and tname (not (memq tname abbrev-table-name-list)))
31 (setq tname (and (get mode 'derived-mode-parent)
32 (derived-mode-abbrev-table-name
33 (get mode 'derived-mode-parent)))))
34 (or tname 'global-abbrev-table)))
35 (elements (delete2 elements :mode :abbrev :taglist)))
36 `(let ((,template (tempo-define-template ,tag
37 ',elements
38 ,tag
39 ,doc
40 ,taglist)))
41 (define-abbrev ,table ,tag "" ,template :system t)
42 (put ,template 'no-self-insert t))))
43
44(provide '+tempo)