Blog - /Personal
Here's an Emacs Lisp snippet for ERC that removes trailing whitespace from every private message (i.e. query window conversation) that is received. It's useful for dealing with the OTR (off-the-record) plugin that some people use for privacy enhancement, which sends a noticeable amount of trailing whitespace for its first couple messages.
While making the initial version of this last month, I forgot to have
the function return nil, which managed to wipe every single Jabber IM
message sent to me at work for two days. Oops. This has of course
been fixed in the code I am pasting here.
(defun my-erc-remove-trailing-whitespace (proc parsed) "Remove trailing whitespace from the current message. Some IM clients use an OTR plug-in that sends some annoying trailing space to the screen, so we want to mop that up." (let ((msg (erc-response.contents parsed))) (when (stringp msg) (setf (erc-response.contents parsed) (erc-replace-regexp-in-string "[[:space:]]+\\'" "" msg)) nil))) (add-hook 'erc-server-PRIVMSG-functions 'my-erc-remove-trailing-whitespace)
Add a comment