+;; Filter out emoji, which cause severe display confusion.
+(defun mdw-replace-wide-characters (string)
+ (with-output-to-string
+ (let ((i 0)
+ (state nil))
+ (while (< i (length string))
+ (let ((ch (aref string i)))
+ (cond ((and (= (char-width ch) 1)
+ (not (or (<= #x1f200 ch #x1ffff))))
+ (when state (princ "*]") (setf state nil))
+ (write-char ch))
+ (t
+ (princ (if state "*" "[*"))
+ (princ (format "#x%x" ch))
+ (setf state t))))
+ (setq i (1+ i)))
+ (when state (princ "*]")))))
+
+(setq erc-replace-alist
+ '(("[[:nonascii:]+]" . mdw-replace-wide-characters)))
+