summaryrefslogtreecommitdiffstats
path: root/.emacs.d
diff options
context:
space:
mode:
Diffstat (limited to '.emacs.d')
-rw-r--r--.emacs.d/Makefile6
-rw-r--r--.emacs.d/init.el59
-rw-r--r--.emacs.d/init.org243
3 files changed, 250 insertions, 58 deletions
diff --git a/.emacs.d/Makefile b/.emacs.d/Makefile
index 17db788..616136b 100644
--- a/.emacs.d/Makefile
+++ b/.emacs.d/Makefile
@@ -1,9 +1,13 @@
.PHONY: all site-lisp
-all: init.elc site-lisp/
+all: init2.elc init.elc site-lisp/
%.elc: %.el
emacs -Q -batch -eval "(byte-compile-file \"$<\")"
+init.el: init2.el
+init2.el: init.org
+ emacs -Q -batch -l "ob-tangle" -eval "(org-babel-tangle-file \"init.org\")"
+
%/: %
$(MAKE) -C "$(CURDIR)/$*"
diff --git a/.emacs.d/init.el b/.emacs.d/init.el
index 587b023..9cbb79d 100644
--- a/.emacs.d/init.el
+++ b/.emacs.d/init.el
@@ -15,6 +15,8 @@
(require 'magit)
(require 'yasnippet))
+(load (concat user-emacs-directory "init2"))
+
;;;; Autoloads
(autoload 'jabber-connect "jabber" nil t)
@@ -110,24 +112,6 @@ MODE1 is enabled and vice-versa."
(add-hook ',(intern (concat mode1-name "-hook"))
#',function-name))))
-(defmacro oni:stumpwm (&rest body)
- "Execute BODY in stumpwm."
- (declare (indent 0))
- `(call-process oni:stumpish-program nil nil nil
- ,(format "eval '%S'" `(progn ,@body))))
-
-(defmacro oni:turn-off (&rest modes)
- "Turn off each mode in MODES."
- (declare (indent 0))
- `(progn ,@(mapcar (lambda (m) `(,m -1)) modes)))
-
-;;;; Variables
-
-(defvar oni:stumpish-program
- (expand-file-name
- "~/.local/share/quicklisp/local-projects/stumpwm/contrib/stumpish")
- "The location of the stumpish executable.")
-
;;;;; Vacuous
(defvar elnode-do-init)
@@ -195,11 +179,6 @@ MODE1 is enabled and vice-versa."
(funcall regfunc (point) (- (point) num))
(funcall wordfunc -1))))
-(defun oni:close-client-window ()
- "Close a client's frames."
- (interactive)
- (server-save-buffers-kill-terminal nil))
-
(defun oni:css-mode-func ()
"Function for `css-mode-hook'."
(local-set-key "\C-j" 'oni:newline-and-indent))
@@ -769,10 +748,6 @@ If no direction is given, don't split."
(interactive)
(kill-process "python-test-mail-server"))
-(defun oni:stumpwm-command (cmd)
- "Execute CMD in stumpwm."
- (call-process oni:stumpish-program nil nil nil cmd))
-
(defun oni:switch-to-other-buffer ()
"Switch to the most recently viewed buffer."
(interactive)
@@ -814,26 +789,6 @@ If no direction is given, don't split."
(when (file-exists-p loaddefs)
(load loaddefs)))))
-;;;;; Advice
-
-(defadvice org-agenda-redo (after ext:org-agenda-redo-add-appts)
- "Pressing `r' on the agenda will also add appointments."
- (progn
- (setq appt-time-msg-list nil)
- (org-agenda-to-appt)))
-
-(defadvice term-handle-exit (after oni:kill-buffer-after-exit activate)
- "Kill the term buffer if the process finished."
- (kill-buffer (current-buffer)))
-
-(defadvice windmove-do-window-select
- (around oni:windmove-stumpwm activate)
- "If no window can be moved to, move stumpwm."
- (condition-case err
- ad-do-it
- (error (oni:stumpwm-command
- (format "move-focus %s" (ad-get-arg 0))))))
-
;;;; Modes
;; Copied from electric.el, modified from `electric-indent-local-mode'.
@@ -1384,21 +1339,11 @@ If no direction is given, don't split."
(global-set-key (kbd "\"") 'oni:self-insert-dwim)
(global-set-key [remap move-beginning-of-line] #'oni:move-beginning-of-dwim)
-(if (daemonp)
- (global-set-key "\C-x\C-c" 'oni:close-client-window))
-
-(when (or window-system (daemonp))
- (global-unset-key "\C-z"))
-
;;;; Misc modes
(oni:enable '(downcase-region narrow-to-page narrow-to-region scroll-left
upcase-region))
-(oni:turn-off
- menu-bar-mode scroll-bar-mode tool-bar-mode blink-cursor-mode
- column-number-mode line-number-mode tooltip-mode)
-
(oni:link-modes outline-minor-mode persistent-outline-mode)
(oni:exclude-modes magit-blame-mode fci-mode)
diff --git a/.emacs.d/init.org b/.emacs.d/init.org
new file mode 100644
index 0000000..2cd3696
--- /dev/null
+++ b/.emacs.d/init.org
@@ -0,0 +1,243 @@
+#+TITLE: ryuslash's Emacs init
+#+PROPERTY: tangle init2.el
+#+STARTUP: showall
+#+OPTIONS: author:nil num:nil toc:nil
+#+MACRO: key @@html:<kbd>$1</kbd>@@@@ascii:`$1'@@
+#+HTML_HEAD: <link href="https://ryuslash.org/org.css" rel="stylesheet" type="text/css">
+
+* Cleanup basic UI
+
+ The tool-bar, menu-bar and scroll-bar aren't particularly
+ keyboard-friendly and just take up space if you don't use them.
+ Anything in the tool-bar or menu-bar can be accessed just as easily
+ with {{{key(M-x)}}}. The scroll-bar is almost just as informative as
+ the current line number and buffer position information.
+
+ #+BEGIN_SRC emacs-lisp :padline no
+ (menu-bar-mode -1)
+ (tool-bar-mode -1)
+ (scroll-bar-mode -1)
+ #+END_SRC
+
+* Stop blinking!
+
+ Blinking cursors are a distraction.
+
+ #+BEGIN_SRC emacs-lisp
+ (blink-cursor-mode -1)
+ #+END_SRC
+
+* Buffer position
+
+ As I'm currently using svg-mode-line-themes[fn:1] for my ~mode-line~ I
+ don't need to show these. Also I didn't really use them much, I
+ don't often need to know what line I'm on.
+
+ #+BEGIN_SRC emacs-lisp
+ (column-number-mode -1)
+ (line-number-mode -1)
+ #+END_SRC
+
+* Don't show tooltips
+
+ Tooltips are another one of those UI elements that aren't quite
+ keyboard-friendly. As usually this information is shown just as well
+ in the echo area, this is not necessary.
+
+ #+BEGIN_SRC emacs-lisp
+ (tooltip-mode -1)
+ #+END_SRC
+
+* Add org-mode appointments to the diary
+
+ Diary offers reminders, which can be useful when scheduling
+ appointments.
+
+ #+BEGIN_SRC emacs-lisp
+ (defadvice org-agenda-redo (after ext:org-agenda-redo-add-appts)
+ "Pressing `r' on the agenda will also add appointments."
+ (setq appt-time-msg-list nil)
+ (org-agenda-to-appt))
+ #+END_SRC
+
+* Close ansi-term buffer after exit
+
+ After the ansi-term process ends it leaves a buffer. I don't use
+ ansi term in such a way that this has ever been useful, so just kill
+ the ansi-term buffer after the process quits, no matter the exit
+ status. Usually this comes about when I press {{{kbd(C-d)}}} at the
+ command prompt.
+
+ #+BEGIN_SRC emacs-lisp
+ (defadvice term-handle-exit (after oni:kill-buffer-after-exit activate)
+ "Kill the term buffer if the process finished."
+ (kill-buffer (current-buffer)))
+ #+END_SRC
+
+* Stumpwm integration
+
+ This variable, macro and function help with integrating Emacs and
+ Stumpwm. They are used by several other functions to make the two
+ seem extra connected. An example of this can be found in [[Fall back
+ on stumpwm when moving around]].
+
+ #+BEGIN_SRC emacs-lisp
+ (defvar oni:stumpish-program
+ (expand-file-name
+ "~/.local/share/quicklisp/local-projects/stumpwm/contrib/util/stumpish/stumpish")
+ "The location of the stumpish executable.")
+
+ (defmacro oni:stumpwm (&rest body)
+ "Execute BODY in stumpwm."
+ (declare (indent 0))
+ `(call-process oni:stumpish-program nil nil nil
+ ,(format "eval '%S'" `(progn ,@body))))
+
+ (defun oni:stumpwm-command (cmd)
+ "Execute CMD in stumpwm."
+ (call-process oni:stumpish-program nil nil nil cmd))
+
+ (defun oni:stumpwm-echo (message)
+ (call-process oni:stumpish-program nil nil nil (format "echo %s" message)))
+ #+END_SRC
+
+* Fall back on stumpwm when moving around
+
+ Using the function specified in [[Stumpwm integration]] wrap the
+ =windmove-do-window-select= function and catch any error produced,
+ hoping it's the error that there's no more window to move to and
+ then request that stumpwm move the focus in the same direction as
+ windmove would have.
+
+ #+BEGIN_SRC emacs-lisp
+ (defadvice windmove-do-window-select
+ (around oni:windmove-stumpwm activate)
+ "If no window can be moved to, move stumpwm."
+ (condition-case err
+ ad-do-it
+ (error (oni:stumpwm-command
+ (format "move-focus %s" (ad-get-arg 0))))))
+ #+END_SRC
+
+* Don't just quit Emacs with {{{key(C-x C-c)}}} in the daemon
+
+ When working with Emacs as a daemon, which I do almost all of the
+ time, I prefer using {{{key(C-x C-c)}}} to close the current frame
+ instead of the entire session. Before this change I would
+ occasionally close my session by mistake.
+
+ #+BEGIN_SRC emacs-lisp
+ (defun oni:close-client-window ()
+ "Close a client's frames."
+ (interactive)
+ (server-save-buffers-kill-terminal nil))
+
+ (when (daemonp)
+ (global-set-key (kbd "C-x C-c") 'oni:close-client-window))
+ #+END_SRC
+
+* Don't minimize the frame with {{{key(C-z)}}}
+
+ One of the more annoying things that can happen is accidentally
+ minimizing the frame you're working with. This doesn't really matter
+ if you're working on a normal stacking window manager, but with a
+ tiling window manager and no task bar this just causes the Emacs
+ frame to hang until it is refocused or disappear with no way to get
+ it back.
+
+ #+BEGIN_SRC emacs-lisp
+ (when (or window-system (daemonp))
+ (global-unset-key (kbd "C-z")))
+ #+END_SRC
+
+* Use the right dictionary
+
+ One of the caveats of using two (or more) languages in a single
+ installation of Gnus is that ispell sometimes gets confused. Having
+ come across a stackoverflow question[fn:2] about just this subject
+ it was easy to modify the source code posted there to come up with
+ this.
+
+ #+BEGIN_SRC emacs-lisp
+ (defun oni:switch-ispell-dictionary ()
+ (save-excursion
+ (message-narrow-to-headers-or-head)
+ (let ((from (message-fetch-field "From")))
+ (ispell-change-dictionary
+ (if (string-match (rx "@aethon.nl>" eol) from) "nl" "en")))))
+
+ (add-hook 'message-setup-hook 'oni:switch-ispell-dictionary)
+ #+END_SRC
+
+* Don't let shr use background color
+
+ Reading mail in Gnus is very nice, but shr has become a little too
+ good at its job. Add to this the many occasions when a background is
+ specified without specifying a foreground, plus a color theme that
+ is the inverse of what is usually expected, and you can get
+ hard-to-read HTML messages, gray foreground and gray background.
+
+ I've looked at the other possible renderers, but they don't look
+ very nice compared to shr. So just remove its ability to add
+ background colors.
+
+ #+BEGIN_SRC emacs-lisp
+ (defun oni:shr-colorize-remove-last-arg (args)
+ "If ARGS has more than 3 items, remove the last one."
+ (if (> (length args) 3)
+ (butlast args)
+ args))
+
+ (with-eval-after-load 'shr
+ (advice-add #'shr-colorize-region :filter-args
+ #'oni:shr-colorize-remove-last-arg))
+ #+END_SRC
+
+* Optimized ~with-eval-after-load~
+
+ First offered [[http://www.lunaryorn.com/2013/05/01/byte-compiling-eval-after-load.html][here]] and then later updated [[http://www.lunaryorn.com/2013/06/25/introducing-with-eval-after-load.html][here]] (when
+ ~with-eval-after-load~ was added). Makes for very nice on-demand
+ settings loading.
+
+ #+BEGIN_SRC emacs-lisp
+ ;; http://www.lunaryorn.com/2013/06/25/introducing-with-eval-after-load/
+ (defmacro stante-after (feature &rest forms)
+ "After FEATURE is loaded, evaluate FORMS.
+
+ FEATURE may be an unquoted feature symbol or a file name, see
+ `eval-after-load'."
+ (declare (indent 1) (debug t))
+ `(,(if (or (not byte-compile-current-file)
+ (if (symbolp feature)
+ (require feature nil :noerror)
+ (load feature :no-message :no-error)))
+ `progn
+ (message "stante-after: cannot find %s" feature)
+ 'with-no-warnings)
+ (with-eval-after-load ',feature ,@forms)))
+ #+END_SRC
+
+* Remember SQL input
+
+ Remembering input between sessions is a good thing.
+
+ #+BEGIN_SRC emacs-lisp
+ (stante-after sql
+ (setf sql-input-ring-file-name
+ (expand-file-name "~/.emacs.d/sqliinput")))
+ #+END_SRC
+
+* Lazily load some buffers
+
+ Don't load all buffers right away. Having a lot of buffers and
+ switching between projects a lot can take up quite a bit of time.
+
+ #+BEGIN_SRC emacs-lisp
+ (setq desktop-restore-eager 5)
+ #+END_SRC
+
+* Footnotes
+
+[fn:1] https://github.com/sabof/svg-mode-line-themes
+
+[fn:2] http://stackoverflow.com/questions/22175214/automatically-switch-language-in-gnus-depending-on-recipient