summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.emacs.d/init.el110
1 files changed, 88 insertions, 22 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el
index 90fdd48..4301ab4 100644
--- a/.emacs.d/init.el
+++ b/.emacs.d/init.el
@@ -27,6 +27,10 @@ FEATURE may be an unquoted feature symbol or a file name, see
(declare (indent 0))
`(add-hook 'emacs-startup-hook #'(lambda () ,@body)))
+(defmacro turn-off (&rest modes)
+ "Turn off each mode in MODES."
+ `(progn ,@(mapcar (lambda (m) `(,m -1)) modes)))
+
;;;; defun
(eval-and-compile
(defun loadpath-add-and-autoload (path)
@@ -48,24 +52,24 @@ FEATURE may be an unquoted feature symbol or a file name, see
(defalias 'yes-or-no-p 'y-or-n-p)
(defalias 'dabbrev-expand 'hippie-expand)
+;;;; uniquify
+
(require 'uniquify)
(stante-after uniquify
(setq uniquify-buffer-name-style 'post-forward))
+;;;; gnus
+
(defvar gnus-init-file)
(setq gnus-init-file "~/.emacs.d/site-lisp/gnus-init")
-(defmacro turn-off (&rest modes)
- "Turn off each mode in MODES."
- `(progn ,@(mapcar (lambda (m) `(,m -1)) modes)))
+;;;; Visual cues
(turn-off menu-bar-mode scroll-bar-mode tool-bar-mode blink-cursor-mode
column-number-mode line-number-mode tooltip-mode)
-(let ((theme (if (equal system-name "drd")
- 'yoshi
- 'leuven)))
+(let ((theme (if (equal system-name "drd") 'yoshi 'leuven)))
(let ((setp (not (daemonp))))
(defun init-set-theme (frame)
"Try to set the theme for the current (first) frame."
@@ -77,13 +81,23 @@ FEATURE may be an unquoted feature symbol or a file name, see
(add-hook 'after-make-frame-functions #'init-set-theme)
(eval-after-init (load-theme theme t))))
-(setq eww-download-path "~/downloads/")
+;;;; eww
+
+(stante-after eww
+ (setq eww-download-path ; Don't go to ~/Downloads
+ "~/downloads/"))
+
+;;;; Typography
(defun init-locally-enable-double-spaces ()
(setq-local sentence-end-double-space t))
+;; Use double spaces to end lines in Emacs Lisp. The checkdoc
+;; function starts complaining if you don't.
(add-hook 'emacs-lisp-mode-hook #'init-locally-enable-double-spaces)
+;;;; Symbols
+
(defun init-set-emacs-lisp-symbols ()
(when (boundp 'prettify-symbols-alist)
(setq prettify-symbols-alist
@@ -92,7 +106,6 @@ FEATURE may be an unquoted feature symbol or a file name, see
(">=" . ?≥)
("sqrt" . ?√))))))
-(add-hook 'emacs-lisp-mode-hook #'init-set-emacs-lisp-symbols)
(defun init-set-python-symbols ()
(when (boundp 'prettify-symbols-alist)
@@ -102,10 +115,10 @@ FEATURE may be an unquoted feature symbol or a file name, see
(">=" . ?≥)
("!=" . ?≠)))))
+(add-hook 'emacs-lisp-mode-hook #'init-set-emacs-lisp-symbols)
(add-hook 'python-mode-hook #'init-set-python-symbols)
-(when (and (>= emacs-major-version 24)
- (> emacs-minor-version 3))
+(when (fboundp 'prettify-symbols-mode)
(add-hook 'prog-mode-hook 'prettify-symbols-mode))
(stante-after slime
@@ -409,6 +422,38 @@ 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))
@@ -603,8 +648,6 @@ Also change directories to current working directory."
(stante-after magit
(setq magit-repo-dirs '("~/projects/"))
- (setq magit-default-tracking-name-function
- 'magit-default-tracking-name-branch-only)
(setq magit-diff-refine-hunk 'all))
(stante-after message
@@ -1299,20 +1342,43 @@ If no direction is given, don't split."
(define-key yas-minor-mode-map [(tab)] nil)
(define-key yas-minor-mode-map (kbd "C-\\") 'yas-expand))
-(defun init-toggle-pom-by-omm ()
- "Toggle mode `persistent-outline-mode'.
+;;;; Connected modes
+
+(link-modes outline-minor-mode persistent-outline-mode)
+(make-modes-exclusive magit-blame-mode fci-mode)
+
+;;;; Make toggling outlines easier
+
+(defun init-set-tab-maybe-toggle-outline ()
+ "Wrap the current function mapped to `TAB'."
+ (let ((func (or (lookup-key (current-local-map) (kbd "TAB"))
+ (lookup-key (current-global-map) (kbd "TAB")))))
+ (local-set-key (kbd "TAB")
+ (lambda ()
+ (interactive)
+ (if (outline-on-heading-p)
+ (if (outline-invisible-p (line-end-position))
+ (show-entry)
+ (hide-entry))
+ (call-interactively func))))))
+
+(add-hook 'outline-minor-mode-hook #'init-set-tab-maybe-toggle-outline)
-Toggle mode `persistent-outline-mode' according to the variable
-`outline-minor-mode'."
- (persistent-outline-mode (or outline-minor-mode -1)))
+;;;; Share the output AND the command
-(add-hook 'outline-minor-mode-hook #'init-toggle-pom-by-omm)
+(defun shell-command-with-command (command &optional output-buffer)
+ "Print both COMMAND and the output into OUTPUT-BUFFER."
+ (interactive (list (read-shell-command "Shell command: " nil nil)
+ current-prefix-arg))
+ (when output-buffer
+ (insert "`" command "':\n"))
+ (shell-command command output-buffer))
-(defun init-toggle-fci-by-mbm ()
- "Toggle `fci-mode' according to the inverse of `magit-blame-mode'."
- (fci-mode (or (not magit-blame-mode) -1)))
+(defun init-set-keys-for-jabber-chat ()
+ "Set certain keys for `jabber-chat-mode'."
+ (local-set-key (kbd "M-!") #'shell-command-with-command))
-(add-hook 'magit-blame-mode-hook #'init-toggle-fci-by-mbm)
+(add-hook 'jabber-chat-mode-hook #'init-set-keys-for-jabber-chat)
(provide 'init)
;;; init.el ends here