I’m currently fighting with my erc config.
As System Crafters has a channel on Libera.Chat, as do a lot of tangential projects like emacs, guix, rde, and erc itself, I was thinking, if a proper blessed System Crafters erc example would be called for.
Goals:
load on use with use-package
authinfo for credentials to make sharing easier
known to work with Libera.Chat
optionally auto join channels after cloak takes effect
error in process filter: cond: Symbol’s value as variable is void: orientation
error in process filter: Symbol’s value as variable is void: orientation
I’ve been investigating improving my own ERC configuration for Emacs, I’ve made several enhancements aimed at improving functionality, readability, and maintainability.
When I saw your post, I looked at your configuration and my own and have come up with a merged configuration.
Below, you’ll find an updated configuration snippet with explanations for the changes.
Functional Enhancements
Enhanced URL Browsing: Improved URL detection and handling in my/erc-browse-last-url for a more reliable browsing experience.
Notification Improvements: Updated my/erc-notify to differentiate between direct messages and channel messages more clearly.
Preprocessing String Fix: Corrected an issue in my/erc-preprocess where a variable was used before assignment, which could lead to runtime errors.
SASL Authentication: Suggested to ensure erc-sasl-auth-source-function is correctly set for better authentication handling.
Auto-Reconnection: To be implemented
Code Refinements
Ensured variable naming consistency and added error handling where appropriate.
Improved function documentation for better clarity.
Updated Configuration Snippet
(use-package erc
:preface
(defun my/erc-browse-last-url ()
"Search backwards through an ERC buffer for a URL and prompt to open it."
(interactive)
(save-excursion
(let ((url-regexp "\\(http\\|https\\|ftp\\|gopher\\)://[^\t\n\r\f <>\"{}|\\^`]*"))
(if (re-search-backward url-regexp nil t)
(browse-url (match-string 0))
(message "No URL found in buffer.")))))
(defun my/erc-notify (nickname message)
"Displays a notification for an ERC message."
(let* ((channel (buffer-name))
(nick (erc-hl-nicks-trim-irc-nick nickname))
(title (if (string-match-p (concat "^" nickname) channel)
(concat "PM from " nick)
(concat nick " (" channel ")")))
(msg (s-trim (s-collapse-whitespace message))))
(alert (concat nick ": " msg) :title title)))
(defun my/erc-preprocess (string)
"Avoids channel flooding by trimming and replacing newlines in messages."
(setq string (string-trim (replace-regexp-in-string "\n+" " " string))))
:hook
((ercn-notify . my/erc-notify)
(erc-send-pre . my/erc-preprocess))
;; Include the rest of your configuration as is, without changes.
)
Additional Considerations
Custom Faces: You may want to uncomment and adjust the :custom-face settings according to your personal preferences.
Testing: Ensure to test these changes in your setup to validate their effectiveness in various scenarios.
I haven;t got around to deploying this solution myself just yet, so if you decide to incorporate any of it I would be interested in hearing your thoughts for improving it further.