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 01:58:37 +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="34773"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs@gnu.org To: moasenwood@zoho.eu Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 13 01:59:24 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 1lAjHQ-0008vH-0a for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 13 Feb 2021 01:59:24 +0100 Original-Received: from localhost ([::1]:42524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lAjHP-0003rG-2p for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 12 Feb 2021 19:59:23 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52738) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lAjGn-0003qw-JN for help-gnu-emacs@gnu.org; Fri, 12 Feb 2021 19:58:45 -0500 Original-Received: from mout.gmx.net ([212.227.17.21]:58205) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lAjGh-0005Ba-Sz for help-gnu-emacs@gnu.org; Fri, 12 Feb 2021 19:58:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1613177917; bh=OOygNHIzeV07pf20ubeI9bidtMoyBpdkI3QJLy2msOc=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=W3lNPU8GUqpZtsejbM+ypa9OqsXR8A87Oy78nFzdKUPKGLxqSBXno+IxvvqGszLjw VEHziuPE/R3nroOZTU2pUZxvBQJqufLSkKWNKOnD9eFknVgn2kVKTSTeJW1K6YoNxM nEtDgwQvXqO0/JUv8IQivTBYoeaKtkwkbzadia0k= 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 01:58:37 +0100 Importance: normal Sensitivity: Normal In-Reply-To: <87a6s8de2x.fsf@zoho.eu> X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:o8fQryL95/0gJVWkyXO5Tw/EPBwFLiUBjh27nt1J1YiGrz1NJjjXs1EKuBtDQMAvbnCj4 jJUh5GHxUPbrjxh7ZIO/bR59iO9EwbyYWD4Q5I2Lnk6VTMNXo5hbhZv1DU4byDvbc6IHhXf4cEJJ MOgXUvTroOMIFBZil4EucCkNv79zATtdBrr4uzHw7ZUylLrgKxxy+2ZgygjEEg4lPYmcRbU579iA hVxkuccOAiG6F94Zg+3c7bMFAYEnVPJdQohimgbjNAcAND/GPvkeQVZvu3VewBIaHrbcFGysQBLC SQ= X-UI-Out-Filterresults: notjunk:1;V03:K0:pWLrppZ+S/M=:Rs5jcdMwNpuVkdWmXT0GYo Fu5v+p/dGFVlkmLlV3XKhqjlmtWa3y+MHwy2Tf+eTK7Una10u8/i9qouOo1y4n5EK1xUge9cz SWIzwxnmGzdgNXdZgX4mmqOK7oQ1uJMpxxQID8D/lcfz1+4zAMWsbszsaXX60jcQO35D16+Hb LvMbBFbSM/swR3iPH+HhabQeDr0GS1JCKsRhx4RN43oQwqZDcL52bGsdJ/kFGbQ86iSOWAhZs cWBA55jb7+2XBbnFVAt3qrV+lzLcPcWVq7kcm+jxqs8bwxwI2JBNk5bscfeVcz9YB4guY4mb8 qdTO+YGjWm0Fke3sR3waCvjOFIFfwe5hm9aWhtJGVhcYZt3yKxcuqroHSnH98xESMH6nKRtpN o8eEF4pGYWPFBldqoYSgkfqWgLq9de2/GvSkmcXVTJyeN66JQVj3lxQ1frwdhPyXsGcMnx8Oq Sm00M5N9utPnj8jgggWeAZYnX3qwOQ3/77DVjuRbeiTg/8yW0eL/Pkwnmhd1brdUV/FOGXoOC Zoy9/C2uRXyAPNRUxIW/B3nbVL2JjT7d37ie7MCeM22YlqyqtPvCuDRCmuax30oerUnHjnEN+ GZUVZkHgdSqbI= Received-SPF: pass client-ip=212.227.17.21; envelope-from=dimech@gmx.com; helo=mout.gmx.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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:127883 Archived-At: I have the following three defun "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 "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 (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))) ))) (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)) (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)) > 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 re= place > 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 >