diff --git a/config.org b/config.org index 6b04cd0..79dc96a 100644 --- a/config.org +++ b/config.org @@ -5809,301 +5809,6 @@ panel. (select-window main-window)))) #+end_src -** IRC - -#+call: confpkg() - -=circe= is a client for IRC in Emacs (hey, isn't that a nice project -name+acronym), and a greek enchantress who turned humans into animals. - -Let's use the former to chat to +recluses+ discerning individuals online. - -[[xkcd:1782]] - -Before we start seeing and sending messages, we need to authenticate with our -IRC servers. The circe manual provided a snippet for putting some of the auth -details in =.authinfo.gpg= --- but I think we should go further than that: have -the entire server info in our authinfo. - -First, a reasonable format by which we can specify: -+ server -+ port -+ SASL username -+ SASL password -+ channels to join - -We can have these stored like so -#+begin_src authinfo -machine chat.freenode.net login USERNAME password PASSWORD port PORT for irc channels emacs,org-mode -#+end_src - -The ~for irc~ bit is used so we can uniquely identify all IRC auth info. By -omitting the =#= in channel names we can have a list of channels comma-separated -(no space!) which the secrets API will return as a single string. - -#+name: irc-authinfo-reader -#+begin_src emacs-lisp :tangle no -(defun auth-server-pass (server) - (if-let ((secret (plist-get (car (auth-source-search :host server)) :secret))) - (if (functionp secret) - (funcall secret) secret) - (error "Could not fetch password for host %s" server))) - -(defun register-irc-auths () - (require 'circe) - (require 'dash) - (let ((accounts (-filter (lambda (a) (string= "irc" (plist-get a :for))) - (auth-source-search :require '(:for) :max 10)))) - (appendq! circe-network-options - (mapcar (lambda (entry) - (let* ((host (plist-get entry :host)) - (label (or (plist-get entry :label) host)) - (ports (mapcar #'string-to-number - (s-split "," (plist-get entry :port)))) - (port (if (= 1 (length ports)) (car ports) ports)) - (user (plist-get entry :user)) - (nick (or (plist-get entry :nick) user)) - (channels (mapcar (lambda (c) (concat "#" c)) - (s-split "," (plist-get entry :channels))))) - `(,label - :host ,host :port ,port :nick ,nick - :sasl-username ,user :sasl-password auth-server-pass - :channels ,channels))) - accounts)))) -#+end_src - -We'll just call src_elisp{(register-irc-auths)} on a hook when we start Circe -up. - -Now we're ready to go, let's actually wire-up Circe, with one or two -configuration tweaks. -#+begin_src emacs-lisp :noweb no-export -(after! circe - (setq-default circe-use-tls t) - (setq circe-notifications-alert-icon "/usr/share/icons/breeze/actions/24/network-connect.svg" - lui-logging-directory (expand-file-name "irc" doom-etc-dir) - lui-logging-file-format "{buffer}/%Y/%m-%d.txt" - circe-format-self-say "{nick:+13s} โ”ƒ {body}") - - (custom-set-faces! - '(circe-my-message-face :weight unspecified)) - - (enable-lui-logging-globally) - (enable-circe-display-images) - - <> - - <> - <> - - (defun named-circe-prompt () - (lui-set-prompt - (concat (propertize (format "%13s > " (circe-nick)) - 'face 'circe-prompt-face) - ""))) - (add-hook 'circe-chat-mode-hook #'named-circe-prompt) - - (appendq! nerd-icons-mode-icon-alist - '((circe-channel-mode nerd-icons-mdicon "nf-md-message" :face nerd-icons-lblue) - (circe-server-mode nerd-icons-mdicon "nf-md-chat_outline" :face nerd-icons-purple)))) - -<> - -(add-transient-hook! #'=irc (register-irc-auths)) -#+end_src - -*** Org-style emphasis - -Let's do our *bold*, /italic/, and _underline_ in org-syntax, using IRC control characters. -#+name: org-emph-to-irc -#+begin_src emacs-lisp -(defun lui-org-to-irc () - "Examine a buffer with simple org-mode formatting, and converts the empasis: -,*bold*, /italic/, and _underline_ to IRC semi-standard escape codes. -=code= is converted to inverse (highlighted) text." - (goto-char (point-min)) - (while (re-search-forward "\\_<\\(?1:[*/_=]\\)\\(?2:[^[:space:]]\\(?:.*?[^[:space:]]\\)?\\)\\1\\_>" nil t) - (replace-match - (concat (pcase (match-string 1) - ("*" "") - ("/" "") - ("_" "") - ("=" "")) - (match-string 2) - "") nil nil))) - -(add-hook 'lui-pre-input-hook #'lui-org-to-irc) -#+end_src - -*** Emojis - -Let's setup Circe to use some emojis -#+name: circe-emojis -#+begin_src emacs-lisp :tangle no -(defun lui-ascii-to-emoji () - (goto-char (point-min)) - (while (re-search-forward "\\( \\)?::?\\([^[:space:]:]+\\):\\( \\)?" nil t) - (replace-match - (concat - (match-string 1) - (or (cdr (assoc (match-string 2) lui-emojis-alist)) - (concat ":" (match-string 2) ":")) - (match-string 3)) - nil nil))) - -(defun lui-emoticon-to-emoji () - (dolist (emoticon lui-emoticons-alist) - (goto-char (point-min)) - (while (re-search-forward (concat " " (car emoticon) "\\( \\)?") nil t) - (replace-match (concat " " - (cdr (assoc (cdr emoticon) lui-emojis-alist)) - (match-string 1)))))) - -(define-minor-mode lui-emojify - "Replace :emojis: and ;) emoticons with unicode emoji chars." - :global t - :init-value t - (if lui-emojify - (add-hook! lui-pre-input #'lui-ascii-to-emoji #'lui-emoticon-to-emoji) - (remove-hook! lui-pre-input #'lui-ascii-to-emoji #'lui-emoticon-to-emoji))) -#+end_src - -Now, some actual emojis to use. -#+name: circe-emoji-alists -#+begin_src emacs-lisp :tangle no -(defvar lui-emojis-alist - '(("grinning" . "๐Ÿ˜€") - ("smiley" . "๐Ÿ˜ƒ") - ("smile" . "๐Ÿ˜„") - ("grin" . "๐Ÿ˜") - ("laughing" . "๐Ÿ˜†") - ("sweat_smile" . "๐Ÿ˜…") - ("joy" . "๐Ÿ˜‚") - ("rofl" . "๐Ÿคฃ") - ("relaxed" . "โ˜บ๏ธ") - ("blush" . "๐Ÿ˜Š") - ("innocent" . "๐Ÿ˜‡") - ("slight_smile" . "๐Ÿ™‚") - ("upside_down" . "๐Ÿ™ƒ") - ("wink" . "๐Ÿ˜‰") - ("relieved" . "๐Ÿ˜Œ") - ("heart_eyes" . "๐Ÿ˜") - ("yum" . "๐Ÿ˜‹") - ("stuck_out_tongue" . "๐Ÿ˜›") - ("stuck_out_tongue_closed_eyes" . "๐Ÿ˜") - ("stuck_out_tongue_wink" . "๐Ÿ˜œ") - ("zanzy" . "๐Ÿคช") - ("raised_eyebrow" . "๐Ÿคจ") - ("monocle" . "๐Ÿง") - ("nerd" . "๐Ÿค“") - ("cool" . "๐Ÿ˜Ž") - ("star_struck" . "๐Ÿคฉ") - ("party" . "๐Ÿฅณ") - ("smirk" . "๐Ÿ˜") - ("unamused" . "๐Ÿ˜’") - ("disapointed" . "๐Ÿ˜ž") - ("pensive" . "๐Ÿ˜”") - ("worried" . "๐Ÿ˜Ÿ") - ("confused" . "๐Ÿ˜•") - ("slight_frown" . "๐Ÿ™") - ("frown" . "โ˜น๏ธ") - ("persevere" . "๐Ÿ˜ฃ") - ("confounded" . "๐Ÿ˜–") - ("tired" . "๐Ÿ˜ซ") - ("weary" . "๐Ÿ˜ฉ") - ("pleading" . "๐Ÿฅบ") - ("tear" . "๐Ÿ˜ข") - ("cry" . "๐Ÿ˜ข") - ("sob" . "๐Ÿ˜ญ") - ("triumph" . "๐Ÿ˜ค") - ("angry" . "๐Ÿ˜ ") - ("rage" . "๐Ÿ˜ก") - ("exploding_head" . "๐Ÿคฏ") - ("flushed" . "๐Ÿ˜ณ") - ("hot" . "๐Ÿฅต") - ("cold" . "๐Ÿฅถ") - ("scream" . "๐Ÿ˜ฑ") - ("fearful" . "๐Ÿ˜จ") - ("disapointed" . "๐Ÿ˜ฐ") - ("relieved" . "๐Ÿ˜ฅ") - ("sweat" . "๐Ÿ˜“") - ("thinking" . "๐Ÿค”") - ("shush" . "๐Ÿคซ") - ("liar" . "๐Ÿคฅ") - ("blank_face" . "๐Ÿ˜ถ") - ("neutral" . "๐Ÿ˜") - ("expressionless" . "๐Ÿ˜‘") - ("grimace" . "๐Ÿ˜ฌ") - ("rolling_eyes" . "๐Ÿ™„") - ("hushed" . "๐Ÿ˜ฏ") - ("frowning" . "๐Ÿ˜ฆ") - ("anguished" . "๐Ÿ˜ง") - ("wow" . "๐Ÿ˜ฎ") - ("astonished" . "๐Ÿ˜ฒ") - ("sleeping" . "๐Ÿ˜ด") - ("drooling" . "๐Ÿคค") - ("sleepy" . "๐Ÿ˜ช") - ("dizzy" . "๐Ÿ˜ต") - ("zipper_mouth" . "๐Ÿค") - ("woozy" . "๐Ÿฅด") - ("sick" . "๐Ÿคข") - ("vomiting" . "๐Ÿคฎ") - ("sneeze" . "๐Ÿคง") - ("mask" . "๐Ÿ˜ท") - ("bandaged_head" . "๐Ÿค•") - ("money_face" . "๐Ÿค‘") - ("cowboy" . "๐Ÿค ") - ("imp" . "๐Ÿ˜ˆ") - ("ghost" . "๐Ÿ‘ป") - ("alien" . "๐Ÿ‘ฝ") - ("robot" . "๐Ÿค–") - ("clap" . "๐Ÿ‘") - ("thumpup" . "๐Ÿ‘") - ("+1" . "๐Ÿ‘") - ("thumbdown" . "๐Ÿ‘Ž") - ("-1" . "๐Ÿ‘Ž") - ("ok" . "๐Ÿ‘Œ") - ("pinch" . "๐Ÿค") - ("left" . "๐Ÿ‘ˆ") - ("right" . "๐Ÿ‘‰") - ("down" . "๐Ÿ‘‡") - ("wave" . "๐Ÿ‘‹") - ("pray" . "๐Ÿ™") - ("eyes" . "๐Ÿ‘€") - ("brain" . "๐Ÿง ") - ("facepalm" . "๐Ÿคฆ") - ("tada" . "๐ŸŽ‰") - ("fire" . "๐Ÿ”ฅ") - ("flying_money" . "๐Ÿ’ธ") - ("lighbulb" . "๐Ÿ’ก") - ("heart" . "โค๏ธ") - ("sparkling_heart" . "๐Ÿ’–") - ("heartbreak" . "๐Ÿ’”") - ("100" . "๐Ÿ’ฏ"))) - -(defvar lui-emoticons-alist - '((":)" . "slight_smile") - (";)" . "wink") - (":D" . "smile") - ("=D" . "grin") - ("xD" . "laughing") - (";(" . "joy") - (":P" . "stuck_out_tongue") - (";D" . "stuck_out_tongue_wink") - ("xP" . "stuck_out_tongue_closed_eyes") - (":(" . "slight_frown") - (";(" . "cry") - (";'(" . "sob") - (">:(" . "angry") - (">>:(" . "rage") - (":o" . "wow") - (":O" . "astonished") - (":/" . "confused") - (":-/" . "thinking") - (":|" . "neutral") - (":-|" . "expressionless"))) -#+end_src - ** Newsfeed #+call: confpkg()