all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* tex-mode.el
@ 2005-02-26 15:10 Eli Zaretskii
  2005-02-26 15:16 ` tex-mode.el Luc Teirlinck
  2005-02-27 13:43 ` tex-mode.el Richard Stallman
  0 siblings, 2 replies; 37+ messages in thread
From: Eli Zaretskii @ 2005-02-26 15:10 UTC (permalink / raw)


When tex-mode.el from current CVS is compiled, it produces the
following warning:

  In tex-mode:
  tex-mode.el:818:8:Warning: function `tex-mode' defined multiple times in this
      file

Is this okay?

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2005-02-26 15:10 tex-mode.el Eli Zaretskii
@ 2005-02-26 15:16 ` Luc Teirlinck
  2005-02-27 13:43 ` tex-mode.el Richard Stallman
  1 sibling, 0 replies; 37+ messages in thread
From: Luc Teirlinck @ 2005-02-26 15:16 UTC (permalink / raw)
  Cc: emacs-devel

Eli Zaretskii wrote:

   When tex-mode.el from current CVS is compiled, it produces the
   following warning:

     In tex-mode:
     tex-mode.el:818:8:Warning: function `tex-mode' defined multiple times in this
	 file

   Is this okay?

There is the following comment:

(define-derived-mode tex-mode text-mode "generic-TeX"
  (tex-common-initialization))
;; We now move the function and define it again.  This gives a warning
;; in the byte-compiler :-( but it's difficult to avoid because
;; `define-derived-mode' will necessarily define the function once
;; and we need to define it a second time for `autoload' to get the
;; proper docstring.
(defalias 'tex-mode-internal (symbol-function 'tex-mode))
;;;###autoload
(defun tex-mode ()

Sincerely,

Luc.

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2005-02-26 15:10 tex-mode.el Eli Zaretskii
  2005-02-26 15:16 ` tex-mode.el Luc Teirlinck
@ 2005-02-27 13:43 ` Richard Stallman
  1 sibling, 0 replies; 37+ messages in thread
From: Richard Stallman @ 2005-02-27 13:43 UTC (permalink / raw)
  Cc: emacs-devel

    When tex-mode.el from current CVS is compiled, it produces the
    following warning:

      In tex-mode:
      tex-mode.el:818:8:Warning: function `tex-mode' defined multiple times in this
	  file

    Is this okay?

It is expected.  I find this somewhat ugly but I don't know
a good way to solve the problem.

^ permalink raw reply	[flat|nested] 37+ messages in thread

* tex-mode.el
@ 2010-09-20 14:18 Sean Sieger
  2010-09-20 15:27 ` tex-mode.el Stefan Monnier
  0 siblings, 1 reply; 37+ messages in thread
From: Sean Sieger @ 2010-09-20 14:18 UTC (permalink / raw)
  To: emacs-devel

I can't get this library to recompile:

In toplevel form:

textmodes/tex-mode.el:641:1:Warning: `"\\\\verb\\**\\([^a-z@*]\\)"' is a
    malformed function
textmodes/tex-mode.el:641:1:Warning: `"\\\\\\(?:end\\|begin\\) *\\({[^
{}]*}\\)"' is a malformed function
textmodes/tex-mode.el:654:12:Error: Symbol's function definition is
void: tex-fo nt-lock-verb




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2010-09-20 14:18 tex-mode.el Sean Sieger
@ 2010-09-20 15:27 ` Stefan Monnier
  2010-09-20 15:48   ` tex-mode.el Sean Sieger
  0 siblings, 1 reply; 37+ messages in thread
From: Stefan Monnier @ 2010-09-20 15:27 UTC (permalink / raw)
  To: Sean Sieger; +Cc: emacs-devel

> I can't get this library to recompile:
> In toplevel form:

> textmodes/tex-mode.el:641:1:Warning: `"\\\\verb\\**\\([^a-z@*]\\)"' is a
>     malformed function
> textmodes/tex-mode.el:641:1:Warning: `"\\\\\\(?:end\\|begin\\) *\\({[^
> {}]*}\\)"' is a malformed function
> textmodes/tex-mode.el:654:12:Error: Symbol's function definition is
> void: tex-fo nt-lock-verb

Have you tried "make bootstrap"?


        Stefan



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2010-09-20 15:27 ` tex-mode.el Stefan Monnier
@ 2010-09-20 15:48   ` Sean Sieger
  0 siblings, 0 replies; 37+ messages in thread
From: Sean Sieger @ 2010-09-20 15:48 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

> Have you tried "make bootstrap"?

Thank you, it looks like it just wrote it; and
thank you for the reminder.



^ permalink raw reply	[flat|nested] 37+ messages in thread

* tex-mode.el
@ 2021-02-09 17:13 Christopher Dimech
  2021-02-09 17:22 ` tex-mode.el Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 37+ messages in thread
From: Christopher Dimech @ 2021-02-09 17:13 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel, I would be grateful if you could help with "tex-mode.el".

Regards
Christopher



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2021-02-09 17:13 tex-mode.el Christopher Dimech
@ 2021-02-09 17:22 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-02-09 17:45   ` tex-mode.el Christopher Dimech
  0 siblings, 1 reply; 37+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-02-09 17:22 UTC (permalink / raw)
  To: help-gnu-emacs

Christopher Dimech wrote:

> Emanuel, I would be grateful if you could help with
> "tex-mode.el".

Sure, if I can.

What do you want it to do?

And how far have you come?

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2021-02-09 17:22 ` tex-mode.el Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-02-09 17:45   ` Christopher Dimech
  2021-02-09 18:15     ` tex-mode.el Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 37+ messages in thread
From: Christopher Dimech @ 2021-02-09 17:45 UTC (permalink / raw)
  To: moasenwood; +Cc: help-gnu-emacs

Have been trying to disable the "suscript" option after it is
enabled (suscript places superscript and subscript at a higher
and lower height, see "tex-font-lock-suscript").

Did start with using (setq tex-fontify-script nil)
However, the suscript functionality remained unchanged.

Then tried calling "tex-font-lock-unfontify-region".

I nedd some function to disable because right now my only
option in to disable plain-tex-mode.

I also did play with re-setting "font-lock-defaults".

(setq font-lock-defaults
   '(font-lock-unfontify-region-function . tex-font-lock-unfontify-region))



> Sent: Wednesday, February 10, 2021 at 5:22 AM
> 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: tex-mode.el
>
> Christopher Dimech wrote:
>
> > Emanuel, I would be grateful if you could help with
> > "tex-mode.el".
>
> Sure, if I can.
>
> What do you want it to do?
>
> And how far have you come?
>
> --
> underground experts united
> http://user.it.uu.se/~embe8573
> https://dataswamp.org/~incal
>
>
>



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2021-02-09 17:45   ` tex-mode.el Christopher Dimech
@ 2021-02-09 18:15     ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-02-09 18:26       ` tex-mode.el Christopher Dimech
  0 siblings, 1 reply; 37+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-02-09 18:15 UTC (permalink / raw)
  To: help-gnu-emacs

Christopher Dimech wrote:

> Have been trying to disable the "suscript" option

OK, one step at a time, what option is that, exactly?

And what does it do that you don't want?

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2021-02-09 18:15     ` tex-mode.el Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-02-09 18:26       ` Christopher Dimech
  2021-02-09 18:37         ` tex-mode.el Emanuel Berg via Users list for the GNU Emacs text editor
  2021-02-09 20:13         ` tex-mode.el tomas
  0 siblings, 2 replies; 37+ messages in thread
From: Christopher Dimech @ 2021-02-09 18:26 UTC (permalink / raw)
  To: moasenwood; +Cc: help-gnu-emacs




> Sent: Wednesday, February 10, 2021 at 6:15 AM
> 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: tex-mode.el
>
> Christopher Dimech wrote:
>
> > Have been trying to disable the "suscript" option
>
> OK, one step at a time, what option is that, exactly?
>
> And what does it do that you don't want?

tex-font-lock-match-suscript matches superscripts (matching part following ^)
and subscripts (matching part following _).  An example is "\alpha^i" and
"\beta_j".

Then "tex-font-lock-suscript" elevates the letter "i" and lowers the letter
"j".

I want to have a function that displays the text normally, without having
to change the major mode.

> --
> underground experts united
> http://user.it.uu.se/~embe8573
> https://dataswamp.org/~incal
>
>
>



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2021-02-09 18:26       ` tex-mode.el Christopher Dimech
@ 2021-02-09 18:37         ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-02-09 18:52           ` tex-mode.el Christopher Dimech
  2021-02-09 20:13         ` tex-mode.el tomas
  1 sibling, 1 reply; 37+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-02-09 18:37 UTC (permalink / raw)
  To: help-gnu-emacs

Christopher Dimech wrote:

> tex-font-lock-match-suscript matches superscripts (matching
> part following ^) and subscripts (matching part following
> _). An example is "\alpha^i" and "\beta_j".

OK, one step at a time, As you see from the source, that
function doesn't do anything if you set `tex-fontify-script'
to nil.

  (setq tex-fontify-script nil)

Now what happens?

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2021-02-09 18:37         ` tex-mode.el Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-02-09 18:52           ` Christopher Dimech
  2021-02-09 19:05             ` tex-mode.el Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 37+ messages in thread
From: Christopher Dimech @ 2021-02-09 18:52 UTC (permalink / raw)
  To: moasenwood; +Cc: help-gnu-emacs


> Sent: Wednesday, February 10, 2021 at 6:37 AM
> 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: tex-mode.el
>
> Christopher Dimech wrote:
>
> > tex-font-lock-match-suscript matches superscripts (matching
> > part following ^) and subscripts (matching part following
> > _). An example is "\alpha^i" and "\beta_j".
>
> OK, one step at a time, As you see from the source, that
> function doesn't do anything if you set `tex-fontify-script'
> to nil.
>
>   (setq tex-fontify-script nil)
>
> Now what happens?

It does nothing but stops matching superscript and subscript.
And I am not sure "tex-font-lock-unfontify-region" does anything
either.

> --
> underground experts united
> http://user.it.uu.se/~embe8573
> https://dataswamp.org/~incal
>
>
>



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2021-02-09 18:52           ` tex-mode.el Christopher Dimech
@ 2021-02-09 19:05             ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-02-09 19:39               ` tex-mode.el Christopher Dimech
                                 ` (2 more replies)
  0 siblings, 3 replies; 37+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-02-09 19:05 UTC (permalink / raw)
  To: help-gnu-emacs

Christopher Dimech wrote:

> It does nothing but stops matching superscript
> and subscript.

Isn't that what you want? No match, no font lock?

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2021-02-09 19:05             ` tex-mode.el Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-02-09 19:39               ` Christopher Dimech
  2021-02-09 19:45               ` tex-mode.el Christopher Dimech
  2021-02-10 20:43               ` tex-mode.el Christopher Dimech
  2 siblings, 0 replies; 37+ messages in thread
From: Christopher Dimech @ 2021-02-09 19:39 UTC (permalink / raw)
  To: moasenwood; +Cc: help-gnu-emacs

> Sent: Wednesday, February 10, 2021 at 7:05 AM
> 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: tex-mode.el
>
> Christopher Dimech wrote:
>
> > It does nothing but stops matching superscript
> > and subscript.
>
> Isn't that what you want? No match, no font lock?

I would like to revert the whole buffer to what it was before,
as normal text, without the elevation and lowering of expressions.


> --
> underground experts united
> http://user.it.uu.se/~embe8573
> https://dataswamp.org/~incal
>
>
>



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2021-02-09 19:05             ` tex-mode.el Emanuel Berg via Users list for the GNU Emacs text editor
  2021-02-09 19:39               ` tex-mode.el Christopher Dimech
@ 2021-02-09 19:45               ` Christopher Dimech
  2021-02-10 20:43               ` tex-mode.el Christopher Dimech
  2 siblings, 0 replies; 37+ messages in thread
From: Christopher Dimech @ 2021-02-09 19:45 UTC (permalink / raw)
  To: moasenwood; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 749 bytes --]

I have actually made a minor mode that does only the suscript part.
In addition it does some basic prettifying with just two commands
\alpha and \beta.   Also made a function to cycle the options.

Would you have time to look at it?  I attach the file and a test.

> Sent: Wednesday, February 10, 2021 at 7:05 AM
> 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: tex-mode.el
>
> Christopher Dimech wrote:
>
> > It does nothing but stops matching superscript
> > and subscript.
>
> Isn't that what you want? No match, no font lock?
>
> --
> underground experts united
> http://user.it.uu.se/~embe8573
> https://dataswamp.org/~incal
>
>
>

[-- Attachment #2: crucible-mode.el --]
[-- Type: text/plain, Size: 18182 bytes --]

;;; crucible-mode.el --- Typeface for texmath -*- lexical-binding:t -*-

;; Copyright (C) 2021  Free Software Foundation

;; Author: Christopher Dimech <email@here.com>
;; URL: https://website-here
;; Version: 0.1.0
;; Package-Requires: ((emacs "27.1"))

;; This file is part of Behistun, a Gnu Behistun.

;; Behistun is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; Behintun is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the Gnu Affero General Public
;; License along with Behistun.  If not, see
;; <http://www.gnu.org/licenses/>.

;;; -------------------------------------------------------------------
;;; Commentary:

;; * Setting texmath keywords using rx
;;   rx uses regular expressions that are easier to read.
;;
;; * Byte Compilation
;;
;;   The Byte Compiler translates functions written in Lisp into
;;   byte-code, a special representation that makes functions execute
;;   faster.  The byte compiler also returns very useful messages.
;;
;;   To byte-compile a file named crucible-mode.el, launch Emacs and
;;   enter the following command.
;;
;;     M-x byte-compile-file Ret crucible-mode.el

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; (require 'rx) ; Is this needed

(eval-when-compile
  (setq byte-compile-function-environment
	(delq (assq 'crucible-mode byte-compile-function-environment)
	      byte-compile-function-environment)))

;; ---------------------------------------------------------------------
(defgroup crucible ()
  "Groups tools for assisting with superior & inferior typeface."
  :prefix "crucible-"
  :group 'crucible)

;; ---------------------------------------------------------------------
(defgroup mtksy-kwd ()
  "Groups tools for typesetting mathematical symbols."
  :prefix "crucible-mtksy"
  :group 'crucible)

;; ---------------------------------------------------------------------
(defvar crucible-mode-hook nil
  "Hook called when Crucible Mode is enabled.")

;; ---------------------------------------------------------------------
;;;###autoload
(define-minor-mode crucible-mode
  "Minor mode for assisting with superior & inferior typeface."
  :init-value nil
  :global nil
  :lighter " Crucible"
  (run-hooks 'crucible-mode-hook))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(multic "
* Colour tex keywords")
;;         _                _                  _
;;  __ ___| |___ _  _ _ _  | |____ __ ___ _ __| |
;; / _/ _ \ / _ \ || | '_| | / /\ V  V / '_/ _` |
;; \__\___/_\___/\_,_|_|   |_\_\ \_/\_/|_| \__,_|

;; ---------------------------------------------------------------------
(defface colour-tex-cruc
  '( (default :inherit bold)
     ( ((class color) (min-colors 88) (background light))
       :foreground "#FF0000" )
     ( ((class color) (min-colors 88) (background dark))
       :foreground "#FF0000" )
     (t :inherit font-lock-builtin-face) )
  "Typeface for tex keywords.")

;; -------------------------------------------------------------------------
(defconst tex-keywords-cruc
  `(
    ;; Greek.  Use (0 'colour-tex-cruc) to highlight the leading "\".
    (,(rx "\\" word-start (group (or "alpha" "beta" "chi" "delta"
          "Delta" "epsilon" "varepsilon" "eta" "gamma" "Gamma" "iota"
          "kappa" "lambda" "Lambda" "mu" "nu" "omega" "Omega" "phi"
          "varphi" "Phi" "pi" "varpi" "Pi" "psi" "Psi" "rho" "varrho"
          "sigma" "varsigma" "Sigma" "tau" "theta" "vartheta" "Theta"
          "upsilon" "Upsilon" "xi" "Xi" "zeta")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Mathematical symbols
    (,(rx "\\" word-start (group (or "infty" "Re" "Im" "angle"
          "triangle" "backslash" "vert" "Vert" "emptyset" "bot" "top"
          "exists" "forall" "hbar" "ell" "aleph" "imath" "jmath"
          "nabla" "neg" "lnot" "prime" "partial" "surd" "wp" "flat"
          "sharp" "natural" "clubsuit" "diamondsuit" "heartsuit"
          "spadesuit")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Binary operations
    (,(rx "\\" word-start (group (or "vee" "wedge" "amalg" "cap" "cup"
          "uplus" "sqcap" "sqcup" "dagger" "ddaccer" "land" "lor"
          "cdot" "diamond" "bullet" "circ" "bigcirc" "odot" "ominus"
          "oplus" "oslash" "otimes" "pm" "mp" "triangleleft"
          "triangleright" "bigtriangledown" "bigtriangleup" "ast"
          "star" "times" "div" "setminus" "wr")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Mathematical relations
    (,(rx "\\" word-start (group (or "asymp" "cong" "dashv" "vdash"
          "perp" "mid" "parallel" "doteq" "equiv" "ge" "geq" "le"
          "leq" "gg" "ll" "models" "ne" "neq" "notin" "in" "ni" "owns"
          "prec" "preceq" "succ" "succeq" "bowtie" "propto" "approx"
          "sim" "simeq" "frown" "smile" "subset" "subseteq" "supset"
          "supseteq" "sqsubseteq" "sqsupseteq" "cos" "sin" "tan" "cot"
          "csc" "sec" "arccos" "arcsin" "arctan" "cosh" "coth" "sinh"
          "tanh" "det" "dim" "exp" "ln" "log" "lg" "arg" "deg" "gcd"
          "hom" "ker" "inf" "sup" "lim" "liminf" "limsup" "max" "min"
          "Pr")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Delimeters
    (,(rx "\\" word-start (group (or "lbrace" "rbrace" "lbrack"
          "rbrack " "langle" "rangle" "lceil" "rceil" "lfloor"
          "rfloor")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Arrows
    (,(rx "\\" word-start (group (or "leftarrow" "gets" "Leftarrow"
          "rightarrow " "to" "Rightarrow" "leftrightarrow"
          "Leftrightarrow" "longleftarrow" "Longleftarrow"
          "longrightarrow" "Longrightarrow" "longleftrightarrow"
          "Longleftrightarrow" "iff" "hookleftarrow" "hookrightarrow"
          "leftharpoondown" "rightharpoondown" "leftharpoonup"
          "rightharpoonup" "rightleftharpoons" "mapsto" "longmapsto"
          "downarrow" "Downarrow" "uparrow" "Uparrow" "updownarrow"
          "Updownarrow" "nearrow" "searrow" "nwarrow" "swarrow"))
          word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Large mathematical operations
    (,(rx "\\" word-start (group (or "bigcap" "bigcup" "bigodot"
          "bigoplus" "bigotimes" "bigsqcup" "biguplus" "bigvee"
          "bigwedge" "coprod" "smallint" "int" "oint" "prod" "sum"
          "limits" "nolimits" "displaylimits")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Fractions and stacking
    (,(rx "\\" word-start (group (or "over" "atop" "above" "choose"
          "brace" "cases" "underbrace" "overbrace" "underline"
          "overline" "overleftarrow" "overrightarrow" "buildrel"
          "ldots" "cdots" "vdots" "ddots" "lgroup" "rgroup" "left"
          "right" "delimiter" "delimiterfactor" "delimitershortfall"
          "matrix" "pmatrix" "bordermatrix" "sqrt" "root" "of"))
          word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Punctuation and style
    (,(rx "\\" word-start (group (or "cdotp" "ldotp" "colon" "sb" "sp"
          "textstyle" "scriptstyle" "scriptscriptstyle"
          "displaystyle")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Mathematical accents
    (,(rx "\\" word-start (group (or "acute" "b" "bar" "breve" "check"
          "ddot" "dot" "grave" "hat" "widehat" "tilde" "widetilde"
          "vec")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Mathematical class
    (,(rx "\\" word-start (group (or "mathord" "mathop" "mathbin"
          "mathrel " "mathopen" "mathclose" "mathpunct")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Equations and multiline display
    (,(rx "\\" word-start (group (or "eqno" "leqno" "displaylines"
          "eqalign " "eqalignno" "leqalignno")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Big sizes.  Using concat rather than rx.
    (,(concat "\\\\\\<\\(big\\|bigl\\|bigm\\|bigr\\|Big\\|Bigl\\|"
              "Bigm\\|Bigr\\|bigg\\|biggl\\|biggm\\|biggr\\|"
              "Bigg\\|Biggl\\|Biggm\\|Biggr\\|downbracefill\\|"
              "upbracefill\\|arrowvert\\|Arrowvert\\|lmoustache\\|"
              "rmoustache\\|bracevert\\)\\>")
     (1 'colour-tex-cruc)) )
  "Fontification for letters and symbols.")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; * Positioning of superscripts and subscripts
;;               _       __
;;  ____  _ _ __(_)_ _  / _|  _ __  ___ ____ _
;; (_-< || | '_ \ | ' \|  _| | '_ \/ _ (_-< ' \
;; /__/\_,_| .__/_|_||_|_|   | .__/\___/__/_||_|
;;         |_|               |_|

;; ---------------------------------------------------------------------
(defcustom supinf-fontify-signal t
  "Enables typeface for tex commands."
  :type 'boolean
  :group 'supinf)

(put 'supinf-fontify-signal 'safe-local-variable 'booleanp)

;; ---------------------------------------------------------------------
(defcustom crucible-supinf-vshift '(0.18 -0.18)
  "Sets vertical shift for superior and inferior glyphs.
The first number is negative, whilst the second is positive.
Shift is measured relative to the text font size."
  :group 'supinf
  :type '(list (float :tag "superior-vshift")
               (float :tag "inferior-vshift")) )

;; ---------------------------------------------------------------------
(defcustom crucible-height-ratio 0.8
  "Sets relative supinf height ratio with the preceding text.
For nested expressions, the setting is applied repeatedly,
subject to the limit set by `crucible-height-minimum'."
  :type 'float
  :group 'supinf)

;; ---------------------------------------------------------------------
(defcustom crucible-height-minimum 0.8
  "Sets the minimum glyph height.
For integer values, the height is in units of 1/10 point.
Relative height is used for floating point values."
  :type '(choice (integer :tag "Font height in 1/10 point units")
		 (float   :tag "Fraction of font height"))
  :group 'supinf)

;; ---------------------------------------------------------------------
(defun crucible-supinf-match (limit)
  "Match superior and inferior glyph patterns up to LIMIT."
  (when (and supinf-fontify-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 crucible-supinf-height (height)
  "Return integer HEIGHT of superior and inferior glyph.
Height is an integer that is 1/10 of point size.  Not smaller than the
value set by `crucible-height-minimum'."
  (ceiling
     (max
        (if (integerp crucible-height-minimum)
	    crucible-height-minimum
	  (condition-case nil ; For bootstrapping.
	      (* crucible-height-minimum
		 (face-attribute 'default :height))
	    (error 0)))
	(* height crucible-height-ratio))))  ; assumes height is integer.

;; ---------------------------------------------------------------------
(defface supr-tfc-cruc
  '((t :height crucible-supinf-height))
  "Typography for superior glyphs."
  :group 'supinf)

;; ---------------------------------------------------------------------
(defface infr-tfc-cruc
  '((t :height crucible-supinf-height))
  "Typography for inferior glyphs."
  :group 'supinf)

;; ---------------------------------------------------------------------
(defun supinf-typeface-cruc (pos)
  "Fontify text at POS."
  (unless (or (memq (get-text-property pos 'face)
		    '(font-lock-constant-face
		      font-lock-builtin-face
		      font-lock-comment-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-cruc
	       display (raise ,(car crucible-supinf-vshift)))
      `(face infr-tfc-cruc
	     display (raise ,(cadr crucible-supinf-vshift))) )))

;; ---------------------------------------------------------------------
(defconst supinf-font-lock-cruc
  (append
      nil
      '( (crucible-supinf-match
	  (1 (supinf-typeface-cruc (match-beginning 0)) append))) )
  "Experimental expressions to highlight in TeX modes.")

;; ---------------------------------------------------------------------
(defun supinf-disable-cruc (beg end)
  "Set typeface for text between BEG and END."
  (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)) crucible-supinf-vshift)
	       (null (cddr prop)))
	  (put-text-property beg next 'display nil))
      (setq beg next))))

;; ---------------------------------------------------------------------
;;(defun tex-typeface-crucible ()
;;  "Font-lock setup for mathematical symbols."
;;  (font-lock-flush (point-min) (point-max))
;;  (if crucible-supinf-enable
;;      (progn
;;        (font-lock-add-keywords nil tex-keywords-cruc t)
;;        (font-lock-add-keywords nil supinf-font-lock-cruc t))
;;    (font-lock-remove-keywords nil tex-keywords-cruc)
;;    (supinf-disable-cruc (point-min) (point-max)))
;;  (font-lock-flush (point-min) (point-max)))

;;(defun supinf-typeface-crucible ()
;;  "Font-lock setup for mathematical symbols."
;;  (font-lock-flush (point-min) (point-max))
;;
;;  (if crucible-mode
;;      (font-lock-add-keywords nil tex-keywords-cruc t)
;;    (font-lock-remove-keywords nil tex-keywords-cruc))
;;
;;  (if crucible-supinf-enable
;;      (font-lock-add-keywords nil supinf-font-lock-cruc t)
;;  (supinf-disable-cruc (point-min) (point-max)))
;;
;;  (font-lock-flush (point-min) (point-max)))

(defun supinf-enable ()
  "Enable the supinf typeface"
  (font-lock-flush (point-min) (point-max))
  (font-lock-add-keywords nil supinf-font-lock-cruc t)
  (font-lock-flush (point-min) (point-max)) )

