Created
June 27, 2014 08:58
-
-
Save ajchemist/592aafbc86b6e9f042d7 to your computer and use it in GitHub Desktop.
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
(defun rcirc-format-response-string (process sender response target text) | |
"Return a nicely-formatted response string, incorporating TEXT | |
\(and perhaps other arguments). The specific formatting used | |
is found by looking up RESPONSE in `rcirc-response-formats'." | |
(with-temp-buffer | |
(insert (or (cdr (assoc response rcirc-response-formats)) | |
(cdr (assq t rcirc-response-formats)))) | |
(goto-char (point-min)) | |
(let ((start (point-min)) | |
(sender (if (or (not sender) | |
(string= (rcirc-server-name process) sender)) | |
"" | |
sender)) | |
(decode (with-rcirc-process-buffer process | |
rcirc-decode-coding-system)) | |
face) | |
(while (re-search-forward "%\\(\\(f\\(.\\)\\)\\|\\(.\\)\\)" nil t) | |
(rcirc-add-face start (match-beginning 0) face) | |
(setq start (match-beginning 0)) | |
(replace-match | |
(cl-case (aref (match-string 1) 0) | |
(?f (setq face | |
(cl-case (string-to-char (match-string 3)) | |
(?w 'font-lock-warning-face) | |
(?p 'rcirc-server-prefix) | |
(?s 'rcirc-server) | |
(t nil))) | |
"") | |
(?n (decode-coding-string sender decode t)) | |
(?N (let ((my-nick (rcirc-nick process))) | |
(decode-coding-string | |
(save-match-data | |
(with-syntax-table rcirc-nick-syntax-table | |
(rcirc-facify sender | |
(cond ((string= sender my-nick) | |
'rcirc-my-nick) | |
((and rcirc-bright-nicks | |
(string-match | |
(regexp-opt rcirc-bright-nicks | |
'words) | |
sender)) | |
'rcirc-bright-nick) | |
((and rcirc-dim-nicks | |
(string-match | |
(regexp-opt rcirc-dim-nicks | |
'words) | |
sender)) | |
'rcirc-dim-nick) | |
(t | |
'rcirc-other-nick))))) | |
decode t))) | |
(?m (propertize text 'rcirc-text text)) | |
(?r response) | |
(?t (or target "")) | |
(t (concat "UNKNOWN CODE:" (match-string 0)))) | |
t t nil 0) | |
(rcirc-add-face (match-beginning 0) (match-end 0) face)) | |
(rcirc-add-face start (match-beginning 0) face)) | |
(buffer-substring (point-min) (point-max)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment