* Patch: ERC italic text support
@ 2020-04-07 15:27 Barna Zsombor
2020-04-07 16:20 ` Eli Zaretskii
0 siblings, 1 reply; 5+ messages in thread
From: Barna Zsombor @ 2020-04-07 15:27 UTC (permalink / raw)
To: emacs-devel, emacs-erc
[-- Attachment #1: Type: text/plain, Size: 296 bytes --]
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
[-- Attachment #2: 0001-Add-ERC-support-for-italic-control-characters.patch --]
[-- Type: text/x-patch, Size: 4700 bytes --]
From fab65a75b71d2800e5d549f01a746b3be98a0444 Mon Sep 17 00:00:00 2001
From: Barna Zsombor <unibro@mailo.com>
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-04-07 21:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-07 15:27 Patch: ERC italic text support Barna Zsombor
2020-04-07 16:20 ` Eli Zaretskii
2020-04-07 16:35 ` copyright assignment (Re: Patch: ERC italic text support) Emanuel Berg via Emacs development discussions.
2020-04-07 18:58 ` Eli Zaretskii
2020-04-07 21:15 ` Emanuel Berg via Emacs development discussions.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.