From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Barna Zsombor Newsgroups: gmane.emacs.erc.general,gmane.emacs.devel Subject: Patch: ERC italic text support Date: Tue, 7 Apr 2020 17:27:01 +0200 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------CEE9C49131EF0B1D9CFAEE1E" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="84838"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 To: emacs-devel@gnu.org, emacs-erc@gnu.org Original-X-From: emacs-erc-bounces+sf-erc-help=m.gmane-mx.org@gnu.org Tue Apr 07 17:32:37 2020 Return-path: Envelope-to: sf-erc-help@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jLqDM-000Ly8-SL for sf-erc-help@m.gmane-mx.org; Tue, 07 Apr 2020 17:32:36 +0200 Original-Received: from localhost ([::1]:49346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLqDL-0006N2-Rg for sf-erc-help@m.gmane-mx.org; Tue, 07 Apr 2020 11:32:35 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39673) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLq86-0005Mr-2B for emacs-erc@gnu.org; Tue, 07 Apr 2020 11:27:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLq84-0003lo-TS for emacs-erc@gnu.org; Tue, 07 Apr 2020 11:27:10 -0400 Original-Received: from relay-1.mailobj.net ([213.182.54.6]:49314) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLq82-0003ca-2c; Tue, 07 Apr 2020 11:27:06 -0400 Original-Received: from v-2c.localdomain (unknown [192.168.90.162]) by relay-1.mailobj.net (Postfix) with SMTP id 6095F122E; Tue, 7 Apr 2020 17:27:02 +0200 (CEST) Original-Received: by mail-2.net-c.com [213.182.54.29] with ESMTP Tue, 7 Apr 2020 17:27:02 +0200 (CEST) X-EA-Auth: 8UjI1Zm/RRDjHJT3MDtAiLkiVq9BajewcQ1lYZ/HgkxLZ8DF3Bjhp756Vr2OJGRBICXTU9f/9Q85QhP6Oyw+ORjCCWmiRKJ+FbgaX42QdGA= Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 213.182.54.6 X-Mailman-Approved-At: Tue, 07 Apr 2020 11:32:32 -0400 X-BeenThere: emacs-erc@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: General discussion about ERC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-erc-bounces+sf-erc-help=m.gmane-mx.org@gnu.org Original-Sender: "emacs-erc" Xref: news.gmane.io gmane.emacs.erc.general:1479 gmane.emacs.devel:246613 Archived-At: This is a multi-part message in MIME format. --------------CEE9C49131EF0B1D9CFAEE1E Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Hi, It was a major discomfort for me that ERC had no support for italic text ( \C-] ), so I "scratched that itch". I attached the patch as requested in CONTRIBUTE. I am a first-time contributor to Emacs so I'd like to request a copy of the copyright assignment. Best wishes, Zsombor Barna --------------CEE9C49131EF0B1D9CFAEE1E Content-Type: text/x-patch; charset=UTF-8; name="0001-Add-ERC-support-for-italic-control-characters.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Add-ERC-support-for-italic-control-characters.patch" >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 --------------CEE9C49131EF0B1D9CFAEE1E--