(defun supinf-disable ()
  "Disable the supinf typeface"
  (font-lock-flush (point-min) (point-max))
  (setq font-lock-defaults
	'(font-lock-unfontify-region-function . supinf-disable-cruc))
  ;;(supinf-disable-cruc (point-min) (point-max))
  (font-lock-flush (point-min) (point-max)) )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; * Displays texmath glyphs for the corresponding tex commands.
;;             _   _           _           _
;;  _ __  __ _| |_| |_    __ _| |_  _ _ __| |_  ___
;; | '  \/ _` |  _| ' \  / _` | | || | '_ \ ' \(_-<
;; |_|_|_\__,_|\__|_||_| \__, |_|\_, | .__/_||_/__/
;;                       |___/   |__/|_|

;;(require 'prog-mode)

(defun texglyph-predicate (start end _match)
  "Prettifies mathematical expressions written in tex syntax.
Matches start with a backslash and end with a word constituent
[a-zA-Z0-9].  Uses the prettify functionality provided by
prog-mode."
(not (or (memq (char-before start) '(?\\))
	 (memq (char-syntax (or (char-after end) ?\s)) '(?w))
	 (nth 8 (syntax-ppss)))))

;; ---------------------------------------------------------------------
(defun texglyph-typeface-crucible ()
  (push '("\\alpha" . ?α) prettify-symbols-alist)
  (push '("\\beta" . ?β) prettify-symbols-alist)
  (setq prettify-symbols-compose-predicate 'texglyph-predicate))

;; ---------------------------------------------------------------------
(defun texglyph-enable ()
  "Enables typeface for tex glyphs."
  (texglyph-typeface-crucible)
  (prettify-symbols-mode))

;; ---------------------------------------------------------------------
(defvar-local texglyph-state-cruc nil)

(defun texglyph-cycle-crucible ()
  "Breaks lines when they get beyond fill-column."
   (interactive)

   (pcase texglyph-state-cruc
     ;; ----------------------------------------------
     (1 (setq supinf-fontify-signal t)
	(supinf-enable)
        (message "Supinf Enabled")
        (setq-local texglyph-state-cruc (1+ texglyph-state-cruc)))
     ;; ----------------------------------------------
     (2 (texglyph-enable)
        (message "Supinf and Glyphs Enabled")
        (setq-local texglyph-state-cruc (1+ texglyph-state-cruc)))
     ;; ----------------------------------------------
     (_ (setq supinf-fontify-signal nil)
	;;(supinf-disable)
	(prettify-symbols-mode 0)
	(message "Supinf and Glyphs Disabled")
        (setq-local texglyph-state-cruc 1)) ))

;; -----------------------------------------------------------------------
(defun texglyph-enableo ()
  "Enables a typeface for displaying tex commands."
  (texglyph-cycle-crucible))

;; -----------------------------------------------------------------------
(defun crucible-prettify-hook ()
  "defun-todo"
  (add-hook 'crucible-mode-hook #'supinf-typeface-crucible)
  (add-hook 'texinfo-mode-hook #'texglyph-typeface-crucible) )

(global-set-key (kbd "H-t") #'texglyph-cycle-crucible)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(texglyph-typeface-crucible)
;; (texglyph-crucible)
;; (crucible-prettify-hook)
(provide 'crucible-mode)

;;; crucible-mode.el ends here

;; crucible-mode             Highlight tex keywords with colour scheme
;; crucible-supinf-enable    Enable supinf positioning
;; crucible-texglyph-enable  Associate glyphs with tex keywords

[-- Attachment #3: crucible-test.texi --]
[-- Type: application/x-texinfo, Size: 1397 bytes --]

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2021-02-09 18:26       ` tex-mode.el Christopher Dimech
  2021-02-09 18:37         ` tex-mode.el Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-02-09 20:13         ` tomas
  2021-02-09 20:26           ` tex-mode.el Christopher Dimech
  1 sibling, 1 reply; 37+ messages in thread
From: tomas @ 2021-02-09 20:13 UTC (permalink / raw)
  To: Christopher Dimech; +Cc: help-gnu-emacs, moasenwood

[-- Attachment #1: Type: text/plain, Size: 2115 bytes --]

On Tue, Feb 09, 2021 at 07:26:14PM +0100, Christopher Dimech wrote:
> 
> 
> 
> > Sent: Wednesday, February 10, 2021 at 6:15 AM
> > 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: tex-mode.el
> >
> > Christopher Dimech wrote:
> >
> > > Have been trying to disable the "suscript" option
> >
> > OK, one step at a time, what option is that, exactly?
> >
> > And what does it do that you don't want?
> 
> tex-font-lock-match-suscript matches superscripts (matching part following ^)
> and subscripts (matching part following _).  An example is "\alpha^i" and
> "\beta_j".
> 
> Then "tex-font-lock-suscript" elevates the letter "i" and lowers the letter
> "j".
> 
> I want to have a function that displays the text normally, without having
> to change the major mode.

Perhaps you're better off by tweaking those variables:

    (defcustom tex-font-script-display '(-0.2 0.2)
      "How much to lower and raise subscript and superscript content.
    This is a list of two floats.  The first is negative and
    specifies how much subscript is lowered, the second is positive
    and specifies how much superscript is raised.  Heights are
    measured relative to that of the normal text."
      :group 'tex
      :type '(list (float :tag "Subscript")
                   (float :tag "Superscript"))
      :version "23.1")

(defined in tex-mode.el) -- try '(0.0 0.0) to lower/raise sub-/superscripts by
zero, and

    (defcustom tex-suscript-height-ratio 0.8
      "Ratio of subscript/superscript height to that of the preceding text.
    In nested subscript/superscript, this factor is applied repeatedly,
    subject to the limit set by `tex-suscript-height-minimum'."
      :type 'float
      :group 'tex
      :version "23.1")

