#+TITLE: mms Emacs Config - IRC #+AUTHOR: MichaƂ Sapka (https://michal.sapka.me) #+STARTUP: showall indent logdone #+HUGO_BASE_DIR: ~/ghq/vcs.sapka.me/michal-sapka-me/ #+HUGO_WEIGHT: 20 #+HUGO_SECTION: emacs/config #+HUGO_CATEGORIES: emacs emacs-config #+HUGO_MENU :menu "emacs-config" :name GUI #+HUGO_CUSTOM_FRONT_MATTER: :abstract "My emacs config - GUI look and feel" #+HUGO_CUSTOM_FRONT_MATTER: :menu-abstract "The way Emacs look in gui mode" #+EXPORT_FILE_NAME: gui * ERC setup #+begin_src emacs-lisp (setq erc-autojoin-channels-alist '(("tilde.chat" "#emacs.ch") ("libera.chat" "##bsd" "#emacs" "#erc" "##sci-fi" "##startrek" "##anime" "#usenet" "#poland"))) #+end_src Handle nickserver: #+begin_src emacs-lisp (require 'erc-services) (erc-services-mode 1) (setq erc-use-auth-source-for-nickserv-password "t") #+end_src Show mew where I left off: url: https://www.emacswiki.org/emacs/ErcBar #+begin_src emacs-lisp (eval-after-load 'erc-track '(progn (defun erc-bar-move-back (n) "Moves back n message lines. Ignores wrapping, and server messages." (interactive "nHow many lines ? ") (re-search-backward "^.*<.*>" nil t n)) (defun erc-bar-update-overlay () "Update the overlay for current buffer, based on the content of erc-modified-channels-alist. Should be executed on window change." (interactive) (let* ((info (assq (current-buffer) erc-modified-channels-alist)) (count (cadr info))) (if (and info (> count erc-bar-threshold)) (save-excursion (end-of-buffer) (when (erc-bar-move-back count) (let ((inhibit-field-text-motion t)) (move-overlay erc-bar-overlay (line-beginning-position) (line-end-position) (current-buffer))))) (delete-overlay erc-bar-overlay)))) (defvar erc-bar-threshold 1 "Display bar when there are more than erc-bar-threshold unread messages.") (defvar erc-bar-overlay nil "Overlay used to set bar") (setq erc-bar-overlay (make-overlay 0 0)) (overlay-put erc-bar-overlay 'face '(:underline "black")) ;;put the hook before erc-modified-channels-update (defadvice erc-track-mode (after erc-bar-setup-hook (&rest args) activate) ;;remove and add, so we know it's in the first place (remove-hook 'window-configuration-change-hook 'erc-bar-update-overlay) (add-hook 'window-configuration-change-hook 'erc-bar-update-overlay)) (add-hook 'erc-send-completed-hook (lambda (str) (erc-bar-update-overlay))))) #+end_src Color nicks src:https://www.emacswiki.org/emacs/ErcNickColors #+begin_src emacs-lisp (defmacro unpack-color (color red green blue &rest body) `(let ((,red (car ,color)) (,green (car (cdr ,color))) (,blue (car (cdr (cdr ,color))))) ,@body)) (defun rgb-to-html (color) (unpack-color color red green blue (concat "#" (format "%02x%02x%02x" red green blue)))) (defun hexcolor-luminance (color) (unpack-color color red green blue (floor (+ (* 0.299 red) (* 0.587 green) (* 0.114 blue))))) (defun invert-color (color) (unpack-color color red green blue `(,(- 255 red) ,(- 255 green) ,(- 255 blue)))) (defun erc-get-color-for-nick (nick dark) (let* ((hash (md5 (downcase nick))) (red (mod (string-to-number (substring hash 0 10) 16) 256)) (blue (mod (string-to-number (substring hash 10 20) 16) 256)) (green (mod (string-to-number (substring hash 20 30) 16) 256)) (color `(,red ,green ,blue))) (rgb-to-html (if (if dark (< (hexcolor-luminance color) 85) (> (hexcolor-luminance color) 170)) (invert-color color) color)))) (defun erc-highlight-nicknames () (save-excursion (goto-char (point-min)) (while (re-search-forward "\\w+" nil t) (let* ((bounds (bounds-of-thing-at-point 'symbol)) (nick (buffer-substring-no-properties (car bounds) (cdr bounds)))) (when (erc-get-server-user nick) (put-text-property (car bounds) (cdr bounds) 'face (cons 'foreground-color (erc-get-color-for-nick nick 't)))))))) (add-hook 'erc-insert-modify-hook 'erc-highlight-nicknames) #+end_src #+begin_src emacs-lisp (defun mms-irc-mode() "use this instance of Emacs for IRC" (interactive) (setq mms-bright-theme 'ef-cyprus mms-dark-theme 'ef-bio) (mms-dark-room-mode) (erc-tls :server "irc.tilde.chat" :port "6697" :nick "mms" :full-name "https://michal.sapka.me") (erc-tls :server "irc.libera.chat" :port "6697" :nick "mms" :full-name "https://michal.sapka.me") ) #+end_src