1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362
|
;;; maths-menu.el --- insert maths characters from a menu -*- lexical-binding:t; coding: utf-8 -*-
;; This file is part of Proof General.
;; Portions © Copyright 1994-2012 David Aspinall and University of Edinburgh
;; Portions © Copyright 2003-2021 Free Software Foundation, Inc.
;; Portions © Copyright 2001-2017 Pierre Courtieu
;; Portions © Copyright 2010, 2016 Erik Martin-Dorel
;; Portions © Copyright 2011-2013, 2016-2017 Hendrik Tews
;; Portions © Copyright 2015-2017 Clément Pit-Claudel
;; Author: Dave Love <fx@gnu.org>
;; Keywords: convenience
;; Version for Proof General modified by David Aspinall, 2007-8.
;; - Hooks added to insert tokenised versions of unicode characters.
;; - Added more characters to the menus.
;; - Define insertion functions following menu names (useful for keybindings)
;; This file 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, or (at your option)
;; any later version.
;; This file 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 General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;; Defines a minor mode which defines a menu bar item allowing a wide
;; range of maths/technical characters (roughly the LaTeX repertoire)
;; to be inserted into the buffer by selecting menu items.
;; Menu display only works properly under X with Gtk menus and if the
;; menu uses a font with a suitable repertoire. (Lucid and Motif
;; toolkit menus can't display multilingual text. I don't know about
;; MS Windows menus.) It will work with tmm in tty mode iff the tty
;; displays Unicode. The tmm version (via F10) is also useful under a
;; window system when the menus don't display the characters
;; correctly, but where the symbols have word syntax, tmm won't
;; provide an ASCII selector for them, which can be a pain to use
;; without a mouse.
;; See also the TeX and sgml Quail input modes. These will probably
;; behave better if you can remember the input sequences. For
;; instance, this minor mode won't give you the ability to insert into
;; the minibuffer via the menu, though presumably it could be added to
;; the minibuffer menu.
;;; Code:
(defvar maths-menu-filter-predicate (lambda (_char) t)
"Predicate function used to filter menu elements.")
(defvar maths-menu-tokenise-insert #'insert
"Function used to insert possibly formatted or escaped character.")
(defun maths-menu-build-menu (spec)
(let ((map (make-sparse-keymap "Characters")))
(dolist (pane spec)
(let* ((name (pop pane))
(pane-map (make-sparse-keymap name)))
(define-key-after map (vector (intern name)) (cons name pane-map))
(dolist (elt pane)
(let ((fname (intern
(concat "maths-menu-insert-"
(replace-regexp-in-string " " "-" (cadr elt))))))
(fset fname
(lambda ()
(interactive)
(funcall maths-menu-tokenise-insert (car elt))))
(define-key-after pane-map
(vector (intern (string (car elt)))) ; convenient unique symbol
(list 'menu-item
(format "%c (%s)" (car elt) (cadr elt))
fname
:visible `(funcall maths-menu-filter-predicate ,(car elt))))))))
map))
(defvar maths-menu-menu
(maths-menu-build-menu
'(("Logic"
(?∧ "and")
(?∨ "or")
(?∀ "for all")
(?∃ "there exists")
(?∄ "there does not exist")
(?⊤ "down tack")
(?⊥ "up tack"))
("Binops 1"
(?± "plus-minus sign")
(?∓ "minus-or-plus sign")
(?× "multiplication sign")
(?÷ "division sign")
(?− "minus sign")
(?∗ "asterisk operator")
(?⋆ "star operator")
(?○ "white circle")
(?• "bullet")
(?· "middle dot")
(?∩ "intersection")
(?∪ "union")
(?⊎ "multiset union")
(?⊓ "square cap")
(?⊔ "square cup")
(?∨ "logical or")
(?∧ "logical and")
(?∖ "set minus")
(?≀ "wreath product"))
("Binops 2"
(?⋄ "diamond operator")
(?△ "white up-pointing triangle")
(?▽ "white down-pointing triangle")
(?◃ "white left-pointing small triangle")
(?▹ "white right-pointing small triangle")
(?◁ "white left-pointing triangle")
(?▷ "white right-pointing triangle")
(?⊕ "circled plus")
(?⊖ "circled minus")
(?⊗ "circled times")
(?⊘ "circled division slash")
(?⊙ "circled dot operator")
(?◯ "large circle")
(?† "dagger")
(?‡ "double dagger")
(?⊴ "normal subgroup of or equal to")
(?⊵ "contains as normal subgroup or equal to"))
("Relations 1"
(?≤ "less-than or equal to")
(?≺ "precedes")
(?≪ "much less-than")
(?⊂ "subset of")
(?⊆ "subset of or equal to")
(?⊏ "square image of")
(?⊑ "square image of or equal to")
(?∈ "element of")
(?∉ "not an element of")
(?⊢ "right tack")
(?≥ "greater-than or equal to")
(?≻ "succeeds")
(?≽ "succeeds or equal to")
(?≫ "much greater-than")
(?⊃ "superset of")
(?⊇ "superset of or equal to")
(?⊐ "square original of")
(?⊒ "square original of or equal to")
(?∋ "contains as member")
(?≡ "identical to")
(?≢ "not identical to") )
("Relations 2"
(?⊣ "left tack")
(?∼ "tilde operator")
(?≃ "asymptotically equal to")
(?≍ "equivalent to")
(?≈ "almost equal to")
(?≅ "approximately equal to")
(?≠ "not equal to")
(?≐ "approaches the limit")
(?∝ "proportional to")
(?⊧ "models")
(?∣ "divides")
(?∥ "parallel to")
(?⋈ "bowtie")
(?⋈ "bowtie")
(?⌣ "smile")
(?⌢ "frown")
(?≙ "estimates")
(?⋿ "z notation bag membership"))
("Arrows"
(?← "leftwards arrow")
(?⇐ "leftwards double arrow")
(?→ "rightwards arrow")
(?⇒ "rightwards double arrow")
(?↔ "left right arrow")
(?⇔ "left right double arrow")
(?↦ "rightwards arrow from bar")
(?↩ "leftwards arrow with hook")
(?↼ "leftwards harpoon with barb upwards")
(?↽ "leftwards harpoon with barb downwards")
(?⇌ "rightwards harpoon over leftwards harpoon")
(?↦ "rightwards arrow from bar")
(?↪ "rightwards arrow with hook")
(?⇀ "rightwards harpoon with barb upwards")
(?⇁ "rightwards harpoon with barb downwards")
(?↝ "rightwards wave arrow")
(?↑ "upwards arrow")
(?⇑ "upwards double arrow")
(?↓ "downwards arrow")
(?⇓ "downwards double arrow")
(?↕ "up down arrow")
(?↗ "north east arrow")
(?↘ "south east arrow")
(?↙ "south west arrow")
(?↖ "north west arrow")
(?⇛ "rightwards triple arrow"))
("Long arrows"
(?⟶ "long rightwards arrow")
(?⟷ "long left right arrow")
(?⟸ "long left double arrow")
(?⟹ "long right double arrow")
(?⟺ "long left right double arrow")
(?⟻ "long left arrow from bar")
(?⟼ "long right arrow from bar")
(?⟽ "long left double arrow bar")
(?⟾ "long right double arrow from bar")
(?⟿ "long rightwards squiggle arrow"))
("Symbols 1"
(?ℵ "alef symbol") ; don't use letter alef (avoid bidi confusion)
(?ℏ "planck constant over two pi")
(?ı "latin small letter dotless i")
(?ℓ "script small l")
(?℘ "script capital p")
(?ℜ "black-letter capital r")
(?ℑ "black-letter capital i")
(?℧ "inverted ohm sign")
(?′ "prime")
(?∅ "empty set")
(?∇ "nabla")
(?√ "square root")
(?∛ "cube root")
(?∠ "angle")
(?¬ "not sign")
(?♯ "music sharp sign")
(?∂ "partial differential")
(?∞ "infinity") )
("Symbols 2"
(?□ "white square")
(?◇ "white diamond")
(?▵ "white up-pointing small triangle")
(?∑ "n-ary summation")
(?∏ "n-ary product")
(?∐ "n-ary coproduct")
(?∫ "integral")
(?∮ "contour integral")
(?⋂ "n-ary intersection")
(?⋃ "n-ary union")
(?⋁ "n-ary logical or")
(?⋀ "n-ary logical and")
(?ℕ "double-struck capital n")
(?ℙ "double-struck capital p")
(?ℚ "double-struck capital q")
(?ℝ "double-struck capital r")
(?ℤ "double-struck capital z")
(?ℐ "script capital i")
(?ƛ "latin small letter lambda with stroke")
(?∴ "therefore")
(?… "horizontal ellipsis")
(?⋯ "midline horizontal ellipsis")
(?⋮ "vertical ellipsis")
(?⋱ "down right diagonal ellipsis")
(?⋰ "up right diagonal ellipsis")
(?⦁ "z notation spot")
(?⦂ "z notation type colon"))
("Delimiters"
(?\⌊ "left floor")
(?\⌈ "left ceiling")
(?\〈 "left-pointing angle bracket")
(?\⌋ "right floor")
(?\⌉ "right ceiling")
(?\〉 "right-pointing angle bracket")
(?\〚 "left white square bracket")
(?\〛 "right white square bracket")
(?\《 "left double angle bracket")
(?\》 "right double angle bracket")
(?\⦇ "z notation left image bracket")
(?\⦈ "z notation right image bracket")
(?\⦉ "z notation left binding bracket")
(?\⦊ "z notation right binding bracket"))
("Greek LC"
(?α "alpha")
(?β "beta")
(?γ "gamma")
(?δ "delta")
(?ε "epsilon")
(?ζ "zeta")
(?η "eta")
(?θ "theta")
(?ϑ "theta symbol")
(?ι "iota")
(?κ "kappa")
(?λ "lamda")
(?μ "mu")
(?ν "nu")
(?ξ "xi")
(?π "pi")
(?ϖ "pi symbol")
(?ρ "rho")
(?ϱ "rho symbol")
(?σ "sigma")
(?ς "final sigma")
(?τ "tau")
(?υ "upsilon")
(?φ "phi")
(?ϕ "phi symbol")
(?χ "chi")
(?ψ "psi")
(?ω "omega"))
("Greek UC"
(?Γ "Gamma")
(?Δ "Delta")
(?Θ "Theta")
(?Λ "Lamda")
(?Ξ "Xi")
(?Π "Pi")
(?Σ "Sigma")
(?Υ "Upsilon")
(?Φ "Phi")
(?Ψ "Psi")
(?Ω "Omega"))
("Sub/super"
(?⁽ "superscript left parenthesis")
(?⁾ "superscript right parenthesis")
(?⁺ "superscript plus sign")
(?⁻ "superscript minus")
(?⁰ "superscript zero")
(?¹ "superscript one")
(?² "superscript two")
(?³ "superscript three")
(?⁴ "superscript four")
(?⁵ "superscript five")
(?⁶ "superscript six")
(?⁷ "superscript seven")
(?⁸ "superscript eight")
(?⁹ "superscript nine")
(?₍ "subscript left parenthesis")
(?₎ "subscript right parenthesis")
(?₊ "subscript plus sign")
(?₋ "subscript minus")
(?₀ "subscript zero")
(?₁ "subscript one")
(?₂ "subscript two")
(?₃ "subscript three")
(?₄ "subscript four")
(?₅ "subscript five")
(?₆ "subscript six")
(?₇ "subscript seven")
(?₈ "subscript eight")
(?₉ "subscript nine")))))
(defvar maths-menu-mode-map
(let ((map (make-sparse-keymap)))
(define-key map [menu-bar maths]
`(menu-item "Maths" ,maths-menu-menu
:help "Menu of maths characters to insert"))
map))
;;;###autoload
(define-minor-mode maths-menu-mode
"Install a menu for entering mathematical characters.
Uses window system menus only when they can display multilingual text.
Otherwise the menu-bar item activates the text-mode menu system.
This mode is only useful with a font which can display the maths repertoire."
:lighter nil)
(provide 'maths-menu)
;;; maths-menu.el ends here
|