>From fab65a75b71d2800e5d549f01a746b3be98a0444 Mon Sep 17 00:00:00 2001 From: Barna Zsombor Date: Tue, 7 Apr 2020 16:46:51 +0200 Subject: [PATCH] Add ERC support for italic control characters ERC lacked support for the ']' control character, it didn't display italic text as italic. - Added erc-italic-face - Updated the regexes - Added cond branches and extended the let expressions --- lisp/erc/erc-goodies.el | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/lisp/erc/erc-goodies.el b/lisp/erc/erc-goodies.el index 94d5de280c..0e9b9384b3 100644 --- a/lisp/erc/erc-goodies.el +++ b/lisp/erc/erc-goodies.el @@ -241,6 +241,10 @@ erc-underline-face "ERC underline face." :group 'erc-faces) +(defface erc-italic-face '((t :slant italic)) + "ERC italic face." + :group 'erc-faces) + (defface fg:erc-color-face0 '((t :foreground "White")) "ERC face." :group 'erc-faces) @@ -385,6 +389,7 @@ erc-controls-interpret (let ((boldp nil) (inversep nil) (underlinep nil) + (italicp nil) (fg nil) (bg nil)) (while (string-match erc-controls-highlight-regexp s) @@ -405,6 +410,8 @@ erc-controls-interpret (setq inversep (not inversep))) ((string= control "\C-_") (setq underlinep (not underlinep))) + ((string= control "\C-]") + (setq italicp (not italicp))) ((string= control "\C-c") (setq fg nil bg nil)) @@ -419,7 +426,7 @@ erc-controls-interpret bg nil)) (t nil)) (erc-controls-propertize - start end boldp inversep underlinep fg bg s))) + start end boldp inversep underlinep italicp fg bg s))) s)) (t s))))) @@ -432,11 +439,11 @@ erc-controls-strip s))) (defvar erc-controls-remove-regexp - "\C-b\\|\C-_\\|\C-v\\|\C-g\\|\C-o\\|\C-c[0-9]?[0-9]?\\(,[0-9][0-9]?\\)?" + "\C-b\\|\C-_\\|\C-]\\|\C-v\\|\C-g\\|\C-o\\|\C-c[0-9]?[0-9]?\\(,[0-9][0-9]?\\)?" "Regular expression which matches control characters to remove.") (defvar erc-controls-highlight-regexp - (concat "\\(\C-b\\|\C-v\\|\C-_\\|\C-g\\|\C-o\\|" + (concat "\\(\C-b\\|\C-v\\|\C-_\\|\C-]\\|\C-g\\|\C-o\\|" "\C-c\\([0-9][0-9]?\\)?\\(,\\([0-9][0-9]?\\)\\)?\\)" "\\([^\C-b\C-v\C-_\C-c\C-g\C-o\n]*\\)") "Regular expression which matches control chars and the text to highlight.") @@ -453,6 +460,7 @@ erc-controls-highlight (let ((boldp nil) (inversep nil) (underlinep nil) + (italicp nil) (fg nil) (bg nil)) (while (re-search-forward erc-controls-highlight-regexp nil t) @@ -471,6 +479,8 @@ erc-controls-highlight (setq inversep (not inversep))) ((string= control "\C-_") (setq underlinep (not underlinep))) + ((string= control "\C-]") + (setq italicp (not italicp))) ((string= control "\C-c") (setq fg nil bg nil)) @@ -481,14 +491,15 @@ erc-controls-highlight (setq boldp nil inversep nil underlinep nil + italicp nil fg nil bg nil)) (t nil)) (erc-controls-propertize start end - boldp inversep underlinep fg bg))))) + boldp inversep underlinep italicp fg bg))))) (t nil))) -(defun erc-controls-propertize (from to boldp inversep underlinep fg bg +(defun erc-controls-propertize (from to boldp inversep underlinep italicp fg bg &optional str) "Prepend properties from IRC control characters between FROM and TO. If optional argument STR is provided, apply to STR, otherwise prepend properties @@ -506,6 +517,9 @@ erc-controls-propertize (if underlinep '(erc-underline-face) nil) + (if italicp + '(erc-italic-face) + nil) (if fg (list (erc-get-fg-color-face fg)) nil) -- 2.26.0