Move all configuration from org to elisp files

This commit is contained in:
Tom Willemse 2018-09-13 22:05:05 -07:00
parent cd9f77887e
commit e2594671af
15 changed files with 361 additions and 348 deletions

View file

@ -0,0 +1,105 @@
;;; oni-circe-init.el --- My Circe configuration -*- lexical-binding: t; -*-
;; Copyright (C) 2018 Tom Willemse
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; My Circe configuration
;;; Code:
(require 'circe)
(require 'circe-color-nicks)
(require 'circe-serenity)
(require 'oni-circe)
;(require 'mowedline)
(add-to-list 'circe-network-options
`("Freenode"
:nick "ryuslash"
:channels ("#mowedline"
"#ninthfloor"
"#dispass"
"#linuxvoice"
"#conkeror"
"#emacs-circe"
"#chicken"
:after-auth
"#emacs")
:nickserv-password
,(oni-circe-get-password-for "irc.freenode.net")))
(add-to-list 'circe-network-options
`("Twitch"
:use-tls nil
:nick "ryuslash"
:host "irc.twitch.tv"
:pass ,(oni-circe-get-password-for "irc.twitch.tv")
:port 6667))
(enable-circe-color-nicks)
(enable-circe-serenity)
(defun mowedline-colorize-mode-line-spec (s)
(cond
((stringp s) (string-trim s))
((eq ':propertize (car s))
(let ((s (cadr s))
(face (plist-get (cddr s) 'face)))
(if face
`(color ,(face-foreground face)
,(substring-no-properties s))
s)))
(t "")))
;(setq mowedline-update-function 'mowedline-update/dbus)
(defvar jjf-tracking-buffers '())
(defvar jjf-external-tracking-timer nil)
(defun jjf-external-tracking ()
(setq jjf-external-tracking-timer nil)
(mowedline-update
'irc
(if (stringp jjf-tracking-buffers)
(mowedline-colorize jjf-tracking-buffers t)
(format "%S" (mapcar #'mowedline-colorize-mode-line-spec
jjf-tracking-buffers)))))
(defun oni:clear-irc-mowedline-widget ()
(mowedline-clear 'irc))
(defun jjf-external-tracking-advice (orig-fun &rest args)
"Update my external status bar when tracking computes a new
status line, and suppress tracking in the mode-line. Since
tracking-status may be called many times in quick succession, for
example on a make-frame-visible event, we use a short timer to
only call the updater once within a minimum duration."
(setq jjf-tracking-buffers (apply orig-fun args))
(when jjf-external-tracking-timer
(cancel-timer jjf-external-tracking-timer))
(setq jjf-external-tracking-timer
(run-at-time 0.2 nil 'jjf-external-tracking))
nil)
;(advice-add 'tracking-status :around #'jjf-external-tracking-advice)
;(add-hook 'kill-emacs-hook 'oni:clear-irc-mowedline-widget)
(provide 'oni-circe-init)
;;; oni-circe-init.el ends here

View file

@ -1,123 +0,0 @@
#+TITLE: Circe config
#+BEGIN_SRC emacs-lisp
(require 'circe)
(require 'circe-color-nicks)
(require 'circe-serenity)
(require 'oni-circe)
(require 'mowedline)
#+END_SRC
I switched to Circe from ERC because I couldn't make the
customizations I wanted to, Circe seems much better at this.
I spend most of my time on IRC on Freenode.
#+BEGIN_SRC emacs-lisp -r -l ";(ref:%s)"
(add-to-list 'circe-network-options
`("Freenode"
:nick "ryuslash"
:channels ("#mowedline"
"#ninthfloor"
"#dispass"
"#linuxvoice"
"#conkeror"
"#emacs-circe"
"#chicken"
:after-auth ;(ref:aauth)
"#emacs")
:nickserv-password
,(oni-circe-get-password-for "irc.freenode.net")))
#+END_SRC
The [[(aauth)][:after-auth]] keyword is used to specify that the =#emacs= channel
should only be joined once the authentication with NickServ has
finished. This has apparently become a requirement.
Sometimes I watch some Twitch streams as well.
#+BEGIN_SRC emacs-lisp
(add-to-list 'circe-network-options
`("Twitch"
:use-tls nil
:nick "ryuslash"
:host "irc.twitch.tv"
:pass ,(oni-circe-get-password-for "irc.twitch.tv")
:port 6667))
#+END_SRC
Enable coloring of nicks.
#+BEGIN_SRC emacs-lisp
(enable-circe-color-nicks)
#+END_SRC
Align all nicks and generally clean up the buffer. I call it: Circe
Serenity.
#+BEGIN_SRC emacs-lisp
(enable-circe-serenity)
#+END_SRC
Add external tracking. Show the status of tracked buffers in
mowedline instead in the mode-line. With color!
This code has been generously donated by [[http://retroj.net][retroj]], the author of
mowedline.
First define a function to parse the text properties from the tracking
buffers list so that highlights (from mentions) also appear in
mowedline.
#+BEGIN_SRC emacs-lisp
(defun mowedline-colorize-mode-line-spec (s)
(cond
((stringp s) (string-trim s))
((eq ':propertize (car s))
(let ((s (cadr s))
(face (plist-get (cddr s) 'face)))
(if face
`(color ,(face-foreground face)
,(substring-no-properties s))
s)))
(t "")))
#+END_SRC
Also tell mowedline to use the dbus interface directly, instead of
going through the command-line interface.
#+BEGIN_SRC emacs-lisp
(setq mowedline-update-function 'mowedline-update/dbus)
#+END_SRC
#+BEGIN_SRC emacs-lisp
(defvar jjf-tracking-buffers '())
(defvar jjf-external-tracking-timer nil)
(defun jjf-external-tracking ()
(setq jjf-external-tracking-timer nil)
(mowedline-update
'irc
(if (stringp jjf-tracking-buffers)
(mowedline-colorize jjf-tracking-buffers t)
(format "%S" (mapcar #'mowedline-colorize-mode-line-spec
jjf-tracking-buffers)))))
(defun oni:clear-irc-mowedline-widget ()
(mowedline-clear 'irc))
(defun jjf-external-tracking-advice (orig-fun &rest args)
"Update my external status bar when tracking computes a new
status line, and suppress tracking in the mode-line. Since
tracking-status may be called many times in quick succession, for
example on a make-frame-visible event, we use a short timer to
only call the updater once within a minimum duration."
(setq jjf-tracking-buffers (apply orig-fun args))
(when jjf-external-tracking-timer
(cancel-timer jjf-external-tracking-timer))
(setq jjf-external-tracking-timer
(run-at-time 0.2 nil 'jjf-external-tracking))
nil)
(advice-add 'tracking-status :around #'jjf-external-tracking-advice)
(add-hook 'kill-emacs-hook 'oni:clear-irc-mowedline-widget)
#+END_SRC

View file

@ -1,22 +0,0 @@
#+TITLE: Company mode configuration
#+BEGIN_SRC emacs-lisp
(require 'company)
(require 'diminish)
#+END_SRC
Don't show that company mode is enabled in the minibuffer.
#+BEGIN_SRC emacs-lisp
(diminish 'company-mode)
#+END_SRC
Show a tooltip when there is more than one completion, show the
documentation for a symbol in the echo area and always show a preview.
#+BEGIN_SRC emacs-lisp
(setq company-frontends
'(company-pseudo-tooltip-unless-just-one-frontend
company-echo-metadata-frontend
company-preview-frontend))
#+END_SRC

View file

@ -0,0 +1,46 @@
;;; oni-dired-init.el --- My Dired configuration -*- lexical-binding: t; -*-
;; Copyright (C) 2018 Tom Willemse
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; My dired configuration.
;;; Code:
(require 'dired)
(require 'dired-x)
(defun oni:dired-add-wdired-keybinding ()
"Add a keybinding for wdired mode."
(define-key dired-mode-map (kbd "E") 'wdired-change-to-wdired-mode))
(setq dired-listing-switches "-alh")
(setq dired-subdir-switches "-Alh")
(add-hook 'dired-mode-hook 'oni:dired-add-wdired-keybinding)
(add-to-list 'dired-guess-shell-alist-user
`(,(rx ".pdf" eos) "zathura"))
(add-to-list 'dired-guess-shell-alist-user
`(,(rx (or ".jpg" ".jpeg" ".png" ".gif") eos) "feh"))
(provide 'oni-dired-init)
;;; oni-dired-init.el ends here

View file

@ -1,43 +0,0 @@
#+TITLE: Dired
#+BEGIN_SRC emacs-lisp
(require 'dired)
(require 'dired-x)
#+END_SRC
Show human-readable sizes in dired buffers.
#+BEGIN_SRC emacs-lisp
(setq dired-listing-switches "-alh")
#+END_SRC
Show the same info for subdirectories, but don't show the =.= and =..=
directories, since those are most likely already shown in the buffer.
#+BEGIN_SRC emacs-lisp
(setq dired-subdir-switches "-Alh")
#+END_SRC
Add a keybinding to dired buffers to change to wdired.
#+BEGIN_SRC emacs-lisp
(defun oni:dired-add-wdired-keybinding ()
"Add a keybinding for wdired mode."
(define-key dired-mode-map (kbd "E") 'wdired-change-to-wdired-mode))
(add-hook 'dired-mode-hook 'oni:dired-add-wdired-keybinding)
#+END_SRC
Open PDF files in zathura.
#+BEGIN_SRC emacs-lisp
(add-to-list 'dired-guess-shell-alist-user
`(,(rx ".pdf" eos) "zathura"))
#+END_SRC
Open Jpeg, Gif and PNG files in feh.
#+BEGIN_SRC emacs-lisp
(add-to-list 'dired-guess-shell-alist-user
`(,(rx (or ".jpg" ".jpeg" ".png" ".gif") eos) "feh"))
#+END_SRC

View file

@ -0,0 +1,49 @@
;;; oni-ediff-init.el --- My Ediff configuration -*- lexical-binding: t; -*-
;; Copyright (C) 2018 Tom Willemse
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; My Ediff configuration.
;;; Code:
(require 'ediff)
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
(setq ediff-split-window-function 'split-window-horizontally)
(setq ediff-diff-options "-w")
(defun oni:turn-on-fullscreen ()
(unless (memq (frame-parameter nil 'fullscreen)
'(fullscreen fullboth))
(set-frame-parameter nil 'fullscreen 'fullboth)))
(defun oni:turn-off-fullscreen ()
(when (memq (frame-parameter nil 'fullscreen)
'(fullscreen fullboth))
(set-frame-parameter nil 'fullscreen nil)))
(add-hook 'ediff-mode-hook 'oni:turn-on-fullscreen)
(add-hook 'ediff-cleanup-hook 'oni:turn-off-fullscreen)
(provide 'oni-ediff-init)
;;; oni-ediff-init.el ends here

View file

@ -1,41 +0,0 @@
#+TITLE: Ediff
#+BEGIN_SRC emacs-lisp
(require 'ediff)
#+END_SRC
Don't use a special frame for the ediff control buffer.
#+BEGIN_SRC emacs-lisp
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
#+END_SRC
Show the different buffers next to eachother instead of underneath
eachother.
#+BEGIN_SRC emacs-lisp
(setq ediff-split-window-function 'split-window-horizontally)
#+END_SRC
Don't show whitespace changes in ediff buffers.
#+BEGIN_SRC emacs-lisp
(setq ediff-diff-options "-w")
#+END_SRC
Show ediff in a fullscreen frame.
#+BEGIN_SRC emacs-lisp
(defun oni:turn-on-fullscreen ()
(unless (memq (frame-parameter nil 'fullscreen)
'(fullscreen fullboth))
(set-frame-parameter nil 'fullscreen 'fullboth)))
(defun oni:turn-off-fullscreen ()
(when (memq (frame-parameter nil 'fullscreen)
'(fullscreen fullboth))
(set-frame-parameter nil 'fullscreen nil)))
(add-hook 'ediff-mode-hook 'oni:turn-on-fullscreen)
(add-hook 'ediff-cleanup-hook 'oni:turn-off-fullscreen)
#+END_SRC

View file

@ -0,0 +1,37 @@
;;; oni-java-init.el --- My java-mode configuration -*- lexical-binding: t; -*-
;; Copyright (C) 2018 Tom Willemse
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; My `java-mode' configuration.
;;; Code:
(add-hook 'java-mode-hook 'electric-pair-local-mode)
(add-hook 'java-mode-hook 'electric-indent-local-mode)
(with-eval-after-load 'jdee-bsh
(setq jdee-server-dir "~/usr/share/java/jdee/"))
(add-hook 'java-mode-hook 'fci-mode)
(provide 'oni-java-init)
;;; oni-java-init.el ends here

View file

@ -1,24 +0,0 @@
Enable electric pair mode
#+BEGIN_SRC emacs-lisp
(add-hook 'java-mode-hook 'electric-pair-local-mode)
#+END_SRC
Enable electric indent mode
#+BEGIN_SRC emacs-lisp
(add-hook 'java-mode-hook 'electric-indent-local-mode)
#+END_SRC
Configure the JDEE server
#+BEGIN_SRC emacs-lisp
(with-eval-after-load 'jdee-bsh
(setq jdee-server-dir "~/usr/share/java/jdee/"))
#+END_SRC
Enable fill column indicator
#+BEGIN_SRC emacs-lisp
(add-hook 'java-mode-hook 'fci-mode)
#+END_SRC

View file

@ -0,0 +1,43 @@
;;; oni-magit-init.el --- My magit configuration -*- lexical-binding: t; -*-
;; Copyright (C) 2018 Tom Willemse
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; My magit configuration.
;;; Code:
(require 'magit)
(require 'magithub)
(setq magit-diff-refine-hunk 'all)
(defvar oni:magit-status-rx
(rx bos "*magit: "))
(defun oni:display-buffer-in-only-window (buffer alist)
(delete-other-windows)
(display-buffer-same-window buffer alist))
(add-to-list 'display-buffer-alist
`(,oni:magit-status-rx oni:display-buffer-in-only-window))
(provide 'oni-magit-init)
;;; oni-magit-init.el ends here

View file

@ -1,37 +0,0 @@
#+TITLE: Magit
#+BEGIN_SRC emacs-lisp
(require 'magit)
#+END_SRC
Magit is a very nice interface to Git for Emacs. It allows you to do
just about anything with Git without leaving the comfort of your Emacs
session.
Integrate github issues and pull requests in Magit. Requires the =hub=
executable.
#+BEGIN_SRC emacs-lisp
(require 'magithub)
#+END_SRC
Show refined diffs in magit. This makes it much easier to see /what/
has changed on a line.
#+BEGIN_SRC emacs-lisp
(setq magit-diff-refine-hunk 'all)
#+END_SRC
Make the magit status buffer always open as the only window in Emacs.
#+BEGIN_SRC emacs-lisp
(defvar oni:magit-status-rx
(rx bos "*magit: "))
(defun oni:display-buffer-in-only-window (buffer alist)
(delete-other-windows)
(display-buffer-same-window buffer alist))
(add-to-list 'display-buffer-alist
`(,oni:magit-status-rx oni:display-buffer-in-only-window))
#+END_SRC

View file

@ -0,0 +1,39 @@
;;; oni-shr-init.el --- My shr configuration -*- lexical-binding: t; -*-
;; Copyright (C) 2018 Tom Willemse
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; My shr configuration.
;;; Code:
(require '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))
(advice-add #'shr-colorize-region :filter-args
#'oni:shr-colorize-remove-last-arg)
(provide 'oni-shr-init)
;;; oni-shr-init.el ends here

View file

@ -1,28 +0,0 @@
#+TITLE: shr configuration
#+BEGIN_SRC emacs-lisp
(require 'shr)
#+END_SRC
* Remove background colors
Define a procedure that removes the last argument it gets if there
are more than 3.
#+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))
#+END_SRC
Add the function as a filter-args advice to
=shr-colorize-region=. The last (fourth) argument to that function
is the background color to use, it's optional, so removing it
effectively stops shr from adding background colors.
#+BEGIN_SRC emacs-lisp
(advice-add #'shr-colorize-region :filter-args
#'oni:shr-colorize-remove-last-arg)
#+END_SRC

View file

@ -0,0 +1,42 @@
;;; oni-slack-init.el --- My Slack configuration -*- lexical-binding: t; -*-
;; Copyright (C) 2018 Tom Willemse
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; My Slack configuration.
;;; Code:
(require 'slack)
(setq slack-prefer-current-team t)
(setq slack-buffer-function 'switch-to-buffer)
(slack-register-team :name "Picturefix"
:default t
:client-id oni:slack-client-id
:client-secret oni:slack-client-secret
:token oni:slack-token
:subscribed-channels
'(general picturefix random shirtlobby))
(provide 'oni-slack-init)
;;; oni-slack-init.el ends here

View file

@ -1,30 +0,0 @@
#+TITLE: Slack configuration
#+BEGIN_SRC emacs-lisp
(require 'slack)
#+END_SRC
Use the current team for most interactive commands.
#+BEGIN_SRC emacs-lisp
(setq slack-prefer-current-team t)
#+END_SRC
Use the regular =switch-to-buffer= so slack doesn't create a new
window every time I open a channel.
#+BEGIN_SRC emacs-lisp
(setq slack-buffer-function 'switch-to-buffer)
#+END_SRC
Register my work team.
#+BEGIN_SRC emacs-lisp
(slack-register-team :name "Picturefix"
:default t
:client-id oni:slack-client-id
:client-secret oni:slack-client-secret
:token oni:slack-token
:subscribed-channels
'(general picturefix random shirtlobby))
#+END_SRC