diff options
Diffstat (limited to 'lisp/acdw.el')
-rw-r--r-- | lisp/acdw.el | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/lisp/acdw.el b/lisp/acdw.el index f039540..6e298b2 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el | |||
@@ -28,6 +28,36 @@ the filesystem, unless INHIBIT-MKDIR is non-nil." | |||
28 | (make-directory (file-name-directory file-name) :parents)) | 28 | (make-directory (file-name-directory file-name) :parents)) |
29 | file-name)))) | 29 | file-name)))) |
30 | 30 | ||
31 | ;;; Evaluating things after other things | ||
32 | |||
33 | |||
34 | (defun eval-after-init (fn) | ||
35 | "Evaluate FN after inititation, or now if Emacs is initialized. | ||
36 | FN is called with no arguments." | ||
37 | (if after-init-time | ||
38 | (funcall fn) | ||
39 | (add-hook 'after-init-hook fn))) | ||
40 | |||
41 | (defmacro eval-after (features &rest body) | ||
42 | "Evaluate BODY, but only after loading FEATURES. | ||
43 | FEATURES can be an atom or a list; as an atom it works like | ||
44 | `with-eval-after-load'. The special feature `init' will evaluate | ||
45 | BODY after Emacs is finished initializing." | ||
46 | (declare (indent 1) | ||
47 | (debug (form def-body))) | ||
48 | (unless (listp features) | ||
49 | (setf features (list features))) | ||
50 | (if (null features) | ||
51 | (macroexp-progn body) | ||
52 | (let* ((this (car features)) | ||
53 | (rest (cdr features))) | ||
54 | (cond ((eq this 'init) | ||
55 | `(eval-after-init | ||
56 | (lambda () (eval-after ,rest ,@body)))) | ||
57 | (:else | ||
58 | `(with-eval-after-load ',this | ||
59 | (eval-after ,rest ,@body))))))) | ||
60 | |||
31 | ;;; Convenience functions | 61 | ;;; Convenience functions |
32 | 62 | ||
33 | (defun define-key* (maps &rest keydefs) | 63 | (defun define-key* (maps &rest keydefs) |
@@ -58,7 +88,7 @@ not a list, return a one-element list containing OBJECT." | |||
58 | (defun add-to-list* (lists &rest things) | 88 | (defun add-to-list* (lists &rest things) |
59 | "Add THINGS to LISTS. | 89 | "Add THINGS to LISTS. |
60 | LISTS can be one list variable or a list. Each thing of THINGS | 90 | LISTS can be one list variable or a list. Each thing of THINGS |
61 | can be either a variablel (the thing), or a list of the form | 91 | can be either a variable (the thing), or a list of the form |
62 | (ELEMENT &optional APPEND COMPARE-FN), which is passed to | 92 | (ELEMENT &optional APPEND COMPARE-FN), which is passed to |
63 | `add-to-list'." | 93 | `add-to-list'." |
64 | (declare (indent 1)) | 94 | (declare (indent 1)) |
@@ -180,9 +210,10 @@ When joining, this command deletes whitespace." | |||
180 | (delete-indentation 1) | 210 | (delete-indentation 1) |
181 | (funcall (if visual-line-mode #'kill-visual-line #'kill-line) arg))) | 211 | (funcall (if visual-line-mode #'kill-visual-line #'kill-line) arg))) |
182 | 212 | ||
183 | (defun other-window|switch-buffer () | 213 | (defun other-window|switch-buffer (arg) |
184 | "Call `other-window' or `switch-buffer' depending on windows." | 214 | "Call `other-window' or `switch-buffer' depending on windows. |
185 | (interactive) | 215 | When called with prefix ARG, unconditionally switch buffer." |
186 | (if (one-window-p) | 216 | (interactive "P") |
187 | (switch-to-buffer nil) | 217 | (if (or arg (one-window-p)) |
218 | (switch-to-buffer (other-buffer) nil t) | ||
188 | (other-window 1))) | 219 | (other-window 1))) |