help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: font-lock as a single command


From: Christopher Dimech
Subject: Re: font-lock as a single command
Date: Sat, 13 Feb 2021 06:51:53 +0100

Have added "font-lock-fontify-region" and supinf gets activated
as soon as I enter the key-sequence "H-t".

(defun supinf-enable ()
  "Enables a typeface for displaying tex commands."
  (interactive)
  (setq-local supinf-signal t)
  ;; Syntax for font-lock-add-keywords is
  ;;   (font-lock-add-keywords MODE KEYWORDS &optional HOW)
  (font-lock-add-keywords nil
     '(  (supinf-match (1 (supinf-raise-cruc (match-beginning 0)))) )
     t)
  (font-lock-fontify-region (point-min) (point-max))
  )




> Sent: Saturday, February 13, 2021 at 5:43 PM
> From: "Emanuel Berg via Users list for the GNU Emacs text editor" 
> <help-gnu-emacs@gnu.org>
> To: help-gnu-emacs@gnu.org
> Subject: Re: font-lock as a single command
>
> Christopher Dimech wrote:
>
> > There is something interesting to tell you. When I call "M-x
> > supinf-enable" nothing happens, but when I start writing
> > (e.g. "\alpha_{ij}"), as soon as I enter "_" the suscript
> > functionality gets enabled for the whole buffer.
> >
> > Could you help on what is going on?
>
> Here is how I would do it, for starters:
>
> \alpha^{high}
> \beta_{low}
>
> (progn
>   (font-lock-add-keywords
>    'emacs-lisp-mode
>    '(
>      ("\\^{\\([[:alnum:]]*\\)}" 1 font-lock-builtin-face)
>      ("_{\\([[:alnum:]]*\\)}"   1 font-lock-function-name-face)
>      )
>    t)
>   (text-mode)
>   (emacs-lisp-mode) )
> ;;                   ^ eval
>
> You can see the result in this screenshot:
>
>   https://dataswamp.org/~incal/figures/emacs/high-low.png
>
> --
> underground experts united
> http://user.it.uu.se/~embe8573
> https://dataswamp.org/~incal
>
>
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]