summaryrefslogtreecommitdiffstats
path: root/emacs/.emacs.d/init.org
diff options
context:
space:
mode:
authorGravatar Tom Willemse2015-09-23 16:41:27 +0200
committerGravatar Tom Willemse2015-09-23 16:41:27 +0200
commit242b8e8e2b8069d381040f2b8c89e97f9af73f98 (patch)
treeb973a20d271bc6a17be9aaca5f7eb960850efebe /emacs/.emacs.d/init.org
parent780bd0f3c457f792c6f11c5b6ae7e7888eb9aa17 (diff)
downloaddotfiles-242b8e8e2b8069d381040f2b8c89e97f9af73f98.tar.gz
dotfiles-242b8e8e2b8069d381040f2b8c89e97f9af73f98.zip
Update structure some more
Diffstat (limited to 'emacs/.emacs.d/init.org')
-rw-r--r--emacs/.emacs.d/init.org403
1 files changed, 209 insertions, 194 deletions
diff --git a/emacs/.emacs.d/init.org b/emacs/.emacs.d/init.org
index a52c0ec..20fac70 100644
--- a/emacs/.emacs.d/init.org
+++ b/emacs/.emacs.d/init.org
@@ -630,6 +630,215 @@
(kill-buffer (current-buffer)))
#+END_SRC
+*** Fix some term keybindings
+
+ =ansi-term= passes along a lot of characters correctly, but things
+ like =forward-delete-word= are not, by default. This is confusing when
+ you see one thing and another is sent. Passing the correct keys
+ directly to the terminal fixes this problem.
+
+ *Note:* See my [[Vacuous defvar][note]] on vacuous defvar for this use of =defvar=.
+
+ *Note:* See my [[Function declarations][note]] on function declarations about the use of
+ =declare-function=.
+
+ #+BEGIN_SRC emacs-lisp
+ (defvar term-raw-map)
+ (declare-function term-send-raw-string "term")
+
+ (defun oni:set-term-keys ()
+ (cl-flet ((zcommand (key)
+ (lambda ()
+ (interactive) (term-send-raw-string key))))
+ (define-key term-raw-map
+ (kbd "C-<backspace>") (zcommand "\C-H"))))
+
+ (add-hook 'term-mode-hook #'oni:set-term-keys)
+ #+END_SRC
+
+** Gnus
+
+ Gnus is a very powerful news reader that also handles Email quite
+ well. I've been using it for a while now, though not to its full
+ extent I'm sure. This section contains customization for multiple
+ major modes that are all closely related to Gnus.
+
+*** 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:7] about just this subject
+ it was easy to modify the source code posted there to come up with
+ this.
+
+ *Note:* See my [[Function declarations][note]] on function declarations about the use of
+ =declare-function=.
+
+ #+BEGIN_SRC emacs-lisp
+ (declare-function message-narrow-to-headers-or-head "message")
+ (declare-function message-fetch-field "message")
+
+ (defun oni:switch-ispell-dictionary ()
+ (save-excursion
+ (message-narrow-to-headers-or-head)
+ (when (string-match (rx (and "@" (or "aethon" "picturefix") ".nl>") eol)
+ (message-fetch-field "From"))
+ (ispell-change-dictionary "nl_NL"))))
+
+ (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.
+
+ *Note:* See my [[Function declarations][note]] on function declarations about the use of
+ =declare-function=.
+
+ #+BEGIN_SRC emacs-lisp
+ (declare-function shr-colorize-region "shr")
+
+ (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
+
+*** Init file
+
+ I put my gnus initialization file right where I put all my
+ module-specific initialization files. Gnus is special, though: It
+ loads the file every time you start it. That keeps it from using a
+ simple =(eval-after-load 'gnus '(load "gnus-init"))=.
+
+ *Note:* See my [[Vacuous defvar][note]] on vacuous defvar for this use of =defvar=.
+
+ #+BEGIN_SRC emacs-lisp
+ (defvar gnus-init-file)
+ (setq gnus-init-file "~/.emacs.d/site-lisp/gnus-init")
+ #+END_SRC
+
+** SQL
+
+ This is a generic comint mode for multiple SQL implementations such
+ as PostgreSQL and MariaDB (MySQL).
+
+*** 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/etc/sqliinput")))
+ #+END_SRC
+
+** Python
+
+ I used to code Python for a living, that's not so much the case
+ anymore. And for almost everything I will prefer Lisp over Python.
+ So these customizations might be a little old or badly tested.
+
+*** Show package name instead of file name
+
+ When working with python, knowing which package I'm in usually tells
+ me more about what I'm doing than the file name, especially when
+ working with django where almost every app will have a ~tests.py~ and
+ a ~models.py~. Of course =uniquify= fixes this pretty well too, though
+ in this case, it's less cool (imo).
+
+ First we define two functions that help us determine the package
+ name of the current file and the parent package name of the current
+ file. Finally we define a third function which determines the full
+ package name of the current buffer.
+
+ #+BEGIN_SRC emacs-lisp
+ (defun oni:python--get-current-module-name ()
+ "Get the name of the current python module.
+
+ This is very simply just the filename of the current buffer with
+ the extension and pyath removed."
+ (file-name-sans-extension
+ (file-name-nondirectory (buffer-file-name))))
+
+ (defun oni:python--get-parent-module-name (&optional dir)
+ "This gets the currend file's parent module.
+
+ This function recursively gathers the parent package name of
+ either DIR or the current buffer's file name. Any directory where
+ an `__init__.py' file is found is considered to be a package.
+
+ This function returns either the parent package, with its
+ parents, or nil if the current directory isn't a python
+ package.."
+ (let* ((base (directory-file-name
+ (file-name-directory (or dir (buffer-file-name)))))
+ (package (file-name-nondirectory base)))
+ (if (file-exists-p (concat base "/__init__.py"))
+ (let ((parent (oni:python--get-parent-module-name base)))
+ (if parent
+ (concat parent "." package)
+ package))
+ nil)))
+
+ (defun oni:python-package-name ()
+ (let ((current-module (oni:python--get-current-module-name)))
+ (if (file-exists-p "__init__.py")
+ (concat (oni:python--get-parent-module-name)
+ "." current-module)
+ current-module)))
+ #+END_SRC
+
+ After all this we make Emacs show the package name rather than the
+ file name in the mode-line.
+
+ #+BEGIN_SRC emacs-lisp
+ (defun oni:python-package-buffer-identification ()
+ "Have `mode-line-buffer-identification' show the python package name."
+ (setq mode-line-buffer-identification
+ '(:eval (oni:python-package-name))))
+
+ (add-hook 'python-mode-hook #'oni:python-package-buffer-identification)
+ #+END_SRC
+
+** Elnode
+
+ Elnode is an awesome project and I'm still looking for a moment
+ where I have the inspiration and time to actually do something with
+ it. I started at some point, but then I couldn't get the cookies to
+ work and I switched over to using Common Lisp, only to eventually
+ stop developing the project because there was not chance of it
+ seeing any use in the foreseeable future.
+
+*** Don't start =elnode= when Emacs starts
+
+ There is one little annoyance and that is the fact that elnode
+ will start itself up when Emacs starts. I don't want that.
+
+ This bit of code can't be put in an =eval-after-load= or anything
+ like that because by the time it would be evaluated, elnode would
+ already have started.
+
+ *Note:* See my [[Vacuous defvar][note]] on vacuous defvar for this use of =defvar=.
+
+ #+BEGIN_SRC emacs-lisp
+ (defvar elnode-do-init)
+ (setq elnode-do-init nil)
+ #+END_SRC
+
* Minor mode customization
Many minor modes also offer a bit of customization possibilities.
@@ -707,200 +916,6 @@
`(add-hook 'emacs-startup-hook #'(lambda () ,@body)))
#+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:7] about just this subject
- it was easy to modify the source code posted there to come up with
- this.
-
- *Note:* See my [[Function declarations][note]] on function declarations about the use of
- =declare-function=.
-
- #+BEGIN_SRC emacs-lisp
- (declare-function message-narrow-to-headers-or-head "message")
- (declare-function message-fetch-field "message")
-
- (defun oni:switch-ispell-dictionary ()
- (save-excursion
- (message-narrow-to-headers-or-head)
- (when (string-match (rx (and "@" (or "aethon" "picturefix") ".nl>") eol)
- (message-fetch-field "From"))
- (ispell-change-dictionary "nl_NL"))))
-
- (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.
-
- *Note:* See my [[Function declarations][note]] on function declarations about the use of
- =declare-function=.
-
- #+BEGIN_SRC emacs-lisp
- (declare-function shr-colorize-region "shr")
-
- (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
-
-* 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
-
-* Fix some term keybindings
-
- =ansi-term= passes along a lot of characters correctly, but things
- like =forward-delete-word= are not, by default. This is confusing when
- you see one thing and another is sent. Passing the correct keys
- directly to the terminal fixes this problem.
-
- *Note:* See my [[Vacuous defvar][note]] on vacuous defvar for this use of =defvar=.
-
- *Note:* See my [[Function declarations][note]] on function declarations about the use of
- =declare-function=.
-
- #+BEGIN_SRC emacs-lisp
- (defvar term-raw-map)
- (declare-function term-send-raw-string "term")
-
- (defun oni:set-term-keys ()
- (cl-flet ((zcommand (key)
- (lambda ()
- (interactive) (term-send-raw-string key))))
- (define-key term-raw-map
- (kbd "C-<backspace>") (zcommand "\C-H"))))
-
- (add-hook 'term-mode-hook #'oni:set-term-keys)
- #+END_SRC
-
-* Some unconditional settings
-
- Here are some settings that either need to be changed before certain
- modules load, or that don't belong in any specific module.
-
-** Gnus init file
-
- I put my gnus initialization file right where I put all my
- module-specific initialization files. Gnus is special, though: It
- loads the file every time you start it. That keeps it from using a
- simple =(eval-after-load 'gnus '(load "gnus-init"))=.
-
- *Note:* See my [[Vacuous defvar][note]] on vacuous defvar for this use of =defvar=.
-
- #+BEGIN_SRC emacs-lisp
- (defvar gnus-init-file)
- (setq gnus-init-file "~/.emacs.d/site-lisp/gnus-init")
- #+END_SRC
-
-** Don't start =elnode= when Emacs starts
-
- Elnode is an awesome project and I'm still looking for a moment
- where I have the inspiration and time to actually do something with
- it. I started at some point, but then I couldn't get the cookies to
- work and I switched over to using Common Lisp, only to eventually
- stop developing the project because there was not chance of it
- seeing any use in the foreseeable future.
-
- There is one little annoyance, though, and that is the fact that
- elnode will start itself up when Emacs starts. I don't want that.
-
- This bit of code can't be put in an =eval-after-load= or anything
- like that because by the time it would be evaluated, elnode would
- already have started.
-
- *Note:* See my [[Vacuous defvar][note]] on vacuous defvar for this use of =defvar=.
-
- #+BEGIN_SRC emacs-lisp
- (defvar elnode-do-init)
- (setq elnode-do-init nil)
- #+END_SRC
-
-* Show python package name instead of file name
-
- When working with python, knowing which package I'm in usually tells
- me more about what I'm doing than the file name, especially when
- working with django where almost every app will have a ~tests.py~ and
- a ~models.py~. Of course =uniquify= fixes this pretty well too, though
- in this case, it's less cool (imo).
-
- First we define two functions that help us determine the package
- name of the current file and the parent package name of the current
- file. Finally we define a third function which determines the full
- package name of the current buffer.
-
- #+BEGIN_SRC emacs-lisp
- (defun oni:python--get-current-module-name ()
- "Get the name of the current python module.
-
- This is very simply just the filename of the current buffer with
- the extension and pyath removed."
- (file-name-sans-extension
- (file-name-nondirectory (buffer-file-name))))
-
- (defun oni:python--get-parent-module-name (&optional dir)
- "This gets the currend file's parent module.
-
- This function recursively gathers the parent package name of
- either DIR or the current buffer's file name. Any directory where
- an `__init__.py' file is found is considered to be a package.
-
- This function returns either the parent package, with its
- parents, or nil if the current directory isn't a python
- package.."
- (let* ((base (directory-file-name
- (file-name-directory (or dir (buffer-file-name)))))
- (package (file-name-nondirectory base)))
- (if (file-exists-p (concat base "/__init__.py"))
- (let ((parent (oni:python--get-parent-module-name base)))
- (if parent
- (concat parent "." package)
- package))
- nil)))
-
- (defun oni:python-package-name ()
- (let ((current-module (oni:python--get-current-module-name)))
- (if (file-exists-p "__init__.py")
- (concat (oni:python--get-parent-module-name)
- "." current-module)
- current-module)))
- #+END_SRC
-
- After all this we make Emacs show the package name rather than the
- file name in the mode-line.
-
- #+BEGIN_SRC emacs-lisp
- (defun oni:python-package-buffer-identification ()
- "Have `mode-line-buffer-identification' show the python package name."
- (setq mode-line-buffer-identification
- '(:eval (oni:python-package-name))))
-
- (add-hook 'python-mode-hook #'oni:python-package-buffer-identification)
- #+END_SRC
-
* Add some known symbols for .conkerorrc/init.js to js2-mode
Conkeror has a lot of functions, and I don't like seeing them all as