(likewise) -- try 0.0 to keep the size equal to the main font. Something
like

  (setq tex-font-script-display '(0.0 0.0))
  (setq tex-suscript-height-ratio 1.0)

or its custom equivalent (maybe via the customize interface?)

Cheers
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2021-02-09 20:13         ` tex-mode.el tomas
@ 2021-02-09 20:26           ` Christopher Dimech
  2021-02-09 20:45             ` tex-mode.el tomas
  0 siblings, 1 reply; 37+ messages in thread
From: Christopher Dimech @ 2021-02-09 20:26 UTC (permalink / raw)
  To: tomas; +Cc: help-gnu-emacs, moasenwood


> Sent: Wednesday, February 10, 2021 at 8:13 AM
> From: tomas@tuxteam.de
> To: "Christopher Dimech" <dimech@gmx.com>
> Cc: moasenwood@zoho.eu, help-gnu-emacs@gnu.org
> Subject: Re: tex-mode.el
>
> On Tue, Feb 09, 2021 at 07:26:14PM +0100, Christopher Dimech wrote:
> >
> >
> >
> > > Sent: Wednesday, February 10, 2021 at 6:15 AM
> > > 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: tex-mode.el
> > >
> > > Christopher Dimech wrote:
> > >
> > > > Have been trying to disable the "suscript" option
> > >
> > > OK, one step at a time, what option is that, exactly?
> > >
> > > And what does it do that you don't want?
> >
> > tex-font-lock-match-suscript matches superscripts (matching part following ^)
> > and subscripts (matching part following _).  An example is "\alpha^i" and
> > "\beta_j".
> >
> > Then "tex-font-lock-suscript" elevates the letter "i" and lowers the letter
> > "j".
> >
> > I want to have a function that displays the text normally, without having
> > to change the major mode.
>
> Perhaps you're better off by tweaking those variables:
>
>     (defcustom tex-font-script-display '(-0.2 0.2)
>       "How much to lower and raise subscript and superscript content.
>     This is a list of two floats.  The first is negative and
>     specifies how much subscript is lowered, the second is positive
>     and specifies how much superscript is raised.  Heights are
>     measured relative to that of the normal text."
>       :group 'tex
>       :type '(list (float :tag "Subscript")
>                    (float :tag "Superscript"))
>       :version "23.1")
>
> (defined in tex-mode.el) -- try '(0.0 0.0) to lower/raise sub-/superscripts by
> zero, and
>
>     (defcustom tex-suscript-height-ratio 0.8
>       "Ratio of subscript/superscript height to that of the preceding text.
>     In nested subscript/superscript, this factor is applied repeatedly,
>     subject to the limit set by `tex-suscript-height-minimum'."
>       :type 'float
>       :group 'tex
>       :version "23.1")
>
> (likewise) -- try 0.0 to keep the size equal to the main font. Something
> like
>
>   (setq tex-font-script-display '(0.0 0.0))
>   (setq tex-suscript-height-ratio 1.0)
>
> or its custom equivalent (maybe via the customize interface?)

Have tried your suggestion, but once the typeface is activated,
re-setting tex-font-script-display and tex-suscript-height-ratio
does not revert to the original (i.e. equivalent to disabling the
tex major made).


> Cheers
>  - t
>



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2021-02-09 20:26           ` tex-mode.el Christopher Dimech
@ 2021-02-09 20:45             ` tomas
  2021-02-10  3:53               ` tex-mode.el Michael Heerdegen
  0 siblings, 1 reply; 37+ messages in thread
From: tomas @ 2021-02-09 20:45 UTC (permalink / raw)
  To: Christopher Dimech; +Cc: help-gnu-emacs, moasenwood

[-- Attachment #1: Type: text/plain, Size: 610 bytes --]

On Tue, Feb 09, 2021 at 09:26:41PM +0100, Christopher Dimech wrote:

[...]

> > Perhaps you're better off by tweaking those variables:
> >
> >     (defcustom tex-font-script-display '(-0.2 0.2)
[...]
> >     (defcustom tex-suscript-height-ratio 0.8

> Have tried your suggestion, but once the typeface is activated,
> re-setting tex-font-script-display and tex-suscript-height-ratio
> does not revert to the original (i.e. equivalent to disabling the
> tex major made).

You want to change display back-and-forth? Have you tried invoking
(font-lock-refresh-defaults) after changing the variables?

Cheers
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2021-02-09 20:45             ` tex-mode.el tomas
@ 2021-02-10  3:53               ` Michael Heerdegen
  2021-02-10  4:01                 ` tex-mode.el Christopher Dimech
  0 siblings, 1 reply; 37+ messages in thread
From: Michael Heerdegen @ 2021-02-10  3:53 UTC (permalink / raw)
  To: help-gnu-emacs

tomas@tuxteam.de writes:

> You want to change display back-and-forth? Have you tried invoking
> (font-lock-refresh-defaults) after changing the variables?

Even calling (font-lock-flush) should suffice, since
`tex-font-script-display's value is consulted on the fly.

Michael.




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2021-02-10  3:53               ` tex-mode.el Michael Heerdegen
@ 2021-02-10  4:01                 ` Christopher Dimech
  2021-02-11  3:42                   ` tex-mode.el Michael Heerdegen
  2021-02-11 21:11                   ` tex-mode.el Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 2 replies; 37+ messages in thread
From: Christopher Dimech @ 2021-02-10  4:01 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 688 bytes --]

I have made a minor mode for texinfo that does this, but the buffer
is not being returned to look as source code.  They still look that
they have a difference in height.

I attach the file with a test.


> Sent: Wednesday, February 10, 2021 at 3:53 PM
> From: "Michael Heerdegen" <michael_heerdegen@web.de>
> To: help-gnu-emacs@gnu.org
> Subject: Re: tex-mode.el
>
> tomas@tuxteam.de writes:
>
> > You want to change display back-and-forth? Have you tried invoking
> > (font-lock-refresh-defaults) after changing the variables?
>
> Even calling (font-lock-flush) should suffice, since
> `tex-font-script-display's value is consulted on the fly.
>
> Michael.
>
>
>

[-- Attachment #2: crucible-mode.el --]
[-- Type: text/plain, Size: 18360 bytes --]

;;; crucible-mode.el --- Typeface for texmath -*- lexical-binding:t -*-

;; Copyright (C) 2021  Free Software Foundation

;; Author: Christopher Dimech <email@here.com>
;; URL: https://website-here
;; Version: 0.1.0
;; Package-Requires: ((emacs "27.1"))

;; This file is part of Behistun, a Gnu Behistun.

;; Behistun is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; Behintun is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the Gnu Affero General Public
;; License along with Behistun.  If not, see
;; <http://www.gnu.org/licenses/>.

;;; -------------------------------------------------------------------
;;; Commentary:

;; * Setting texmath keywords using rx
;;   rx uses regular expressions that are easier to read.
;;
;; * Byte Compilation
;;
;;   The Byte Compiler translates functions written in Lisp into
;;   byte-code, a special representation that makes functions execute
;;   faster.  The byte compiler also returns very useful messages.
;;
;;   To byte-compile a file named crucible-mode.el, launch Emacs and
;;   enter the following command.
;;
;;     M-x byte-compile-file Ret crucible-mode.el

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; (require 'rx) ; Is this needed

(eval-when-compile
  (setq byte-compile-function-environment
	(delq (assq 'crucible-mode byte-compile-function-environment)
	      byte-compile-function-environment)))

;; ---------------------------------------------------------------------
(defgroup crucible ()
  "Groups tools for assisting with superior & inferior typeface."
  :prefix "crucible-"
  :group 'crucible)

;; ---------------------------------------------------------------------
(defgroup mtksy-kwd ()
  "Groups tools for typesetting mathematical symbols."
  :prefix "crucible-mtksy"
  :group 'crucible)

;; ---------------------------------------------------------------------
(defvar crucible-mode-hook nil
  "Hook called when Crucible Mode is enabled.")

;; ---------------------------------------------------------------------
;;;###autoload
(define-minor-mode crucible-mode
  "Minor mode for assisting with superior & inferior typeface."
  :init-value nil
  :global nil
  :lighter " Crucible"
  (run-hooks 'crucible-mode-hook))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(multic "
* Colour tex keywords")
;;         _                _                  _
;;  __ ___| |___ _  _ _ _  | |____ __ ___ _ __| |
;; / _/ _ \ / _ \ || | '_| | / /\ V  V / '_/ _` |
;; \__\___/_\___/\_,_|_|   |_\_\ \_/\_/|_| \__,_|

;; ---------------------------------------------------------------------
(defface colour-tex-cruc
  '( (default :inherit bold)
     ( ((class color) (min-colors 88) (background light))
       :foreground "#FF0000" )
     ( ((class color) (min-colors 88) (background dark))
       :foreground "#FF0000" )
     (t :inherit font-lock-builtin-face) )
  "Typeface for tex keywords.")

;; -------------------------------------------------------------------------
(defconst tex-keywords-cruc
  `(
    ;; Greek.  Use (0 'colour-tex-cruc) to highlight the leading "\".
    (,(rx "\\" word-start (group (or "alpha" "beta" "chi" "delta"
          "Delta" "epsilon" "varepsilon" "eta" "gamma" "Gamma" "iota"
          "kappa" "lambda" "Lambda" "mu" "nu" "omega" "Omega" "phi"
          "varphi" "Phi" "pi" "varpi" "Pi" "psi" "Psi" "rho" "varrho"
          "sigma" "varsigma" "Sigma" "tau" "theta" "vartheta" "Theta"
          "upsilon" "Upsilon" "xi" "Xi" "zeta")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Mathematical symbols
    (,(rx "\\" word-start (group (or "infty" "Re" "Im" "angle"
          "triangle" "backslash" "vert" "Vert" "emptyset" "bot" "top"
          "exists" "forall" "hbar" "ell" "aleph" "imath" "jmath"
          "nabla" "neg" "lnot" "prime" "partial" "surd" "wp" "flat"
          "sharp" "natural" "clubsuit" "diamondsuit" "heartsuit"
          "spadesuit")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Binary operations
    (,(rx "\\" word-start (group (or "vee" "wedge" "amalg" "cap" "cup"
          "uplus" "sqcap" "sqcup" "dagger" "ddaccer" "land" "lor"
          "cdot" "diamond" "bullet" "circ" "bigcirc" "odot" "ominus"
          "oplus" "oslash" "otimes" "pm" "mp" "triangleleft"
          "triangleright" "bigtriangledown" "bigtriangleup" "ast"
          "star" "times" "div" "setminus" "wr")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Mathematical relations
    (,(rx "\\" word-start (group (or "asymp" "cong" "dashv" "vdash"
          "perp" "mid" "parallel" "doteq" "equiv" "ge" "geq" "le"
          "leq" "gg" "ll" "models" "ne" "neq" "notin" "in" "ni" "owns"
          "prec" "preceq" "succ" "succeq" "bowtie" "propto" "approx"
          "sim" "simeq" "frown" "smile" "subset" "subseteq" "supset"
          "supseteq" "sqsubseteq" "sqsupseteq" "cos" "sin" "tan" "cot"
          "csc" "sec" "arccos" "arcsin" "arctan" "cosh" "coth" "sinh"
          "tanh" "det" "dim" "exp" "ln" "log" "lg" "arg" "deg" "gcd"
          "hom" "ker" "inf" "sup" "lim" "liminf" "limsup" "max" "min"
          "Pr")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Delimeters
    (,(rx "\\" word-start (group (or "lbrace" "rbrace" "lbrack"
          "rbrack " "langle" "rangle" "lceil" "rceil" "lfloor"
          "rfloor")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Arrows
    (,(rx "\\" word-start (group (or "leftarrow" "gets" "Leftarrow"
          "rightarrow " "to" "Rightarrow" "leftrightarrow"
          "Leftrightarrow" "longleftarrow" "Longleftarrow"
          "longrightarrow" "Longrightarrow" "longleftrightarrow"
          "Longleftrightarrow" "iff" "hookleftarrow" "hookrightarrow"
          "leftharpoondown" "rightharpoondown" "leftharpoonup"
          "rightharpoonup" "rightleftharpoons" "mapsto" "longmapsto"
          "downarrow" "Downarrow" "uparrow" "Uparrow" "updownarrow"
          "Updownarrow" "nearrow" "searrow" "nwarrow" "swarrow"))
          word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Large mathematical operations
    (,(rx "\\" word-start (group (or "bigcap" "bigcup" "bigodot"
          "bigoplus" "bigotimes" "bigsqcup" "biguplus" "bigvee"
          "bigwedge" "coprod" "smallint" "int" "oint" "prod" "sum"
          "limits" "nolimits" "displaylimits")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Fractions and stacking
    (,(rx "\\" word-start (group (or "over" "atop" "above" "choose"
          "brace" "cases" "underbrace" "overbrace" "underline"
          "overline" "overleftarrow" "overrightarrow" "buildrel"
          "ldots" "cdots" "vdots" "ddots" "lgroup" "rgroup" "left"
          "right" "delimiter" "delimiterfactor" "delimitershortfall"
          "matrix" "pmatrix" "bordermatrix" "sqrt" "root" "of"))
          word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Punctuation and style
    (,(rx "\\" word-start (group (or "cdotp" "ldotp" "colon" "sb" "sp"
          "textstyle" "scriptstyle" "scriptscriptstyle"
          "displaystyle")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Mathematical accents
    (,(rx "\\" word-start (group (or "acute" "b" "bar" "breve" "check"
          "ddot" "dot" "grave" "hat" "widehat" "tilde" "widetilde"
          "vec")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Mathematical class
    (,(rx "\\" word-start (group (or "mathord" "mathop" "mathbin"
          "mathrel " "mathopen" "mathclose" "mathpunct")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Equations and multiline display
    (,(rx "\\" word-start (group (or "eqno" "leqno" "displaylines"
          "eqalign " "eqalignno" "leqalignno")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Big sizes.  Using concat rather than rx.
    (,(concat "\\\\\\<\\(big\\|bigl\\|bigm\\|bigr\\|Big\\|Bigl\\|"
              "Bigm\\|Bigr\\|bigg\\|biggl\\|biggm\\|biggr\\|"
              "Bigg\\|Biggl\\|Biggm\\|Biggr\\|downbracefill\\|"
              "upbracefill\\|arrowvert\\|Arrowvert\\|lmoustache\\|"
              "rmoustache\\|bracevert\\)\\>")
     (1 'colour-tex-cruc)) )
  "Fontification for letters and symbols.")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; * Positioning of superscripts and subscripts
;;               _       __
;;  ____  _ _ __(_)_ _  / _|  _ __  ___ ____ _
;; (_-< || | '_ \ | ' \|  _| | '_ \/ _ (_-< ' \
;; /__/\_,_| .__/_|_||_|_|   | .__/\___/__/_||_|
;;         |_|               |_|

;; ---------------------------------------------------------------------
(defcustom supinf-fontify-signal t
  "Enables typeface for tex commands."
  :type 'boolean
  :group 'supinf)

(put 'supinf-fontify-signal 'safe-local-variable 'booleanp)

;; ---------------------------------------------------------------------
(defcustom crucible-supinf-vshift '(0.18 -0.18)
  "Sets vertical shift for superior and inferior glyphs.
The first number is negative, whilst the second is positive.
Shift is measured relative to the text font size."
  :group 'supinf
  :type '(list (float :tag "superior-vshift")
               (float :tag "inferior-vshift")) )

;; ---------------------------------------------------------------------
(defcustom crucible-height-ratio 0.8
  "Sets relative supinf height ratio with the preceding text.
For nested expressions, the setting is applied repeatedly,
subject to the limit set by `crucible-height-minimum'."
  :type 'float
  :group 'supinf)

;; ---------------------------------------------------------------------
(defcustom crucible-height-minimum 0.8
  "Sets the minimum glyph height.
For integer values, the height is in units of 1/10 point.
Relative height is used for floating point values."
  :type '(choice (integer :tag "Font height in 1/10 point units")
		 (float   :tag "Fraction of font height"))
  :group 'supinf)

;; ---------------------------------------------------------------------
(defun crucible-supinf-match (limit)
  "Match superior and inferior glyph patterns up to LIMIT."
  (when (and supinf-fontify-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 crucible-supinf-height (height)
  "Return integer HEIGHT of superior and inferior glyph.
Height is an integer that is 1/10 of point size.  Not smaller than the
value set by `crucible-height-minimum'."
  (ceiling
     (max
        (if (integerp crucible-height-minimum)
	    crucible-height-minimum
	  (condition-case nil ; For bootstrapping.
	      (* crucible-height-minimum
		 (face-attribute 'default :height))
	    (error 0)))
	(* height crucible-height-ratio))))  ; assumes height is integer.

;; ---------------------------------------------------------------------
(defface supr-tfc-cruc
  '((t :height crucible-supinf-height))
  "Typography for superior glyphs."
  :group 'supinf)

;; ---------------------------------------------------------------------
(defface infr-tfc-cruc
  '((t :height crucible-supinf-height))
  "Typography for inferior glyphs."
  :group 'supinf)

;; ---------------------------------------------------------------------
(defun supinf-typeface-cruc (pos)
  "Fontify text at POS."
  (unless (or (memq (get-text-property pos 'face)
		    '(font-lock-constant-face
		      font-lock-builtin-face
		      font-lock-comment-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-cruc
	       display (raise ,(car crucible-supinf-vshift)))
      `(face infr-tfc-cruc
	     display (raise ,(cadr crucible-supinf-vshift))) )))

;; ---------------------------------------------------------------------
(defconst supinf-font-lock-cruc
  (append
      nil
      '( (crucible-supinf-match
	  (1 (supinf-typeface-cruc (match-beginning 0)) append))) )
  "Experimental expressions to highlight in TeX modes.")

;; ---------------------------------------------------------------------
(defun supinf-disable-cruc (beg end)
  "Set typeface for text between BEG and END."
  (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)) crucible-supinf-vshift)
	       (null (cddr prop)))
	  (put-text-property beg next 'display nil))
      (setq beg next))))

;; ---------------------------------------------------------------------
;;(defun tex-typeface-crucible ()
;;  "Font-lock setup for mathematical symbols."
;;  (font-lock-flush (point-min) (point-max))
;;  (if crucible-supinf-enable
;;      (progn
;;        (font-lock-add-keywords nil tex-keywords-cruc t)
;;        (font-lock-add-keywords nil supinf-font-lock-cruc t))
;;    (font-lock-remove-keywords nil tex-keywords-cruc)
;;    (supinf-disable-cruc (point-min) (point-max)))
;;  (font-lock-flush (point-min) (point-max)))

;;(defun supinf-typeface-crucible ()
;;  "Font-lock setup for mathematical symbols."
;;  (font-lock-flush (point-min) (point-max))
;;
;;  (if crucible-mode
;;      (font-lock-add-keywords nil tex-keywords-cruc t)
;;    (font-lock-remove-keywords nil tex-keywords-cruc))
;;
;;  (if crucible-supinf-enable
;;      (font-lock-add-keywords nil supinf-font-lock-cruc t)
;;  (supinf-disable-cruc (point-min) (point-max)))
;;
;;  (font-lock-flush (point-min) (point-max)))

(defun supinf-enable ()
  "Enable the supinf typeface"
  (font-lock-flush (point-min) (point-max))
  (font-lock-add-keywords nil supinf-font-lock-cruc t)
  (font-lock-flush (point-min) (point-max)) )

(defun supinf-disable ()
  "Disable the supinf typeface"
  (font-lock-flush (point-min) (point-max))
  (setq font-lock-defaults
	'(font-lock-unfontify-region-function . supinf-disable-cruc))
  ;;(supinf-disable-cruc (point-min) (point-max))
  (font-lock-flush (point-min) (point-max)) )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; * Displays texmath glyphs for the corresponding tex commands.
;;             _   _           _           _
;;  _ __  __ _| |_| |_    __ _| |_  _ _ __| |_  ___
;; | '  \/ _` |  _| ' \  / _` | | || | '_ \ ' \(_-<
;; |_|_|_\__,_|\__|_||_| \__, |_|\_, | .__/_||_/__/
;;                       |___/   |__/|_|

;;(require 'prog-mode)

(defun texglyph-predicate (start end _match)
  "Prettifies mathematical expressions written in tex syntax.
Matches start with a backslash and end with a word constituent
[a-zA-Z0-9].  Uses the prettify functionality provided by
prog-mode."
(not (or (memq (char-before start) '(?\\))
	 (memq (char-syntax (or (char-after end) ?\s)) '(?w))
	 (nth 8 (syntax-ppss)))))

;; ---------------------------------------------------------------------
(defun texglyph-typeface-crucible ()
  (push '("\\alpha" . ?α) prettify-symbols-alist)
  (push '("\\beta" . ?β) prettify-symbols-alist)
  (setq prettify-symbols-compose-predicate 'texglyph-predicate))

;; ---------------------------------------------------------------------
(defun texglyph-enable ()
  "Enables typeface for tex glyphs."
  (texglyph-typeface-crucible)
  (prettify-symbols-mode))

;; ---------------------------------------------------------------------
(defvar-local texglyph-state-cruc nil)

(defun texglyph-cycle-crucible ()
  "Breaks lines when they get beyond fill-column."
   (interactive)

   (pcase texglyph-state-cruc
     ;; ----------------------------------------------
     (1 (setq supinf-fontify-signal t)
	(supinf-enable)
        (message "Supinf Enabled")
        (setq-local texglyph-state-cruc (1+ texglyph-state-cruc)))
     ;; ----------------------------------------------
     (2 (texglyph-enable)
        (message "Supinf and Glyphs Enabled")
        (setq-local texglyph-state-cruc (1+ texglyph-state-cruc)))
     ;; ----------------------------------------------
     (_ (setq supinf-fontify-signal nil)
	;;(supinf-disable)
	(setq-local supinf-fontify-signal nil)
	(setq tex-font-script-display '(-0.0 0.0))
	(setq tex-suscript-height-ratio 0.0)
	(font-lock-flush)
	(font-lock-refresh-defaults)
	;;(prettify-symbols-mode 0)
	(message "Supinf and Glyphs Disabled")
        (setq-local texglyph-state-cruc 1)) ))

;; -----------------------------------------------------------------------
(defun texglyph-enableo ()
  "Enables a typeface for displaying tex commands."
  (texglyph-cycle-crucible))

;; -----------------------------------------------------------------------
(defun crucible-prettify-hook ()
  "defun-todo"
  (add-hook 'crucible-mode-hook #'supinf-typeface-crucible)
  (add-hook 'texinfo-mode-hook #'texglyph-typeface-crucible) )

(global-set-key (kbd "H-t") #'texglyph-cycle-crucible)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(texglyph-typeface-crucible)
;; (texglyph-crucible)
;; (crucible-prettify-hook)
(provide 'crucible-mode)

;;; crucible-mode.el ends here

;; crucible-mode             Highlight tex keywords with colour scheme
;; crucible-supinf-enable    Enable supinf positioning
;; crucible-texglyph-enable  Associate glyphs with tex keywords

[-- Attachment #3: crucible-test.texi --]
[-- Type: application/x-texinfo, Size: 1397 bytes --]

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2021-02-09 19:05             ` tex-mode.el Emanuel Berg via Users list for the GNU Emacs text editor
  2021-02-09 19:39               ` tex-mode.el Christopher Dimech
  2021-02-09 19:45               ` tex-mode.el Christopher Dimech
@ 2021-02-10 20:43               ` Christopher Dimech
  2021-02-10 20:49                 ` tex-mode.el Emanuel Berg via Users list for the GNU Emacs text editor
  2 siblings, 1 reply; 37+ messages in thread
From: Christopher Dimech @ 2021-02-10 20:43 UTC (permalink / raw)
  To: moasenwood; +Cc: help-gnu-emacs

This disabling thing for tex-mode is killing me.

> Sent: Wednesday, February 10, 2021 at 7:05 AM
> 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: tex-mode.el
>
> Christopher Dimech wrote:
>
> > It does nothing but stops matching superscript
> > and subscript.
>
> Isn't that what you want? No match, no font lock?
>
> --
> underground experts united
> http://user.it.uu.se/~embe8573
> https://dataswamp.org/~incal
>
>
>



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2021-02-10 20:43               ` tex-mode.el Christopher Dimech
@ 2021-02-10 20:49                 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-02-10 21:01                   ` tex-mode.el Christopher Dimech
  0 siblings, 1 reply; 37+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-02-10 20:49 UTC (permalink / raw)
  To: help-gnu-emacs

Christopher Dimech wrote:

> This disabling thing for tex-mode is killing me.

Well, why is it so important? Try to think of/do something
else...

But, did you Tassilo Horn's suggestion?

(defun th/tex-toggle-script ()
  (interactive)
  (setq-local tex-fontify-script (not tex-fontify-script))
  (font-lock-flush))

What happens?

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2021-02-10 20:49                 ` tex-mode.el Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-02-10 21:01                   ` Christopher Dimech
  2021-02-10 21:21                     ` tex-mode.el Stefan Monnier
  2021-02-11  3:13                     ` tex-mode.el Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 2 replies; 37+ messages in thread
From: Christopher Dimech @ 2021-02-10 21:01 UTC (permalink / raw)
  To: moasenwood; +Cc: help-gnu-emacs

> Sent: Thursday, February 11, 2021 at 8:49 AM
> 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: tex-mode.el
>
> Christopher Dimech wrote:
>
> > This disabling thing for tex-mode is killing me.
>
> Well, why is it so important? Try to think of/do something
> else...

I did not think it would be so difficult to do.

> But, did you Tassilo Horn's suggestion?
>
> (defun th/tex-toggle-script ()
>   (interactive)
>   (setq-local tex-fontify-script (not tex-fontify-script))
>   (font-lock-flush))

> What happens?

Still same problem

(setq-local tex-fontify-script nil)
(font-lock-flush)

It works in the sense that when I call it the new text is not
fontified.  However, the text that was already fontified remains
fontified.

> --
> underground experts united
> http://user.it.uu.se/~embe8573
> https://dataswamp.org/~incal
>
>
>



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2021-02-10 21:01                   ` tex-mode.el Christopher Dimech
@ 2021-02-10 21:21                     ` Stefan Monnier
  2021-02-10 21:25                       ` tex-mode.el Christopher Dimech
  2021-02-11  3:13                     ` tex-mode.el Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 1 reply; 37+ messages in thread
From: Stefan Monnier @ 2021-02-10 21:21 UTC (permalink / raw)
  To: help-gnu-emacs

> Still same problem
>
> (setq-local tex-fontify-script nil)
> (font-lock-flush)
>
> It works in the sense that when I call it the new text is not
> fontified.  However, the text that was already fontified remains
> fontified.

Works for me, so maybe you want to provide a more detailed description
of what you do, and what is and isn't properly re-fontified.


        Stefan




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2021-02-10 21:21                     ` tex-mode.el Stefan Monnier
@ 2021-02-10 21:25                       ` Christopher Dimech
  2021-02-10 21:30                         ` tex-mode.el Stefan Monnier
  0 siblings, 1 reply; 37+ messages in thread
From: Christopher Dimech @ 2021-02-10 21:25 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 632 bytes --]

I could send you the minor I have put up.

> Sent: Thursday, February 11, 2021 at 9:21 AM
> From: "Stefan Monnier" <monnier@iro.umontreal.ca>
> To: help-gnu-emacs@gnu.org
> Subject: Re: tex-mode.el
>
> > Still same problem
> >
> > (setq-local tex-fontify-script nil)
> > (font-lock-flush)
> >
> > It works in the sense that when I call it the new text is not
> > fontified.  However, the text that was already fontified remains
> > fontified.
>
> Works for me, so maybe you want to provide a more detailed description
> of what you do, and what is and isn't properly re-fontified.
>
>
>         Stefan
>
>
>

[-- Attachment #2: crucible-mode.el --]
[-- Type: text/plain, Size: 18368 bytes --]

;;; crucible-mode.el --- Typeface for texmath -*- lexical-binding:t -*-

;; Copyright (C) 2021  Free Software Foundation

;; Author: Christopher Dimech <email@here.com>
;; URL: https://website-here
;; Version: 0.1.0
;; Package-Requires: ((emacs "27.1"))

;; This file is part of Behistun, a Gnu Behistun.

;; Behistun is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; Behintun is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the Gnu Affero General Public
;; License along with Behistun.  If not, see
;; <http://www.gnu.org/licenses/>.

;;; -------------------------------------------------------------------
;;; Commentary:

;; * Setting texmath keywords using rx
;;   rx uses regular expressions that are easier to read.
;;
;; * Byte Compilation
;;
;;   The Byte Compiler translates functions written in Lisp into
;;   byte-code, a special representation that makes functions execute
;;   faster.  The byte compiler also returns very useful messages.
;;
;;   To byte-compile a file named crucible-mode.el, launch Emacs and
;;   enter the following command.
;;
;;     M-x byte-compile-file Ret crucible-mode.el

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; (require 'rx) ; Is this needed

(eval-when-compile
  (setq byte-compile-function-environment
	(delq (assq 'crucible-mode byte-compile-function-environment)
	      byte-compile-function-environment)))

;; ---------------------------------------------------------------------
(defgroup crucible ()
  "Groups tools for assisting with superior & inferior typeface."
  :prefix "crucible-"
  :group 'crucible)

;; ---------------------------------------------------------------------
(defgroup mtksy-kwd ()
  "Groups tools for typesetting mathematical symbols."
  :prefix "crucible-mtksy"
  :group 'crucible)

;; ---------------------------------------------------------------------
(defvar crucible-mode-hook nil
  "Hook called when Crucible Mode is enabled.")

;; ---------------------------------------------------------------------
;;;###autoload
(define-minor-mode crucible-mode
  "Minor mode for assisting with superior & inferior typeface."
  :init-value nil
  :global nil
  :lighter " Crucible"
  (run-hooks 'crucible-mode-hook))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(multic "
* Colour tex keywords")
;;         _                _                  _
;;  __ ___| |___ _  _ _ _  | |____ __ ___ _ __| |
;; / _/ _ \ / _ \ || | '_| | / /\ V  V / '_/ _` |
;; \__\___/_\___/\_,_|_|   |_\_\ \_/\_/|_| \__,_|

;; ---------------------------------------------------------------------
(defface colour-tex-cruc
  '( (default :inherit bold)
     ( ((class color) (min-colors 88) (background light))
       :foreground "#FF0000" )
     ( ((class color) (min-colors 88) (background dark))
       :foreground "#FF0000" )
     (t :inherit font-lock-builtin-face) )
  "Typeface for tex keywords.")

;; -------------------------------------------------------------------------
(defconst tex-keywords-cruc
  `(
    ;; Greek.  Use (0 'colour-tex-cruc) to highlight the leading "\".
    (,(rx "\\" word-start (group (or "alpha" "beta" "chi" "delta"
          "Delta" "epsilon" "varepsilon" "eta" "gamma" "Gamma" "iota"
          "kappa" "lambda" "Lambda" "mu" "nu" "omega" "Omega" "phi"
          "varphi" "Phi" "pi" "varpi" "Pi" "psi" "Psi" "rho" "varrho"
          "sigma" "varsigma" "Sigma" "tau" "theta" "vartheta" "Theta"
          "upsilon" "Upsilon" "xi" "Xi" "zeta")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Mathematical symbols
    (,(rx "\\" word-start (group (or "infty" "Re" "Im" "angle"
          "triangle" "backslash" "vert" "Vert" "emptyset" "bot" "top"
          "exists" "forall" "hbar" "ell" "aleph" "imath" "jmath"
          "nabla" "neg" "lnot" "prime" "partial" "surd" "wp" "flat"
          "sharp" "natural" "clubsuit" "diamondsuit" "heartsuit"
          "spadesuit")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Binary operations
    (,(rx "\\" word-start (group (or "vee" "wedge" "amalg" "cap" "cup"
          "uplus" "sqcap" "sqcup" "dagger" "ddaccer" "land" "lor"
          "cdot" "diamond" "bullet" "circ" "bigcirc" "odot" "ominus"
          "oplus" "oslash" "otimes" "pm" "mp" "triangleleft"
          "triangleright" "bigtriangledown" "bigtriangleup" "ast"
          "star" "times" "div" "setminus" "wr")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Mathematical relations
    (,(rx "\\" word-start (group (or "asymp" "cong" "dashv" "vdash"
          "perp" "mid" "parallel" "doteq" "equiv" "ge" "geq" "le"
          "leq" "gg" "ll" "models" "ne" "neq" "notin" "in" "ni" "owns"
          "prec" "preceq" "succ" "succeq" "bowtie" "propto" "approx"
          "sim" "simeq" "frown" "smile" "subset" "subseteq" "supset"
          "supseteq" "sqsubseteq" "sqsupseteq" "cos" "sin" "tan" "cot"
          "csc" "sec" "arccos" "arcsin" "arctan" "cosh" "coth" "sinh"
          "tanh" "det" "dim" "exp" "ln" "log" "lg" "arg" "deg" "gcd"
          "hom" "ker" "inf" "sup" "lim" "liminf" "limsup" "max" "min"
          "Pr")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Delimeters
    (,(rx "\\" word-start (group (or "lbrace" "rbrace" "lbrack"
          "rbrack " "langle" "rangle" "lceil" "rceil" "lfloor"
          "rfloor")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Arrows
    (,(rx "\\" word-start (group (or "leftarrow" "gets" "Leftarrow"
          "rightarrow " "to" "Rightarrow" "leftrightarrow"
          "Leftrightarrow" "longleftarrow" "Longleftarrow"
          "longrightarrow" "Longrightarrow" "longleftrightarrow"
          "Longleftrightarrow" "iff" "hookleftarrow" "hookrightarrow"
          "leftharpoondown" "rightharpoondown" "leftharpoonup"
          "rightharpoonup" "rightleftharpoons" "mapsto" "longmapsto"
          "downarrow" "Downarrow" "uparrow" "Uparrow" "updownarrow"
          "Updownarrow" "nearrow" "searrow" "nwarrow" "swarrow"))
          word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Large mathematical operations
    (,(rx "\\" word-start (group (or "bigcap" "bigcup" "bigodot"
          "bigoplus" "bigotimes" "bigsqcup" "biguplus" "bigvee"
          "bigwedge" "coprod" "smallint" "int" "oint" "prod" "sum"
          "limits" "nolimits" "displaylimits")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Fractions and stacking
    (,(rx "\\" word-start (group (or "over" "atop" "above" "choose"
          "brace" "cases" "underbrace" "overbrace" "underline"
          "overline" "overleftarrow" "overrightarrow" "buildrel"
          "ldots" "cdots" "vdots" "ddots" "lgroup" "rgroup" "left"
          "right" "delimiter" "delimiterfactor" "delimitershortfall"
          "matrix" "pmatrix" "bordermatrix" "sqrt" "root" "of"))
          word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Punctuation and style
    (,(rx "\\" word-start (group (or "cdotp" "ldotp" "colon" "sb" "sp"
          "textstyle" "scriptstyle" "scriptscriptstyle"
          "displaystyle")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Mathematical accents
    (,(rx "\\" word-start (group (or "acute" "b" "bar" "breve" "check"
          "ddot" "dot" "grave" "hat" "widehat" "tilde" "widetilde"
          "vec")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Mathematical class
    (,(rx "\\" word-start (group (or "mathord" "mathop" "mathbin"
          "mathrel " "mathopen" "mathclose" "mathpunct")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Equations and multiline display
    (,(rx "\\" word-start (group (or "eqno" "leqno" "displaylines"
          "eqalign " "eqalignno" "leqalignno")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Big sizes.  Using concat rather than rx.
    (,(concat "\\\\\\<\\(big\\|bigl\\|bigm\\|bigr\\|Big\\|Bigl\\|"
              "Bigm\\|Bigr\\|bigg\\|biggl\\|biggm\\|biggr\\|"
              "Bigg\\|Biggl\\|Biggm\\|Biggr\\|downbracefill\\|"
              "upbracefill\\|arrowvert\\|Arrowvert\\|lmoustache\\|"
              "rmoustache\\|bracevert\\)\\>")
     (1 'colour-tex-cruc)) )
  "Fontification for letters and symbols.")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; * Positioning of superscripts and subscripts
;;               _       __
;;  ____  _ _ __(_)_ _  / _|  _ __  ___ ____ _
;; (_-< || | '_ \ | ' \|  _| | '_ \/ _ (_-< ' \
;; /__/\_,_| .__/_|_||_|_|   | .__/\___/__/_||_|
;;         |_|               |_|

;; ---------------------------------------------------------------------
(defcustom supinf-fontify-signal t
  "Enables typeface for tex commands."
  :type 'boolean
  :group 'supinf)

(put 'supinf-fontify-signal 'safe-local-variable 'booleanp)

;; ---------------------------------------------------------------------
(defcustom crucible-supinf-vshift '(0.18 -0.18)
  "Sets vertical shift for superior and inferior glyphs.
The first number is negative, whilst the second is positive.
Shift is measured relative to the text font size."
  :group 'supinf
  :type '(list (float :tag "superior-vshift")
               (float :tag "inferior-vshift")) )

;; ---------------------------------------------------------------------
(defcustom crucible-height-ratio 0.8
  "Sets relative supinf height ratio with the preceding text.
For nested expressions, the setting is applied repeatedly,
subject to the limit set by `crucible-height-minimum'."
  :type 'float
  :group 'supinf)

;; ---------------------------------------------------------------------
(defcustom crucible-height-minimum 0.8
  "Sets the minimum glyph height.
For integer values, the height is in units of 1/10 point.
Relative height is used for floating point values."
  :type '(choice (integer :tag "Font height in 1/10 point units")
		 (float   :tag "Fraction of font height"))
  :group 'supinf)

;; ---------------------------------------------------------------------
(defun crucible-supinf-match (limit)
  "Match superior and inferior glyph patterns up to LIMIT."
  (when (and supinf-fontify-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 crucible-supinf-height (height)
  "Return integer HEIGHT of superior and inferior glyph.
Height is an integer that is 1/10 of point size.  Not smaller than the
value set by `crucible-height-minimum'."
  (ceiling
     (max
        (if (integerp crucible-height-minimum)
	    crucible-height-minimum
	  (condition-case nil ; For bootstrapping.
	      (* crucible-height-minimum
		 (face-attribute 'default :height))
	    (error 0)))
	(* height crucible-height-ratio))))  ; assumes height is integer.

;; ---------------------------------------------------------------------
(defface supr-tfc-cruc
  '((t :height crucible-supinf-height))
  "Typography for superior glyphs."
  :group 'supinf)

;; ---------------------------------------------------------------------
(defface infr-tfc-cruc
  '((t :height crucible-supinf-height))
  "Typography for inferior glyphs."
  :group 'supinf)

;; ---------------------------------------------------------------------
(defun supinf-typeface-cruc (pos)
  "Fontify text at POS."
  (unless (or (memq (get-text-property pos 'face)
		    '(font-lock-constant-face
		      font-lock-builtin-face
		      font-lock-comment-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-cruc
	       display (raise ,(car crucible-supinf-vshift)))
      `(face infr-tfc-cruc
	     display (raise ,(cadr crucible-supinf-vshift))) )))

;; ---------------------------------------------------------------------
(defconst supinf-font-lock-cruc
  (append
      nil
      '( (crucible-supinf-match
	  (1 (supinf-typeface-cruc (match-beginning 0)) append))) )
  "Experimental expressions to highlight in TeX modes.")

;; ---------------------------------------------------------------------
(defun supinf-disable-cruc (beg end)
  "Set typeface for text between BEG and END."
  (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)) crucible-supinf-vshift)
	       (null (cddr prop)))
	  (put-text-property beg next 'display nil))
      (setq beg next))))

;; ---------------------------------------------------------------------
;;(defun tex-typeface-crucible ()
;;  "Font-lock setup for mathematical symbols."
;;  (font-lock-flush (point-min) (point-max))
;;  (if crucible-supinf-enable
;;      (progn
;;        (font-lock-add-keywords nil tex-keywords-cruc t)
;;        (font-lock-add-keywords nil supinf-font-lock-cruc t))
;;    (font-lock-remove-keywords nil tex-keywords-cruc)
;;    (supinf-disable-cruc (point-min) (point-max)))
;;  (font-lock-flush (point-min) (point-max)))

;;(defun supinf-typeface-crucible ()
;;  "Font-lock setup for mathematical symbols."
;;  (font-lock-flush (point-min) (point-max))
;;
;;  (if crucible-mode
;;      (font-lock-add-keywords nil tex-keywords-cruc t)
;;    (font-lock-remove-keywords nil tex-keywords-cruc))
;;
;;  (if crucible-supinf-enable
;;      (font-lock-add-keywords nil supinf-font-lock-cruc t)
;;  (supinf-disable-cruc (point-min) (point-max)))
;;
;;  (font-lock-flush (point-min) (point-max)))

(defun supinf-enable ()
  "Enable the supinf typeface"
  (font-lock-flush (point-min) (point-max))
  (font-lock-add-keywords nil supinf-font-lock-cruc t)
  (font-lock-flush (point-min) (point-max)) )

(defun supinf-disable ()
  "Disable the supinf typeface"
  (font-lock-flush (point-min) (point-max))
  (setq font-lock-defaults
	'(font-lock-unfontify-region-function . supinf-disable-cruc))
  ;;(supinf-disable-cruc (point-min) (point-max))
  (font-lock-flush (point-min) (point-max)) )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; * Displays texmath glyphs for the corresponding tex commands.
;;             _   _           _           _
;;  _ __  __ _| |_| |_    __ _| |_  _ _ __| |_  ___
;; | '  \/ _` |  _| ' \  / _` | | || | '_ \ ' \(_-<
;; |_|_|_\__,_|\__|_||_| \__, |_|\_, | .__/_||_/__/
;;                       |___/   |__/|_|

;;(require 'prog-mode)

(defun texglyph-predicate (start end _match)
  "Prettifies mathematical expressions written in tex syntax.
Matches start with a backslash and end with a word constituent
[a-zA-Z0-9].  Uses the prettify functionality provided by
prog-mode."
(not (or (memq (char-before start) '(?\\))
	 (memq (char-syntax (or (char-after end) ?\s)) '(?w))
	 (nth 8 (syntax-ppss)))))

;; ---------------------------------------------------------------------
(defun texglyph-typeface-crucible ()
  (push '("\\alpha" . ?α) prettify-symbols-alist)
  (push '("\\beta" . ?β) prettify-symbols-alist)
  (setq prettify-symbols-compose-predicate 'texglyph-predicate))

;; ---------------------------------------------------------------------
(defun texglyph-enable ()
  "Enables typeface for tex glyphs."
  (texglyph-typeface-crucible)
  (prettify-symbols-mode))

;; ---------------------------------------------------------------------
(defvar-local texglyph-state-cruc nil)

(defun texglyph-cycle-crucible ()
  "Breaks lines when they get beyond fill-column."
   (interactive)

   (pcase texglyph-state-cruc
     ;; ----------------------------------------------
     (1 (setq supinf-fontify-signal t)
	(supinf-enable)
        (message "Supinf Enabled")
        (setq-local texglyph-state-cruc (1+ texglyph-state-cruc)))
     ;; ----------------------------------------------
     (2 (texglyph-enable)
        (message "Supinf and Glyphs Enabled")
        (setq-local texglyph-state-cruc (1+ texglyph-state-cruc)))
     ;; ----------------------------------------------
     (_ (setq supinf-fontify-signal nil)
	;;(supinf-disable)
	(setq-local supinf-fontify-signal nil)
	;;(setq tex-font-script-display '(-0.0 0.0))
	;;(setq tex-suscript-height-ratio 0.0)
	(font-lock-flush)
	;;(font-lock-refresh-defaults)
	;;(prettify-symbols-mode 0)
	(message "Supinf and Glyphs Disabled")
        (setq-local texglyph-state-cruc 1)) ))

;; -----------------------------------------------------------------------
(defun texglyph-enableo ()
  "Enables a typeface for displaying tex commands."
  (texglyph-cycle-crucible))

;; -----------------------------------------------------------------------
(defun crucible-prettify-hook ()
  "defun-todo"
  (add-hook 'crucible-mode-hook #'supinf-typeface-crucible)
  (add-hook 'texinfo-mode-hook #'texglyph-typeface-crucible) )

(global-set-key (kbd "H-t") #'texglyph-cycle-crucible)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;(texglyph-typeface-crucible)
;; (texglyph-crucible)
;; (crucible-prettify-hook)
(provide 'crucible-mode)

;;; crucible-mode.el ends here

;; crucible-mode             Highlight tex keywords with colour scheme
;; crucible-supinf-enable    Enable supinf positioning
;; crucible-texglyph-enable  Associate glyphs with tex keywords

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2021-02-10 21:25                       ` tex-mode.el Christopher Dimech
@ 2021-02-10 21:30                         ` Stefan Monnier
  2021-02-10 21:54                           ` tex-mode.el Christopher Dimech
  0 siblings, 1 reply; 37+ messages in thread
From: Stefan Monnier @ 2021-02-10 21:30 UTC (permalink / raw)
  To: help-gnu-emacs

>> > It works in the sense that when I call it the new text is not
>> > fontified.  However, the text that was already fontified remains
>> > fontified.
>> Works for me, so maybe you want to provide a more detailed description
>> of what you do, and what is and isn't properly re-fontified.
> I could send you the minor I have put up.

You could, but that would be counter productive: it would just hide the
problem under more code.


        Stefan




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2021-02-10 21:30                         ` tex-mode.el Stefan Monnier
@ 2021-02-10 21:54                           ` Christopher Dimech
  0 siblings, 0 replies; 37+ messages in thread
From: Christopher Dimech @ 2021-02-10 21:54 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

When I tried with tex-made.el, it works, but there must be some
silly thing in my minor mode that messes things up.  The minor mode
is quite simple and self contained, but seems to be missing either
some functionality or is being set up in some weird way.



> Sent: Thursday, February 11, 2021 at 9:30 AM
> From: "Stefan Monnier" <monnier@iro.umontreal.ca>
> To: help-gnu-emacs@gnu.org
> Subject: Re: tex-mode.el
>
> >> > It works in the sense that when I call it the new text is not
> >> > fontified.  However, the text that was already fontified remains
> >> > fontified.
> >> Works for me, so maybe you want to provide a more detailed description
> >> of what you do, and what is and isn't properly re-fontified.
> > I could send you the minor I have put up.
>
> You could, but that would be counter productive: it would just hide the
> problem under more code.
>
>
>         Stefan
>
>
>



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2021-02-10 21:01                   ` tex-mode.el Christopher Dimech
  2021-02-10 21:21                     ` tex-mode.el Stefan Monnier
@ 2021-02-11  3:13                     ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-02-11  3:27                       ` tex-mode.el Christopher Dimech
  1 sibling, 1 reply; 37+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-02-11  3:13 UTC (permalink / raw)
  To: help-gnu-emacs

Christopher Dimech wrote:

> Still same problem
>
> (setq-local tex-fontify-script nil)
> (font-lock-flush)
>
> It works in the sense that when I call it the new text is
> not fontified. However, the text that was already fontified
> remains fontified.

Does it work for you when you start Emacs with -Q?

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2021-02-11  3:13                     ` tex-mode.el Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-02-11  3:27                       ` Christopher Dimech
  0 siblings, 0 replies; 37+ messages in thread
From: Christopher Dimech @ 2021-02-11  3:27 UTC (permalink / raw)
  To: moasenwood; +Cc: help-gnu-emacs

I think that I have found a problem with my code, because when I applied
the two commands mentioned for tex-mode.el the fontifying was disabled on
the entire buffer.

(setq-local tex-fontify-script nil)
(font-lock-flush)

I am actually trying to write a minor-mode for suscript to work also
for texinfo, when one can call tex commands.  For texinfo, the
fontifying is enabled as soon as the mode is called.  However, for
my minor mode I would like that a function would set things up, and
another to disable it.

Have copied the following code parts from tex-mode.el and want to
write a function that enables the raising and lowering fontification.
And anothr that I can call to disable.  Have fount the setup in
tex-mode.el quite complicated.

--------

(defcustom tex-fontify-script t)
(defcustom tex-font-script-display '(-0.2 0.2))
(defcustom tex-suscript-height-ratio 0.8)
(defcustom tex-suscript-height-minimum 0.0)
(defun tex-suscript-height height)

(defface superscript )
(defface subscript )

(defun tex-font-lock-match-suscript limit)
(defun tex-font-lock-suscript pos)
(defun tex-font-lock-unfontify-region beg end)



> Sent: Thursday, February 11, 2021 at 3:13 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: tex-mode.el
>
> Christopher Dimech wrote:
>
> > Still same problem
> >
> > (setq-local tex-fontify-script nil)
> > (font-lock-flush)
> >
> > It works in the sense that when I call it the new text is
> > not fontified. However, the text that was already fontified
> > remains fontified.
>
> Does it work for you when you start Emacs with -Q?
>
> --
> underground experts united
> http://user.it.uu.se/~embe8573
> https://dataswamp.org/~incal
>
>
>



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2021-02-10  4:01                 ` tex-mode.el Christopher Dimech
@ 2021-02-11  3:42                   ` Michael Heerdegen
  2021-02-11  4:01                     ` tex-mode.el Christopher Dimech
  2021-02-11 21:11                   ` tex-mode.el Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 1 reply; 37+ messages in thread
From: Michael Heerdegen @ 2021-02-11  3:42 UTC (permalink / raw)
  To: help-gnu-emacs

Christopher,

After commenting out the `multic' expression I could try your example.

I'm not really skilled with font-lock.

I think in your case `font-lock-flush' is indeed not enough, I think
that one doesn't unfontify, which has to be done in your case.
`font-lock-refresh-defaults' as had been suggested should be better.

Your unfontify function seems to work when called (tested).  But is it
called?

I think here:

(defun supinf-disable ()
  "Disable the supinf typeface"
  (font-lock-flush (point-min) (point-max))
  (setq font-lock-defaults
	'(font-lock-unfontify-region-function . supinf-disable-cruc))
        ^^^^
  ;;(supinf-disable-cruc (point-min) (point-max))
  (font-lock-flush (point-min) (point-max)) )

you are missing a level of parens.  Then, with some good will, the thing
could indeed work I think.

Oh, and it seems something in your mode is not done buffer locally,
since the ^^^^ underlining here now looks weird in my messages buffer,
where I definitely didn't enable your mode.  Or maybe just a side effect
of experimenting, dunno.

HTH,

Michael.




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2021-02-11  3:42                   ` tex-mode.el Michael Heerdegen
@ 2021-02-11  4:01                     ` Christopher Dimech
  2021-02-11  4:11                       ` tex-mode.el Michael Heerdegen
  0 siblings, 1 reply; 37+ messages in thread
From: Christopher Dimech @ 2021-02-11  4:01 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: help-gnu-emacs

When I used "tex-mode.el", the suscript fontification can be disabled
using the following function.  But does not work with my minor-mode.

(defun supinf-disable ()
   (interactive)
   (setq-local tex-fontify-script nil)
   (font-lock-flush))

I am trying to have two functions, one to enable, another
to disable.  Enabling is also creating me problems to set up.
The code in tex-mode.el is in quite a mess and surely does not
help a lot.

> Sent: Thursday, February 11, 2021 at 3:42 PM
> From: "Michael Heerdegen" <michael_heerdegen@web.de>
> To: help-gnu-emacs@gnu.org
> Subject: Re: tex-mode.el
>
> Christopher,
>
> After commenting out the `multic' expression I could try your example.
>
> I'm not really skilled with font-lock.
>
> I think in your case `font-lock-flush' is indeed not enough, I think
> that one doesn't unfontify, which has to be done in your case.
> `font-lock-refresh-defaults' as had been suggested should be better.
>
> Your unfontify function seems to work when called (tested).  But is it
> called?
>
> I think here:
>
> (defun supinf-disable ()
>   "Disable the supinf typeface"
>   (font-lock-flush (point-min) (point-max))
>   (setq font-lock-defaults
> 	'(font-lock-unfontify-region-function . supinf-disable-cruc))
>         ^^^^
>   ;;(supinf-disable-cruc (point-min) (point-max))
>   (font-lock-flush (point-min) (point-max)) )

Yes, it was a bad attempt from my part.  It was the routine hack I was
playing with.

> you are missing a level of parens.  Then, with some good will, the thing
> could indeed work I think.
>
> Oh, and it seems something in your mode is not done buffer locally,
> since the ^^^^ underlining here now looks weird in my messages buffer,
> where I definitely didn't enable your mode.  Or maybe just a side effect
> of experimenting, dunno.
>
> HTH,
>
> Michael.
>
>
>



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2021-02-11  4:01                     ` tex-mode.el Christopher Dimech
@ 2021-02-11  4:11                       ` Michael Heerdegen
  2021-02-11  4:27                         ` tex-mode.el Christopher Dimech
  2021-02-11 13:29                         ` tex-mode.el Christopher Dimech
  0 siblings, 2 replies; 37+ messages in thread
From: Michael Heerdegen @ 2021-02-11  4:11 UTC (permalink / raw)
  To: Christopher Dimech; +Cc: help-gnu-emacs

Christopher Dimech <dimech@gmx.com> writes:

> When I used "tex-mode.el", the suscript fontification can be disabled
> using the following function.  But does not work with my minor-mode.
>
> (defun supinf-disable ()
>    (interactive)
>    (setq-local tex-fontify-script nil)
>    (font-lock-flush))

I would M-x trace-function to check if `supinf-disable-cruc' (enter the
name at the prompt) is called when you disable.  It should be.  And the
function seems to do the job.

> I am trying to have two functions, one to enable, another
> to disable.  Enabling is also creating me problems to set up.
> The code in tex-mode.el is in quite a mess and surely does not
> help a lot.

It's no simple stuff.  I'll try to have another look tomorrow when I get
the time - or do you have any concrete questions?

Michael.



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2021-02-11  4:11                       ` tex-mode.el Michael Heerdegen
@ 2021-02-11  4:27                         ` Christopher Dimech
  2021-02-11 13:29                         ` tex-mode.el Christopher Dimech
  1 sibling, 0 replies; 37+ messages in thread
From: Christopher Dimech @ 2021-02-11  4:27 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: help-gnu-emacs


> Sent: Thursday, February 11, 2021 at 4:11 PM
> From: "Michael Heerdegen" <michael_heerdegen@web.de>
> To: "Christopher Dimech" <dimech@gmx.com>
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: tex-mode.el
>
> Christopher Dimech <dimech@gmx.com> writes:
>
> > When I used "tex-mode.el", the suscript fontification can be disabled
> > using the following function.  But does not work with my minor-mode.
> >
> > (defun supinf-disable ()
> >    (interactive)
> >    (setq-local tex-fontify-script nil)
> >    (font-lock-flush))
>
> I would M-x trace-function to check if `supinf-disable-cruc' (enter the
> name at the prompt) is called when you disable.  It should be.  And the
> function seems to do the job.
>
> > I am trying to have two functions, one to enable, another
> > to disable.  Enabling is also creating me problems to set up.
> > The code in tex-mode.el is in quite a mess and surely does not
> > help a lot.
>
> It's no simple stuff.  I'll try to have another look tomorrow when I get
> the time - or do you have any concrete questions?

I would appreciate that very much because I think that the task does require
some community effort.  I discussed my plan with Stefan Monnier and he's all
for the change.

> Michael.
>
>



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2021-02-11  4:11                       ` tex-mode.el Michael Heerdegen
  2021-02-11  4:27                         ` tex-mode.el Christopher Dimech
@ 2021-02-11 13:29                         ` Christopher Dimech
  1 sibling, 0 replies; 37+ messages in thread
From: Christopher Dimech @ 2021-02-11 13:29 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: help-gnu-emacs

The whole point would be to call "(tex-font-lock-match-suscript limit)"
and "(tex-font-lock-suscript pos)", which is then to be added to
font-lock.

My minor-mode has the equivalent code under different function names.



> Sent: Thursday, February 11, 2021 at 4:11 PM
> From: "Michael Heerdegen" <michael_heerdegen@web.de>
> To: "Christopher Dimech" <dimech@gmx.com>
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: tex-mode.el
>
> Christopher Dimech <dimech@gmx.com> writes:
>
> > When I used "tex-mode.el", the suscript fontification can be disabled
> > using the following function.  But does not work with my minor-mode.
> >
> > (defun supinf-disable ()
> >    (interactive)
> >    (setq-local tex-fontify-script nil)
> >    (font-lock-flush))
>
> I would M-x trace-function to check if `supinf-disable-cruc' (enter the
> name at the prompt) is called when you disable.  It should be.  And the
> function seems to do the job.
>
> > I am trying to have two functions, one to enable, another
> > to disable.  Enabling is also creating me problems to set up.
> > The code in tex-mode.el is in quite a mess and surely does not
> > help a lot.
>
> It's no simple stuff.  I'll try to have another look tomorrow when I get
> the time - or do you have any concrete questions?
>
> Michael.
>
>



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2021-02-10  4:01                 ` tex-mode.el Christopher Dimech
  2021-02-11  3:42                   ` tex-mode.el Michael Heerdegen
@ 2021-02-11 21:11                   ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-02-11 23:08                     ` tex-mode.el Christopher Dimech
  1 sibling, 1 reply; 37+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-02-11 21:11 UTC (permalink / raw)
  To: help-gnu-emacs

Christopher Dimech wrote:

> I have made a minor mode for texinfo that does this, but the
> buffer is not being returned to look as source code.
> They still look that they have a difference in height.
>
> I attach the file with a test.

Using this...

(require 'checkdoc)

(setq checkdoc-permit-comma-termination-flag t)

(defun check-package-style ()
  (interactive)
  (let ((msg "Style check..."))
    (message msg)
    (checkdoc-current-buffer t) ; TAKE-NOTES
    (message "%sdone" msg) ))
(defalias 'check-style #'check-package-style)

It says

*** crucible-mode.el: checkdoc-current-buffer
crucible-mode.el:47: You should have a section marked ";;; Code:"
crucible-mode.el:360: First sentence should end with punctuation
crucible-mode.el:366: First sentence should end with punctuation
crucible-mode.el:384: Argument ‘start’ should appear (as START) in the doc string
crucible-mode.el:386: Lisp symbol ‘prog-mode’ should appear in quotes
crucible-mode.el:394: All variables and subroutines might as well have a documentation string
crucible-mode.el:408: Lisp symbol ‘fill-column’ should appear in quotes
crucible-mode.el:440: First sentence should end with punctuation
crucible-mode.el:440: First line should be capitalized

Using the byte compiler, it says

crucible-mode.el: 
In texglyph-cycle-crucible:
crucible-mode.el:425:10: Warning: assignment to free variable
    ‘tex-font-script-display’
crucible-mode.el:426:10: Warning: assignment to free variable
    ‘tex-suscript-height-ratio’

In end of data:
crucible-mode.el:458:1: Warning: the following functions are not known to be
    defined: multic, supinf-typeface-crucible

Seems to be minor issues most (all?) of them but you might as
well fix them to be home free. If and when you do that, I'd be
happy to look at it again, if there are still issues...

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: tex-mode.el
  2021-02-11 21:11                   ` tex-mode.el Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-02-11 23:08                     ` Christopher Dimech
  0 siblings, 0 replies; 37+ messages in thread
From: Christopher Dimech @ 2021-02-11 23:08 UTC (permalink / raw)
  To: moasenwood; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 2879 bytes --]

Have cleaned up the code, and have identified the problematic part.
I wish to tidy up the "font-lock-add-keywords" part.

Currently the supinf typeface is set using "add-hook", making supinf
activate as soon as one reads the file in emacs.  But, that is not what
I would like. 

I would like a function that turns on the supinf typeface, and have another
one that turns it off.  When one reads the file, everything will be shown
an normal text without the typeface.  And with the key-sequence "H-t", one
could then cycle through the different typefaces.


> Sent: Friday, February 12, 2021 at 9:11 AM
> 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: tex-mode.el
>
> Christopher Dimech wrote:
> 
> > I have made a minor mode for texinfo that does this, but the
> > buffer is not being returned to look as source code.
> > They still look that they have a difference in height.
> >
> > I attach the file with a test.
> 
> Using this...
> 
> (require 'checkdoc)
> 
> (setq checkdoc-permit-comma-termination-flag t)
> 
> (defun check-package-style ()
>   (interactive)
>   (let ((msg "Style check..."))
>     (message msg)
>     (checkdoc-current-buffer t) ; TAKE-NOTES
>     (message "%sdone" msg) ))
> (defalias 'check-style #'check-package-style)
> 
> It says
> 
> *** crucible-mode.el: checkdoc-current-buffer
> crucible-mode.el:47: You should have a section marked ";;; Code:"
> crucible-mode.el:360: First sentence should end with punctuation
> crucible-mode.el:366: First sentence should end with punctuation
> crucible-mode.el:384: Argument ‘start’ should appear (as START) in the doc string
> crucible-mode.el:386: Lisp symbol ‘prog-mode’ should appear in quotes
> crucible-mode.el:394: All variables and subroutines might as well have a documentation string
> crucible-mode.el:408: Lisp symbol ‘fill-column’ should appear in quotes
> crucible-mode.el:440: First sentence should end with punctuation
> crucible-mode.el:440: First line should be capitalized
> 
> Using the byte compiler, it says
> 
> crucible-mode.el: 
> In texglyph-cycle-crucible:
> crucible-mode.el:425:10: Warning: assignment to free variable
>     ‘tex-font-script-display’
> crucible-mode.el:426:10: Warning: assignment to free variable
>     ‘tex-suscript-height-ratio’
> 
> In end of data:
> crucible-mode.el:458:1: Warning: the following functions are not known to be
>     defined: multic, supinf-typeface-crucible
> 
> Seems to be minor issues most (all?) of them but you might as
> well fix them to be home free. If and when you do that, I'd be
> happy to look at it again, if there are still issues...
> 
> -- 
> underground experts united
> http://user.it.uu.se/~embe8573
> https://dataswamp.org/~incal
> 
> 
>

[-- Attachment #2: crucible-mode.el --]
[-- Type: text/plain, Size: 16933 bytes --]

;;; crucible-mode.el --- Typeface for texmath -*- lexical-binding:t -*-

;; Copyright (C) 2021  Free Software Foundation

;; Author: Christopher Dimech <email@here.com>
;; URL: https://website-here
;; Version: 0.1.0
;; Package-Requires: ((emacs "27.1"))

;; This file is part of Behistun, a Gnu Behistun.

;; Behistun is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; Behintun is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the Gnu Affero General Public
;; License along with Behistun.  If not, see
;; <http://www.gnu.org/licenses/>.

;;; -------------------------------------------------------------------
;;; Commentary:

;; * Setting texmath keywords using rx
;;   rx uses regular expressions that are easier to read.
;;
;; * Byte Compilation
;;
;;   The Byte Compiler translates functions written in Lisp into
;;   byte-code, a special representation that makes functions execute
;;   faster.  The byte compiler also returns very useful messages.
;;
;;   To byte-compile a file named crucible-mode.el, launch Emacs and
;;   enter the following command.
;;
;;     M-x byte-compile-file Ret crucible-mode.el

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; (require 'rx) ; Is this needed

;; (eval-when-compile
;;   (setq byte-compile-function-environment
;;	(delq (assq 'crucible-mode byte-compile-function-environment)
;;	      byte-compile-function-environment)))

;; ---------------------------------------------------------------------
;;; Code:

(defgroup crucible ()
  "Groups tools for assisting with superior & inferior typeface."
  :prefix "crucible-"
  :group 'crucible)

;; ---------------------------------------------------------------------
(defgroup keyword-tfc ()
  "Groups tools for typesetting mathematical symbols."
  :prefix "crucible-keyword"
  :group 'crucible)

;; ---------------------------------------------------------------------
(defvar crucible-mode-hook nil
  "Hook called when Crucible Mode is enabled.")

;; ---------------------------------------------------------------------
;;;###autoload
(define-minor-mode crucible-mode
  "Minor mode for assisting with superior & inferior typeface."
  :init-value nil
  :global nil
  :lighter " Crucible"
  (run-hooks 'crucible-mode-hook))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(multic "
* Colour tex keywords")
;;         _                _                  _
;;  __ ___| |___ _  _ _ _  | |____ __ ___ _ __| |
;; / _/ _ \ / _ \ || | '_| | / /\ V  V / '_/ _` |
;; \__\___/_\___/\_,_|_|   |_\_\ \_/\_/|_| \__,_|

;; ---------------------------------------------------------------------
(defface colour-tex-cruc
  '( (default :inherit bold)
     ( ((class color) (min-colors 88) (background light))
       :foreground "#FF0000" )
     ( ((class color) (min-colors 88) (background dark))
       :foreground "#FF0000" )
     (t :inherit font-lock-builtin-face) )
  "Typeface for tex keywords.")

;; -------------------------------------------------------------------------
(defconst tex-keywords-cruc
  `(
    ;; Greek.  Use (0 'colour-tex-cruc) to highlight the leading "\".
    (,(rx "\\" word-start (group (or "alpha" "beta" "chi" "delta"
          "Delta" "epsilon" "varepsilon" "eta" "gamma" "Gamma" "iota"
          "kappa" "lambda" "Lambda" "mu" "nu" "omega" "Omega" "phi"
          "varphi" "Phi" "pi" "varpi" "Pi" "psi" "Psi" "rho" "varrho"
          "sigma" "varsigma" "Sigma" "tau" "theta" "vartheta" "Theta"
          "upsilon" "Upsilon" "xi" "Xi" "zeta")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Mathematical symbols
    (,(rx "\\" word-start (group (or "infty" "Re" "Im" "angle"
          "triangle" "backslash" "vert" "Vert" "emptyset" "bot" "top"
          "exists" "forall" "hbar" "ell" "aleph" "imath" "jmath"
          "nabla" "neg" "lnot" "prime" "partial" "surd" "wp" "flat"
          "sharp" "natural" "clubsuit" "diamondsuit" "heartsuit"
          "spadesuit")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Binary operations
    (,(rx "\\" word-start (group (or "vee" "wedge" "amalg" "cap" "cup"
          "uplus" "sqcap" "sqcup" "dagger" "ddaccer" "land" "lor"
          "cdot" "diamond" "bullet" "circ" "bigcirc" "odot" "ominus"
          "oplus" "oslash" "otimes" "pm" "mp" "triangleleft"
          "triangleright" "bigtriangledown" "bigtriangleup" "ast"
          "star" "times" "div" "setminus" "wr")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Mathematical relations
    (,(rx "\\" word-start (group (or "asymp" "cong" "dashv" "vdash"
          "perp" "mid" "parallel" "doteq" "equiv" "ge" "geq" "le"
          "leq" "gg" "ll" "models" "ne" "neq" "notin" "in" "ni" "owns"
          "prec" "preceq" "succ" "succeq" "bowtie" "propto" "approx"
          "sim" "simeq" "frown" "smile" "subset" "subseteq" "supset"
          "supseteq" "sqsubseteq" "sqsupseteq" "cos" "sin" "tan" "cot"
          "csc" "sec" "arccos" "arcsin" "arctan" "cosh" "coth" "sinh"
          "tanh" "det" "dim" "exp" "ln" "log" "lg" "arg" "deg" "gcd"
          "hom" "ker" "inf" "sup" "lim" "liminf" "limsup" "max" "min"
          "Pr")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Delimeters
    (,(rx "\\" word-start (group (or "lbrace" "rbrace" "lbrack"
          "rbrack " "langle" "rangle" "lceil" "rceil" "lfloor"
          "rfloor")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Arrows
    (,(rx "\\" word-start (group (or "leftarrow" "gets" "Leftarrow"
          "rightarrow " "to" "Rightarrow" "leftrightarrow"
          "Leftrightarrow" "longleftarrow" "Longleftarrow"
          "longrightarrow" "Longrightarrow" "longleftrightarrow"
          "Longleftrightarrow" "iff" "hookleftarrow" "hookrightarrow"
          "leftharpoondown" "rightharpoondown" "leftharpoonup"
          "rightharpoonup" "rightleftharpoons" "mapsto" "longmapsto"
          "downarrow" "Downarrow" "uparrow" "Uparrow" "updownarrow"
          "Updownarrow" "nearrow" "searrow" "nwarrow" "swarrow"))
          word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Large mathematical operations
    (,(rx "\\" word-start (group (or "bigcap" "bigcup" "bigodot"
          "bigoplus" "bigotimes" "bigsqcup" "biguplus" "bigvee"
          "bigwedge" "coprod" "smallint" "int" "oint" "prod" "sum"
          "limits" "nolimits" "displaylimits")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Fractions and stacking
    (,(rx "\\" word-start (group (or "over" "atop" "above" "choose"
          "brace" "cases" "underbrace" "overbrace" "underline"
          "overline" "overleftarrow" "overrightarrow" "buildrel"
          "ldots" "cdots" "vdots" "ddots" "lgroup" "rgroup" "left"
          "right" "delimiter" "delimiterfactor" "delimitershortfall"
          "matrix" "pmatrix" "bordermatrix" "sqrt" "root" "of"))
          word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Punctuation and style
    (,(rx "\\" word-start (group (or "cdotp" "ldotp" "colon" "sb" "sp"
          "textstyle" "scriptstyle" "scriptscriptstyle"
          "displaystyle")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Mathematical accents
    (,(rx "\\" word-start (group (or "acute" "b" "bar" "breve" "check"
          "ddot" "dot" "grave" "hat" "widehat" "tilde" "widetilde"
          "vec")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Mathematical class
    (,(rx "\\" word-start (group (or "mathord" "mathop" "mathbin"
          "mathrel " "mathopen" "mathclose" "mathpunct")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Equations and multiline display
    (,(rx "\\" word-start (group (or "eqno" "leqno" "displaylines"
          "eqalign " "eqalignno" "leqalignno")) word-end)
     (1 'colour-tex-cruc))
    ;;
    ;; Big sizes.  Using concat rather than rx.
    (,(concat "\\\\\\<\\(big\\|bigl\\|bigm\\|bigr\\|Big\\|Bigl\\|"
              "Bigm\\|Bigr\\|bigg\\|biggl\\|biggm\\|biggr\\|"
              "Bigg\\|Biggl\\|Biggm\\|Biggr\\|downbracefill\\|"
              "upbracefill\\|arrowvert\\|Arrowvert\\|lmoustache\\|"
              "rmoustache\\|bracevert\\)\\>")
     (1 'colour-tex-cruc)) )
  "Fontification for letters and symbols.")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; * Positioning of superscripts and subscripts
;;               _       __
;;  ____  _ _ __(_)_ _  / _|  _ __  ___ ____ _
;; (_-< || | '_ \ | ' \|  _| | '_ \/ _ (_-< ' \
;; /__/\_,_| .__/_|_||_|_|   | .__/\___/__/_||_|
;;         |_|               |_|

;; ---------------------------------------------------------------------
(defcustom supinf-signal t
  "Enables typeface for tex commands."
  :type 'boolean
  :group 'supinf)

(put 'supinf-signal 'safe-local-variable 'booleanp)

;; ---------------------------------------------------------------------
(defcustom deviat-supinf '(0.18 -0.18)
  "Sets the vertical shift for superior and inferior glyphs.
Deviation is measured relative to the text font size."
  :group 'supinf
  :type '(list (float :tag "superior-deviation")
               (float :tag "inferior-deviation")) )

;; ---------------------------------------------------------------------
(defcustom height-scale-supinf 0.8
  "Sets relative supinf height ratio with the preceding text.
For nested expressions, the setting is applied repeatedly,
subject to the limit set by `crucible-height-minimum'."
  :type 'float
  :group 'supinf)

;; ---------------------------------------------------------------------
(defcustom height-minimum-supinf 0.8
  "Sets the minimum glyph height.
For integer values, the height is in units of 1/10 point.
Relative height is used for floating point values."
  :type '(choice (integer :tag "Font height in 1/10 point units")
		 (float   :tag "Fraction of font height"))
  :group 'supinf)

;; ---------------------------------------------------------------------
(defun supinf-height (height)
  "Return integer HEIGHT of superior and inferior glyph.
Height is an integer that is 1/10 of point size.  Not smaller than the
value set by `crucible-height-minimum'."
  (ceiling
     (max
        (if (integerp height-minimum-supinf)
	    height-minimum-supinf
	  (condition-case nil ; For bootstrapping.
	      (* height-minimum-supinf
		 (face-attribute 'default :height))
	    (error 0)))
	(* height height-scale-supinf))))  ; assumes height is integer.

;; ---------------------------------------------------------------------
(defface supr-tfc
  '((t :height supinf-height))
  "Typography for superior glyphs."
  :group 'supinf)

;; ---------------------------------------------------------------------
(defface infr-tfc
  '((t :height supinf-height))
  "Typography for inferior glyphs."
  :group 'supinf)

;; ---------------------------------------------------------------------
(defun supinf-raise-cruc (pos)
  "Raise and lower typeface at position POS."
  (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."
  (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))

;; ---------------------------------------------------------------------
(defconst supinf-font-lock-cruc
  (append
     '((supinf-match
          (1 (supinf-raise-cruc (match-beginning 0))) )))
  "Experimental expressions to highlight in TeX modes.")

;; ---------------------------------------------------------------------
(defun supinf-enable ()
  "Enables a typeface for displaying tex commands."
  (setq supinf-signal t)
  (font-lock-add-keywords nil supinf-font-lock-cruc t))

;; ---------------------------------------------------------------------
(defun supinf-disable-cruc (beg end)
  "Set typeface for text between BEG and END."
  (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))))

;; ---------------------------------------------------------------------
;;(defun tex-typeface-crucible ()
;;  "Font-lock setup for mathematical symbols."
;;  (font-lock-flush (point-min) (point-max))
;;  (if crucible-supinf-enable
;;      (progn
;;        (font-lock-add-keywords nil tex-keywords-cruc t)
;;        (font-lock-add-keywords nil supinf-font-lock-cruc t))
;;    (font-lock-remove-keywords nil tex-keywords-cruc)
;;    (supinf-disable-cruc (point-min) (point-max)))
;;  (font-lock-flush (point-min) (point-max)))

(defun supinf-disable ()
  "Disable supinf functionality."
  (interactive)
  (setq-local supinf-signal nil)
  (font-lock-flush))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; * Displays texmath glyphs for the corresponding tex commands.
;;             _   _           _           _
;;  _ __  __ _| |_| |_    __ _| |_  _ _ __| |_  ___
;; | '  \/ _` |  _| ' \  / _` | | || | '_ \ ' \(_-<
;; |_|_|_\__,_|\__|_||_| \__, |_|\_, | .__/_||_/__/
;;                       |___/   |__/|_|

;;(require 'prog-mode)

(defun texglyph-predicate (start end _match)
  "Prettify mathematical expressions defined using tex syntax.
Matches START with a backslash and END with a word constituent
[a-zA-Z0-9].  Uses the prettify functionality provided by
'prog-mode'."

(not (or (memq (char-before start) '(?\\))
	 (memq (char-syntax (or (char-after end) ?\s)) '(?w))
	 (nth 8 (syntax-ppss)))))

;; ---------------------------------------------------------------------
(defun texglyph-crucible ()
  "Set keywords and corresponding glyph."
  (push '("\\alpha" . ?α) prettify-symbols-alist)
  (push '("\\beta" . ?β) prettify-symbols-alist)
  (setq prettify-symbols-compose-predicate 'texglyph-predicate))

;; ---------------------------------------------------------------------
(defun texglyph-enable ()
  "Enables typeface for tex glyphs."
  (texglyph-crucible)
  (prettify-symbols-mode))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; ---------------------------------------------------------------------
(defvar-local texglyph-state-cruc nil)

(defun texglyph-cycle-crucible ()
  "Cycles supinf and texglyph functionality."
   (interactive)
   (pcase texglyph-state-cruc
     ;; ----------------------------------------------
     (1 (setq supinf-signal t)
	(supinf-enable)
	(message "Supinf Enabled")
        (setq-local texglyph-state-cruc (1+ texglyph-state-cruc)))
     ;; ----------------------------------------------
     (2 (texglyph-enable)
        (message "Supinf and Glyphs Enabled")
        (setq-local texglyph-state-cruc (1+ texglyph-state-cruc)))
     ;; ----------------------------------------------
     (_ (supinf-disable)
	(prettify-symbols-mode 0)
	(message "Supinf and Glyphs Disabled")
        (setq-local texglyph-state-cruc 1)) ))

;; -----------------------------------------------------------------------
(defun crucible-prettify-hook ()
  "Hooks."
  (add-hook 'crucible-mode-hook #'supinf-enable)
  (add-hook 'texinfo-mode-hook #'texglyph-crucible))

(global-set-key (kbd "H-t") #'texglyph-cycle-crucible)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(crucible-prettify-hook)
(provide 'crucible-mode)

;;; crucible-mode.el ends here

[-- Attachment #3: crucible-test.texi --]
[-- Type: application/x-texinfo, Size: 1397 bytes --]

^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2021-02-11 23:08 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-09 17:13 tex-mode.el Christopher Dimech
2021-02-09 17:22 ` tex-mode.el Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-09 17:45   ` tex-mode.el Christopher Dimech
2021-02-09 18:15     ` tex-mode.el Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-09 18:26       ` tex-mode.el Christopher Dimech
2021-02-09 18:37         ` tex-mode.el Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-09 18:52           ` tex-mode.el Christopher Dimech
2021-02-09 19:05             ` tex-mode.el Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-09 19:39               ` tex-mode.el Christopher Dimech
2021-02-09 19:45               ` tex-mode.el Christopher Dimech
2021-02-10 20:43               ` tex-mode.el Christopher Dimech
2021-02-10 20:49                 ` tex-mode.el Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-10 21:01                   ` tex-mode.el Christopher Dimech
2021-02-10 21:21                     ` tex-mode.el Stefan Monnier
2021-02-10 21:25                       ` tex-mode.el Christopher Dimech
2021-02-10 21:30                         ` tex-mode.el Stefan Monnier
2021-02-10 21:54                           ` tex-mode.el Christopher Dimech
2021-02-11  3:13                     ` tex-mode.el Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-11  3:27                       ` tex-mode.el Christopher Dimech
2021-02-09 20:13         ` tex-mode.el tomas
2021-02-09 20:26           ` tex-mode.el Christopher Dimech
2021-02-09 20:45             ` tex-mode.el tomas
2021-02-10  3:53               ` tex-mode.el Michael Heerdegen
2021-02-10  4:01                 ` tex-mode.el Christopher Dimech
2021-02-11  3:42                   ` tex-mode.el Michael Heerdegen
2021-02-11  4:01                     ` tex-mode.el Christopher Dimech
2021-02-11  4:11                       ` tex-mode.el Michael Heerdegen
2021-02-11  4:27                         ` tex-mode.el Christopher Dimech
2021-02-11 13:29                         ` tex-mode.el Christopher Dimech
2021-02-11 21:11                   ` tex-mode.el Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-11 23:08                     ` tex-mode.el Christopher Dimech
  -- strict thread matches above, loose matches on Subject: below --
2010-09-20 14:18 tex-mode.el Sean Sieger
2010-09-20 15:27 ` tex-mode.el Stefan Monnier
2010-09-20 15:48   ` tex-mode.el Sean Sieger
2005-02-26 15:10 tex-mode.el Eli Zaretskii
2005-02-26 15:16 ` tex-mode.el Luc Teirlinck
2005-02-27 13:43 ` tex-mode.el Richard Stallman

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.