From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Christopher Dimech Newsgroups: gmane.emacs.help Subject: Re: font-lock as a single command Date: Sat, 13 Feb 2021 02:13:19 +0100 Message-ID: References: <87lfbsdf7i.fsf@zoho.eu> <87a6s8de2x.fsf@zoho.eu> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38566"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs@gnu.org, moasenwood@zoho.eu To: Christopher Dimech Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 13 02:57:48 2021 Return-path: Envelope-to: geh-help-gnu-emacs@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 1lAkBw-0009u9-G9 for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 13 Feb 2021 02:57:48 +0100 Original-Received: from localhost ([::1]:52058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lAkBv-0002fF-Ip for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 12 Feb 2021 20:57:47 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35740) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lAk9P-0001la-CS for help-gnu-emacs@gnu.org; Fri, 12 Feb 2021 20:55:11 -0500 Original-Received: from mout.gmx.net ([212.227.17.20]:60111) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lAk93-0001CM-9H for help-gnu-emacs@gnu.org; Fri, 12 Feb 2021 20:55:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1613181287; bh=az7H+sanQBm06illeMr4n/tMVi8krCvSI6vsuvcKHBc=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=QoNBZTX263goX4UH2lpDLYe2Cd0KLA48IICgD9V0Zfo49t6K+TFIfkZUAqpqHV34o QbE52L2F7QCW0l2Zo/ezDRa/R4EN93ocStfNjViTtxDesSkb8/1FAVMyPC70amHOl5 TvUdyPuiSopnuaxItvab8/2wTExA8BSebJA5UMoM= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from [213.165.168.94] ([213.165.168.94]) by web-mail.gmx.net (3c-app-mailcom-bs05.server.lan [172.19.170.173]) (via HTTP); Sat, 13 Feb 2021 02:13:19 +0100 Importance: normal Sensitivity: Normal In-Reply-To: X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:SUzX4zCruMM2vYR/rqmee8lPHTVvhs4RJ4X7MmuP3KZETjtK1DjMgC5NUjxx0xAxzfJkl 23+nN9XsXnmRfJ2/nobaaXdy1zGn9Q4dBgKSR499Bta753lRiXjHBsqDse8lfFix7h/MfIQemRLj EozKVCoHXoND5kUndwnFi6igk6juZ1R36MUsA2+LKhttrEY/V3u/A6UtUXtEu2lEj0/7+TzbfyWU KnxtVqAERDiMuIpjPi032W1ZHgveT4RHT8Tv8XTrD/sGqWNpLUeyBLlS1tAidjBeXfMJunBe0/Bw Ng= X-UI-Out-Filterresults: notjunk:1;V03:K0:l9kgybcx5hA=:q+BChynk6cy+frYtBzIs07 bQXW5TpZFB8o+9Nd7UwbfhWAxViPb36M1I6h1F1Kp0BAbf3cAGt8POw2W2OPWO9PasuIeHv5H 63RQUJW5G0hYC5RQA2x8FvU1YNZBE4BGDFeXcykjBSyH2yWLmPkAGwHdKNihSxu8iKnr1387w SWaNF+gUzOaQE2Wf7Y1PIYiNQTnSEFFVsV7OwKGBd8VuAfLRajYyMW1Q4fepCM8b5KuO+Uxjz fdUrSWRzEiogio8f093B41j0cEKAGAvGKKWTK8h4rZBR7V+3IAwd9Aff3ZzPC9jmu3Y5pcjhE ZvlAfbF+vVvUl8z9gKJ6I8s0ryp/EfU7n0Hx5rNhwsODevXgp+l/kHeK9VPIzYRR+4ecMc6S3 oI8cIdr7J6XG5XezDYDVmG/VeMHzXZHwwEAXqKRqqfIO1xW0JA4I1nyaK9vtK1eG5deicbo1L e7Go39k70OnGGRr3zU3ZFEjCNBBhK1SWbNYIBFQnF9k9i7lw3XdxrANj6NUFPwkVpaDHyhqMf HaAx0a2SY+/EjjLu7XgpNkC+H6izhoD6lV+/uejoCpGMaRRwzk01NamAeSBbZZ8LNYmgjVk+T SrHF/XnrdytJE= Received-SPF: pass client-ip=212.227.17.20; envelope-from=dimech@gmx.com; helo=mout.gmx.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:127885 Archived-At: I do not know how good the following defun is to disable the lowering and raising typeface=2E I got it from "tex-mode=2Eel" but do not really know how to use it=2E (defun supinf-disable-cruc (beg end) "Set typeface for text between BEG and END=2E" (font-lock-default-unfontify-region beg end) (while (< beg end) (let ((next (next-single-property-change beg 'display nil end)) (prop (get-text-property beg 'display))) (if (and (eq (car-safe prop) 'raise) (member (car-safe (cdr prop)) deviat-supinf) (null (cddr prop))) (put-text-property beg next 'display nil)) (setq beg next)))) > Sent: Saturday, February 13, 2021 at 12:58 PM > From: "Christopher Dimech" > To: moasenwood@zoho=2Eeu > Cc: help-gnu-emacs@gnu=2Eorg > Subject: Re: font-lock as a single command > > I have the following three defun >=20 > "supinf-match" matches superscript and subscript code structures=2E > In the following example "\alpha^{ijk} \beta_{pqr}", {ijk} is > rained in height, whereas {pqr} is lowered in height=2E=20 > The raising and lowering is achieved by calling "supinf-raise-cruc"=2E >=20 > "supinf-enable" sets the new typeface using "font-lock-add-keywords"=2E > I also want a function that disables the raising and lowering, returning > the buffer to how it was before "supinf-enable" was called=2E >=20 >=20 > (defun supinf-raise-cruc (pos) > "Raise and lower typeface at position POS=2E" > (unless (or (memq (get-text-property pos 'face) > '(font-lock-constant-face font-lock-builtin-face)) > ;; Check for backslash quoting > (let ((odd nil) (pos pos)) > (while (eq (char-before pos) ?\\) > (setq pos (1- pos) odd (not odd))) > odd)) > (if (eq (char-after pos) ?^) > `(face supr-tfc display (raise ,(car deviat-supinf))) > `(face infr-tfc display (raise ,(cadr deviat-supinf))) ))) >=20 > (defun supinf-match (limit) > "Match superior and inferior glyph patterns up to LIMIT=2E" > (when (and supinf-signal > (re-search-forward "[_^] *\\([^\n\\{}]\\|\ > \\\\\\([a-zA-Z@]+\\|[^ \t\n]\\)\\|\\({\\)\\)" limit t)) > (when (match-end 3) > (let ((beg (match-beginning 3)) > (end (save-restriction > (narrow-to-region (point-min) limit) > (condition-case nil > (scan-lists (point) 1 1) (error nil))))) > ;; body of let > (store-match-data > (if end > (list (match-beginning 0) end beg end) > (list beg beg beg beg))))) > t)) >=20 > (defun supinf-enable () > "Enables a typeface for displaying tex commands=2E" > (setq 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)) >=20 >=20 >=20 > > Sent: Saturday, February 13, 2021 at 12:08 PM > > From: "Emanuel Berg via Users list for the GNU Emacs text editor" > > To: help-gnu-emacs@gnu=2Eorg > > Subject: Re: font-lock as a single command > > > > Christopher Dimech wrote: > >=20 > > > (font-lock-add-keywords MODE KEYWORDS &optional HOW) > > > > > > What does the optional HOW actually do? > >=20 > > It is actually described in the docstring: > >=20 > > If optional argument HOW is =E2=80=98set=E2=80=99, they are used to = replace > > the current highlighting list=2E If HOW is any other non-nil > > value, they are added at the end of the current > > highlighting list=2E > >=20 > > --=20 > > underground experts united > > http://user=2Eit=2Euu=2Ese/~embe8573 > > https://dataswamp=2Eorg/~incal > >=20 > >=20 > > >=20 >