Skip to content

Instantly share code, notes, and snippets.

@legumbre
Created May 8, 2013 00:00
Show Gist options
  • Save legumbre/5537184 to your computer and use it in GitHub Desktop.
Save legumbre/5537184 to your computer and use it in GitHub Desktop.
(defun erc-format-privmessage (nick msg privp msgp)
"Format a PRIVMSG in an insertable fashion."
(let* ((mark-s (if msgp (if privp "*" "") "-"))
(mark-e (if msgp (if privp "*" ">") "-"))
(str (format "%s%s%s %s" mark-s nick mark-e msg))
(nick-face (if privp 'erc-nick-msg-face 'erc-nick-default-face))
(msg-face (if privp 'erc-direct-msg-face 'erc-default-face)))
;; add text properties to text before the nick, the nick and after the nick
(erc-put-text-property 0 (length mark-s) 'face msg-face str)
(erc-put-text-property (length mark-s) (+ (length mark-s) (length nick))
'face nick-face str)
(erc-put-text-property (+ (length mark-s) (length nick)) (length str)
'face msg-face str)
str))
(setq erc-insert-timestamp-function 'erc-insert-timestamp-right)
(setq erc-timestamp-format "%H:%M")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment