* Minor mode for colouring plain tex lowercase greek letters
@ 2021-01-11 9:10 michael-franzese
2021-01-11 19:36 ` michael-franzese
0 siblings, 1 reply; 2+ messages in thread
From: michael-franzese @ 2021-01-11 9:10 UTC (permalink / raw)
To: Help Gnu Emacs
Am trying to write a minor made to highlight tex keywords. I am starting
with the lowercase greek letters: \alpha, \beta, \gamma, \delta, \epsilon,
\zeta, \eta, \theta, \iota, \kappa, \lambda, \mu, \nu, \xi.
Do not know how I can set the lowercase greek letters to some colour.
I would have to assign a face to each regexp group rather than defining my own faces.
Reuse the font-lock faces that one can find on M-x find-library RET faces RET.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Minor mode for colouring plain tex lowercase greek letters
2021-01-11 9:10 Minor mode for colouring plain tex lowercase greek letters michael-franzese
@ 2021-01-11 19:36 ` michael-franzese
0 siblings, 0 replies; 2+ messages in thread
From: michael-franzese @ 2021-01-11 19:36 UTC (permalink / raw)
To: michael-franzese; +Cc: Help Gnu Emacs
Have put the following code te highlight greek letters using a minor mode
for texinfo-mode and the plani tex colouring commands \alpha \beta \gamma
are not being coloured.
(defun insert-ptex ()
(interactive)
(insert "ptex"))
(defvar ptex-mode-map
(let ((map (make-keymap)))
(define-key map (kbd "C-c t") 'insert-ptex)
map)
"Key map for use when variable `ptex-mode' is non-nil.")
(defvar ptex-mode-hook nil
"Hook called when variable `ptex-mode' is non-nil.")
(define-minor-mode ptex-mode
"Minor mode for colouring plain tex keywords."
:init-value nil
:global nil
:lighter " ptex"
:keymap ptex-mode-map
(run-hooks 'ptex-mode-hook))
(add-hook 'texinfo-mode-hook 'ptex-mode)
(defface colour-greek-category
'((default :inherit bold)
(((class color) (min-colors 88) (background light))
:foreground "#00FFFF")
(((class color) (min-colors 88) (background dark))
:foreground "#00FFFF")
(t :inherit font-lock-builtin-face))
"Face for header category entry.")
(defconst ptex-greek-keywords
'(("\\\\\\<\\(alpha\\|beta\\|gamma\\)\\>"
(1 'colour-greek-category)))
"Rules to apply font-lock highlighting.")
(defun ptex-assign-font-greek-keywords ()
"Font-lock setup for `ptex-greek-keywords'."
(font-lock-flush (point-min) (point-max))
(if ptex-mode
(font-lock-add-keywords nil ptex-greek-keywords t)
(font-lock-remove-keywords nil ptex-greek-keywords))
(font-lock-flush (point-min) (point-max)))
(add-hook 'texinfo-mode-hook #'ptex-assign-font-greek-keywords)
(provide 'ptex-mode)
> Sent: Monday, January 11, 2021 at 9:10 PM
> From: michael-franzese@gmx.com
> To: "Help Gnu Emacs" <help-gnu-emacs@gnu.org>
> Subject: Minor mode for colouring plain tex lowercase greek letters
>
> Am trying to write a minor made to highlight tex keywords. I am starting
> with the lowercase greek letters: \alpha, \beta, \gamma, \delta, \epsilon,
> \zeta, \eta, \theta, \iota, \kappa, \lambda, \mu, \nu, \xi.
>
> Do not know how I can set the lowercase greek letters to some colour.
>
> I would have to assign a face to each regexp group rather than defining my own faces.
> Reuse the font-lock faces that one can find on M-x find-library RET faces RET.
>
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-11 19:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-11 9:10 Minor mode for colouring plain tex lowercase greek letters michael-franzese
2021-01-11 19:36 ` michael-franzese
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.