summaryrefslogtreecommitdiffstats
path: root/.emacs.d
diff options
context:
space:
mode:
authorGravatar Tom Willemse2013-12-30 13:07:11 +0100
committerGravatar Tom Willemse2013-12-30 13:07:11 +0100
commit730ebf26a902d94bdf56e28e70409f6f0a4fa7a5 (patch)
tree08a8078dca90145efa8b270e4dbd175e003e9ab6 /.emacs.d
parent13b91519fe2e639cb8fea572cf6df597e838023b (diff)
downloademacs-730ebf26a902d94bdf56e28e70409f6f0a4fa7a5.tar.gz
emacs-730ebf26a902d94bdf56e28e70409f6f0a4fa7a5.zip
Reorder macros
Diffstat (limited to '.emacs.d')
-rw-r--r--.emacs.d/init.el111
1 files changed, 56 insertions, 55 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el
index 38cffa4..c917f0b 100644
--- a/.emacs.d/init.el
+++ b/.emacs.d/init.el
@@ -2,7 +2,7 @@
;;; Commentary:
;;; Code:
-;;;; defmacro
+;;;; Macros
(defmacro stante-after (feature &rest forms)
"After FEATURE is loaded, evaluate FORMS.
@@ -22,11 +22,66 @@ FEATURE may be an unquoted feature symbol or a file name, see
(eval-after-load ',feature
`(funcall (function ,(lambda () ,@forms)))))))
+(defmacro oni:email (user at host dot com)
+ "Turn arguments into an email address.
+The resulting email address will look like: USER@HOST.COM, AT and
+DOT are intentionally being skipped."
+ (ignore at dot)
+ (concat (symbol-name user) "@" (symbol-name host) "."
+ (symbol-name com)))
+
(defmacro eval-after-init (&rest body)
"Defer execution of BODY until after Emacs init."
(declare (indent 0))
`(add-hook 'emacs-startup-hook #'(lambda () ,@body)))
+(defmacro link-modes (mode1 mode2)
+ "Whenever MODE1 is started, also start MODE2. Same for stopping.
+
+If INVERSE is specified, make sure MODE2 is turned off whenever
+MODE1 is enabled and vice-versa."
+ (let* ((mode1-name (symbol-name mode1))
+ (mode2-name (symbol-name mode2))
+ (function-name (intern (concat "toggle-" mode2-name
+ "-by-" mode1-name))))
+ `(progn
+ (defun ,function-name ()
+ ,(concat "Toggle `" mode2-name "' according to the variable `"
+ mode1-name "'.")
+ (,mode2 (or ,mode1 -1)))
+ (add-hook ',(intern (concat mode1-name "-hook"))
+ #',function-name))))
+
+(defmacro make-modes-exclusive (mode1 mode2)
+ "Whenever MODE1 is started, stop MODE2. Switch for stopping."
+ (let* ((mode1-name (symbol-name mode1))
+ (mode2-name (symbol-name mode2))
+ (function-name
+ (intern (concat "toggle-" mode2-name
+ "-inverse-of-" mode1-name))))
+ `(progn
+ (defvar ,mode1)
+ (defun ,function-name ()
+ ,(concat "Toggle `" mode2-name
+ "' according to the inverse of `" mode1-name "'.")
+ (,mode2 (or (not ,mode1) -1)))
+ (add-hook ',(intern (concat mode1-name "-hook"))
+ #',function-name))))
+
+(defmacro mode-hooks (&rest lst)
+ "Apply `add-mode-hooks' to each element of LST."
+ (declare (indent 0))
+ `(progn
+ ,@(level (mapcar
+ #'(lambda (itm)
+ (add-mode-hooks (car itm) (list 'quote (cadr itm)))) lst))))
+
+(defmacro stumpwm (&rest body)
+ "Execute BODY in stumpwm."
+ (declare (indent 0))
+ `(call-process init-stumpish-program nil nil nil
+ ,(format "eval '%S'" `(progn ,@body))))
+
(defmacro turn-off (&rest modes)
"Turn off each mode in MODES."
`(progn ,@(mapcar (lambda (m) `(,m -1)) modes)))
@@ -158,12 +213,6 @@ FEATURE may be an unquoted feature symbol or a file name, see
ad-do-it
(error (stumpwm-command (format "move-focus %s" (ad-get-arg 0))))))
-(defmacro stumpwm (&rest body)
- "Execute BODY in stumpwm."
- (declare (indent 0))
- `(call-process init-stumpish-program nil nil nil
- ,(format "eval '%S'" `(progn ,@body))))
-
(global-set-key (kbd "C-c S") #'split-window-right)
(global-set-key (kbd "C-c s") #'split-window-below)
(global-set-key (kbd "C-c Q") #'delete-other-windows)
@@ -304,14 +353,6 @@ FEATURE may be an unquoted feature symbol or a file name, see
For `python-mode' I prefer `python-imenu-create-flat-index'."
(setq imenu-create-index-function #'python-imenu-create-flat-index))
-(defmacro mode-hooks (&rest lst)
- "Apply `add-mode-hooks' to each element of LST."
- (declare (indent 0))
- `(progn
- ,@(level (mapcar
- #'(lambda (itm)
- (add-mode-hooks (car itm) (list 'quote (cadr itm)))) lst))))
-
(eval-and-compile
(defun add-hooks (hooks function &optional append local)
"`add-hook' for each in HOOKS."
@@ -407,38 +448,6 @@ Also change directories to current working directory."
"Turn on option `compilation-shell-minor-mode' for `pony-minor-mode'."
(add-hook 'pony-minor-mode-hook 'compilation-shell-minor-mode nil t))
-(defmacro link-modes (mode1 mode2)
- "Whenever MODE1 is started, also start MODE2. Same for stopping.
-
-If INVERSE is specified, make sure MODE2 is turned off whenever
-MODE1 is enabled and vice-versa."
- (let* ((mode1-name (symbol-name mode1))
- (mode2-name (symbol-name mode2))
- (function-name (intern (concat "toggle-" mode2-name
- "-by-" mode1-name))))
- `(progn
- (defun ,function-name ()
- ,(concat "Toggle `" mode2-name "' according to the variable `"
- mode1-name "'.")
- (,mode2 (or ,mode1 -1)))
- (add-hook ',(intern (concat mode1-name "-hook"))
- #',function-name))))
-
-(defmacro make-modes-exclusive (mode1 mode2)
- "Whenever MODE1 is started, stop MODE2. Switch for stopping."
- (let* ((mode1-name (symbol-name mode1))
- (mode2-name (symbol-name mode2))
- (function-name
- (intern (concat "toggle-" mode2-name
- "-inverse-of-" mode1-name))))
- `(progn
- (defun ,function-name ()
- ,(concat "Toggle `" mode2-name
- "' according to the inverse of `" mode1-name "'.")
- (,mode2 (or (not ,mode1) -1)))
- (add-hook ',(intern (concat mode1-name "-hook"))
- #',function-name))))
-
(stante-after appt
(setq appt-disp-window-function #'oni:appt-display-window-and-jabber)
(setq appt-display-diary nil))
@@ -923,14 +932,6 @@ Depending on the value of `buffer-narrowed-p'."
(load custom-file)
-(defmacro oni:email (user at host dot com)
- "Turn arguments into an email address.
-The resulting email address will look like: USER@HOST.COM, AT and
-DOT are intentionally being skipped."
- (ignore at dot)
- (concat (symbol-name user) "@" (symbol-name host) "."
- (symbol-name com)))
-
(defun oni:after-save-func ()
"Function for `after-save-hook'."
(executable-make-buffer-file-executable-if-script-p)