Skip to content

Instantly share code, notes, and snippets.

@randymorris
Created November 12, 2012 22:08
Show Gist options
  • Save randymorris/4062314 to your computer and use it in GitHub Desktop.
Save randymorris/4062314 to your computer and use it in GitHub Desktop.
Right align nicks in rcirc so messages all start at the same column
(defvar rcirc-max-nick-length 10
"Maxmimum nick length used for right-aligned nicks.")
(defun rcirc-markup-right-align-nicks (sender response)
"Right align nicks, truncating at `rcirc-max-nick-length'."
(goto-char (point-min))
(string-match "^..:.. <\\([^>]+\\)>" (buffer-string))
(let* ((length rcirc-max-nick-length)
(nick (match-string 1 (buffer-string)))
(nick* (format (format "%%%ds" length) nick))
(nick* (truncate-string-to-width nick* length)))
(while (search-forward (format "<%s>" nick) nil t)
(replace-match (format "<%s>" nick*) nil t))))
(add-to-list 'rcirc-markup-text-functions 'rcirc-markup-right-align-nicks)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment