From cbc98a0a6da81f5782473767f5e0cc001bd37942 Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Fri, 15 Oct 2010 13:19:39 +0900 Subject: [PATCH 1/1] Make "^C[,]" ctlseq matching robuster. * riece-ctlseq.el (riece-ctlseq-colors): Add an example setting to the doc. (riece-ctlseq-regexp, riece-ctlseq-update-attribute): Make "^C[,]" matching robuster. Thanks to Akira TAGOH. --- lisp/ChangeLog | 8 ++++++++ lisp/riece-ctlseq.el | 24 +++++++++++++++--------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9b3cbaa..50720c8 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,11 @@ +2010-10-15 Daiki Ueno + + * riece-ctlseq.el (riece-ctlseq-colors): Add an example setting to + the doc. + (riece-ctlseq-regexp, riece-ctlseq-update-attribute): Make + "^C[,]" matching robuster. + Thanks to Akira TAGOH. + 2010-10-15 Daiki Ueno * riece-ctlseq.el (riece-ctlseq-regexp): New constant. diff --git a/lisp/riece-ctlseq.el b/lisp/riece-ctlseq.el index b1bb87d..5b3842b 100644 --- a/lisp/riece-ctlseq.el +++ b/lisp/riece-ctlseq.el @@ -40,7 +40,14 @@ '("white" "black" "red" "orange" "yellow" "LightGreen" "DarkOliveGreen" "cyan4" "turquoise" "blue" "black" "black" "black" "black" "black" "DarkBlue" "purple1" "purple2" "purple3" "magenta") - "List of colors can be used with ^C,." + "List of colors can be used with ^C,. + +To set up colors compatible with X-Chat and mIRC, do: +\(setq riece-ctlseq-colors '(\"#cecece\" \"black\" \"#0000cc\" \"#00cc00\" + \"#dd0000\" \"#aa0000\" \"#bb00bb\" \"#ffaa00\" + \"#eedd22\" \"#33de55\" \"#00cccc\" \"#33eeff\" + \"#0000ff\" \"#ee22ee\" \"#777777\" \"#999999\")) +" :group 'riece-ctlseq :type '(repeat (string :tag "Color"))) @@ -61,7 +68,7 @@ "Mark up control sequences in IRC buffers.") (defconst riece-ctlseq-regexp - "[\x2\xF\x16\x1F]\\|\x3\\([0-9]+\\)?\\(,[0-9]+\\)?") + "[\x2\xF\x16\x1F]\\|\x3\\([0-9][0-9]?\\)\\(,[0-9][0-9]?\\)?") (defun riece-ctlseq-compatible-attributes-p (this other) (let ((pointer this)) @@ -148,15 +155,14 @@ ((eq (aref tag 0) ?\x1F) ;^_ (setq attrs (plist-put attrs 'underline (not (plist-get attrs 'underline))))) - ((string-match "\x3\\([0-9]+\\)?\\(,[0-9]+\\)?" tag) ;^C, - (if (match-beginning 1) - (setq attrs (plist-put attrs 'foreground - (nth (string-to-number (match-string 1 tag)) - riece-ctlseq-colors)))) - (if (match-beginning 2) + ((eq (aref tag 0) ?\x3) ;^C[,] + (setq attrs (plist-put attrs 'foreground + (nth (string-to-number (substring tag 1)) + riece-ctlseq-colors))) + (if (string-match "," tag) (setq attrs (plist-put attrs 'background (nth (string-to-number - (substring (match-string 2 tag) 1)) + (substring tag (match-end 0))) riece-ctlseq-colors)))))) attrs)) -- 2.25.1