Created
November 12, 2012 22:08
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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