diff --git a/emacs/.emacs.d/init.org b/emacs/.emacs.d/init.org index a5a7ee5..95c89b5 100644 --- a/emacs/.emacs.d/init.org +++ b/emacs/.emacs.d/init.org @@ -561,6 +561,133 @@ To start off, first I need to enable lexical binding. '("-a" "picturefix")))))) #+END_SRC +** Linewise user-interface + + This is the library used by Circe and Slack to display messages. + + #+BEGIN_SRC emacs-lisp + (eval-when-compile (require 'lui)) + #+END_SRC + + Put the time stamp in lui buffers in the right margin. This gives + the text some extra room. + + #+BEGIN_SRC emacs-lisp + (with-eval-after-load 'lui + (setq lui-time-stamp-position 'right-margin)) + #+END_SRC + + Remove the "[]" from the time stamp, it's not really necessary. + + #+BEGIN_SRC emacs-lisp + (with-eval-after-load 'lui + (setq lui-time-stamp-format "%H:%M")) + #+END_SRC + + Give the right margin just enough room to show the time-stamps, no + more, no less. + + #+BEGIN_SRC emacs-lisp + (defun oni:set-circe-margin-width () + (setq right-margin-width 5)) + + (add-hook 'lui-mode-hook #'oni:set-circe-margin-width) + #+END_SRC + + Fix the wrap prefix so that text at the prompt is aligned properly. + + #+BEGIN_SRC emacs-lisp + (defun oni:set-lui-prompt-wrap-prefix () + (setq wrap-prefix " ")) + + (add-hook 'lui-mode-hook #'oni:set-lui-prompt-wrap-prefix) + #+END_SRC + + Enable visual line mode in lui buffers so my text doesn't go + off-screen. + + #+BEGIN_SRC emacs-lisp + (add-hook 'lui-mode-hook 'visual-line-mode) + #+END_SRC + +** Circe + + I switched to Circe from ERC because I couldn't make the + customizations I wanted to, Circe seems much better at this. + + #+BEGIN_SRC emacs-lisp + (ensure-library circe) + #+END_SRC + + I prefer storing my passwords in a GPG encrypted authinfo + file. Circe doesn't look at this out-of-the-box, but it's easy + enough to get this. This function returns a function that will get + a stored password for the given host. + + #+BEGIN_SRC emacs-lisp + (defun oni:circe-get-password-for (host) + (lambda (_) + (let ((found (nth 0 (auth-source-search :max 1 + :host host + :require '(:secret))))) + (when found + (let ((secret (plist-get found :secret))) + (if (functionp secret) + (funcall secret) + secret)))))) + #+END_SRC + + I spend most of my time on IRC on Freenode. + + #+BEGIN_SRC emacs-lisp + (eval-when-compile (require 'circe)) + + (with-eval-after-load 'circe + (add-to-list 'circe-network-options + `("Freenode" + :nick "ryuslash" + :channels ("#emacs" + "#mowedline" + "#ninthfloor" + "#dispass" + "#linuxvoice" + "#conkeror") + :nickserv-password + ,(oni:circe-get-password-for "irc.freenode.net")))) + #+END_SRC + + Sometimes I watch some Twitch streams as well. + + #+BEGIN_SRC emacs-lisp + (with-eval-after-load 'circe + (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 + (with-eval-after-load 'circe + (require 'circe-color-nicks) + (enable-circe-color-nicks)) + #+END_SRC + + Align all nicks. + + #+BEGIN_SRC emacs-lisp + (ensure-library circe-aligned-nicks + :path "vendor-lisp/circe-aligned-nicks") + + (with-eval-after-load 'circe + (require 'circe-aligned-nicks) + (enable-circe-aligned-nicks)) + #+END_SRC + * Custom Put the customize settings in a different file so that Emacs doesn't diff --git a/emacs/.emacs.d/vendor-lisp/circe-aligned-nicks/circe-aligned-nicks.el b/emacs/.emacs.d/vendor-lisp/circe-aligned-nicks/circe-aligned-nicks.el new file mode 100644 index 0000000..195b714 --- /dev/null +++ b/emacs/.emacs.d/vendor-lisp/circe-aligned-nicks/circe-aligned-nicks.el @@ -0,0 +1,203 @@ +;;; circe-aligned-nicks.el --- Align nicks in Circe buffers -*- lexical-binding: t; -*- + +;; Copyright (C) 2016 Tom Willemse + +;; Author: Tom Willemse +;; Keywords: convenience + +;; 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 . + +;;; Commentary: + +;; This is an extension module for Circe. It right-aligns all new +;; nicks with the longest known nick. + +;;; Code: + +(defvar circe-aligned-nicks-longest-nick 0 + "The longest known nick.") +(make-variable-buffer-local 'circe-aligned-nicks-longest-nick) + +(defvar circe-aligned-nicks-original-format-say nil + "The original value of `circe-format-say'.") +(defvar circe-aligned-nicks-original-format-self-say nil + "The original value of `circe-format-self-say'.") +(defvar circe-aligned-nicks-original-format-action nil + "The original value of `circe-format-action'.") +(defvar circe-aligned-nicks-original-format-self-action nil + "The original value of `circe-format-self-action'.") +(defvar circe-aligned-nicks-original-format-server-message nil + "The original value of `circe-format-server-message'.") +(defvar circe-aligned-nicks-original-format-server-join-in-channel nil + "The original value of `circe-format-server-join-in-channel'.") +(defvar circe-aligned-nicks-original-format-server-join nil + "The original value of `circe-format-server-join'.") +(defvar circe-aligned-nicks-original-format-server-quit nil + "The original value of `circe-format-server-quit'.") +(defvar circe-aligned-nicks-original-format-server-quit-channel nil + "The original value of `circe-format-server-quit-channel'.") +(defvar circe-aligned-nicks-original-format-server-part nil + "The original value of `circe-format-server-part'.") +(defvar circe-aligned-nicks-original-format-server-nick-change nil + "The original value of `circe-format-server-nick-change'.") + +(defun circe-aligned-nicks--update-longest-nick (keywords) + (let* ((nick (plist-get keywords :nick)) + (len (length nick))) + (when (> len circe-aligned-nicks-longest-nick) + (setq circe-aligned-nicks-longest-nick len) + (setq-local lui-fill-type (make-string (+ len 3) ?\s))))) + +(defun circe-aligned-nicks-say-formatter (&rest keywords) + (circe-aligned-nicks--update-longest-nick keywords) + (lui-format (format "{nick:%ds} {body}" circe-aligned-nicks-longest-nick) + keywords)) + +(defun circe-aligned-nicks-self-say-formatter (&rest keywords) + (format (format "%%%ds %%s" circe-aligned-nicks-longest-nick) + ">" (plist-get keywords :body))) + +(defun circe-aligned-nicks-action-formatter (&rest keywords) + (lui-format + (format "{intro:%ds} {nick} {body}" circe-aligned-nicks-longest-nick) + (plist-put keywords :intro "*"))) + +(defun circe-aligned-nicks-server-message-formatter (&rest keywords) + (lui-format + (format "{intro:%ds} {body}" circe-aligned-nicks-longest-nick) + (plist-put keywords :intro "***"))) + +(defun circe-aligned-nicks-server-join-in-channel-formatter (&rest keywords) + (lui-format + (format "{intro:%ds} Join: {nick} ({userinfo}) joined {channel}" + circe-aligned-nicks-longest-nick) + (plist-put keywords :intro "***"))) + +(defun circe-aligned-nicks-server-join-formatter (&rest keywords) + (lui-format + (format "{intro:%ds} Join: {nick} ({userinfo})" + circe-aligned-nicks-longest-nick) + (plist-put keywords :intro "***"))) + +(defun circe-aligned-nicks-server-quit-formatter (&rest keywords) + (lui-format + (format "{intro:%ds} Quit: {nick} ({userhost}) left IRC: {reason}" + circe-aligned-nicks-longest-nick) + (plist-put keywords :intro "***"))) + +(defun circe-aligned-nicks-server-quit-channel-formatter (&rest keywords) + (lui-format + (format "{intro:%ds} Quit: {nick} ({userhost}) left {channel}: {reason}" + circe-aligned-nicks-longest-nick) + (plist-put keywords :intro "***"))) + +(defun circe-aligned-nicks-server-part-formatter (&rest keywords) + (lui-format + (format "{intro:%ds} Part: {nick} ({userhost}) left {channel}: {reason}" + circe-aligned-nicks-longest-nick) + (plist-put keywords :intro "***"))) + +(defun circe-aligned-nicks-server-nick-change-formatter (&rest keywords) + (lui-format + (format "{intro:%ds} Nick change: {old-nick} ({userhost}) is now know as {new-nick}" + circe-aligned-nicks-longest-nick) + (plist-put keywords :intro "***"))) + +;;;###autoload +(defun enable-circe-aligned-nicks () + (interactive) + (if (null circe-aligned-nicks-original-format-say) + (setq circe-aligned-nicks-original-format-say + circe-format-say)) + (setq circe-format-say #'circe-aligned-nicks-say-formatter) + + (if (null circe-aligned-nicks-original-format-self-say) + (setq circe-aligned-nicks-original-format-self-say + circe-format-self-say)) + (setq circe-format-self-say #'circe-aligned-nicks-say-formatter) + + (if (null circe-aligned-nicks-original-format-action) + (setq circe-aligned-nicks-original-format-action + circe-format-action)) + (setq circe-format-action #'circe-aligned-nicks-action-formatter) + + (if (null circe-aligned-nicks-original-format-self-action) + (setq circe-aligned-nicks-original-format-self-action + circe-format-self-action)) + (setq circe-format-self-action #'circe-aligned-nicks-action-formatter) + + (if (null circe-aligned-nicks-original-format-server-message) + (setq circe-aligned-nicks-original-format-server-message + circe-format-server-message)) + (setq circe-format-server-message #'circe-aligned-nicks-server-message-formatter) + + (if (null circe-aligned-nicks-original-format-server-join-in-channel) + (setq circe-aligned-nicks-original-format-server-join-in-channel + circe-format-server-join-in-channel)) + (setq circe-format-server-join-in-channel + #'circe-aligned-nicks-server-join-in-channel-formatter) + + (if (null circe-aligned-nicks-original-format-server-join) + (setq circe-aligned-nicks-original-format-server-join + circe-format-server-join)) + (setq circe-format-server-join #'circe-aligned-nicks-server-join-formatter) + + (if (null circe-aligned-nicks-original-format-server-quit) + (setq circe-aligned-nicks-original-format-server-quit + circe-format-server-quit)) + (setq circe-format-server-quit #'circe-aligned-nicks-server-quit-formatter) + + (if (null circe-aligned-nicks-original-format-server-quit-channel) + (setq circe-aligned-nicks-original-format-server-quit-channel + circe-format-server-quit-channel)) + (setq circe-format-server-quit-channel + #'circe-aligned-nicks-server-quit-channel-formatter) + + (if (null circe-aligned-nicks-original-format-server-part) + (setq circe-aligned-nicks-original-format-server-part + circe-format-server-part)) + (setq circe-format-server-part #'circe-aligned-nicks-server-part-formatter) + + (if (null circe-aligned-nicks-original-format-server-nick-change) + (setq circe-aligned-nicks-original-format-server-nick-change + circe-format-server-nick-change)) + (setq circe-format-server-nick-change + #'circe-aligned-nicks-server-nick-change-formatter)) + +(defun disable-circe-aligned-nicks () + (interactive) + (setq circe-format-say circe-aligned-nicks-original-format-say + circe-aligned-nicks-original-format-say nil + circe-format-self-say circe-aligned-nicks-original-format-self-say + circe-aligned-nicks-original-format-self-say nil + circe-format-action circe-aligned-nicks-original-format-action + circe-aligned-nicks-original-format-action nil + circe-format-self-action circe-aligned-nicks-original-format-self-action + circe-aligned-nicks-original-format-self-action nil + circe-format-server-message circe-aligned-nicks-original-format-server-message + circe-aligned-nicks-original-format-server-message nil + circe-format-server-join-in-channel circe-aligned-nicks-original-format-server-join-in-channel + circe-aligned-nicks-original-format-server-join-in-channel nil + circe-format-server-join circe-aligned-nicks-original-format-server-join + circe-aligned-nicks-original-format-server-join nil + circe-format-server-quit circe-aligned-nicks-original-format-server-quit + circe-aligned-nicks-original-format-server-quit nil + circe-format-server-quit-channel circe-aligned-nicks-original-format-server-quit-channel + circe-aligned-nicks-original-format-server-quit-channel nil + circe-format-server-part circe-aligned-nicks-original-format-server-part + circe-aligned-nicks-original-format-server-part nil + circe-format-server-nick-change circe-aligned-nicks-original-format-server-nick-change)) + +(provide 'circe-aligned-nicks) +;;; circe-aligned-nicks.el ends here