File: latex-math-symbol.el

package info (click to toggle)
mu-cite 8.1%2B0.20120227-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 188 kB
  • ctags: 69
  • sloc: lisp: 766; sh: 162; makefile: 87
file content (183 lines) | stat: -rw-r--r-- 6,140 bytes parent folder | download | duplicates (8)
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
;;; latex-math-symbol.el --- LaTeX math symbol decoder

;; Copyright (C) 1996,1997 MORIOKA Tomohiko

;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
;; Created: 1996/7/1
;; Version:
;;    $Id: latex-math-symbol.el,v 1.3 1997/01/14 11:30:27 morioka Exp morioka $
;; Keywords: LaTeX, math, mule

;; This file is part of MU (Message Utilities).

;; This program 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 2, or (at
;; your option) any later version.

;; This program 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., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.

;;; Commentary:

;; - How to install
;;	bytecompile this file and copy it to the apropriate directory.
;; - How to use
;;	If you use tm, please put following to your ~/.emacs:
;;	  (autoload 'latex-math-decode-buffer "latex-math-symbol" nil t)
;;	  (add-hook 'mime-viewer/plain-text-preview-hook
;;		    'latex-math-decode-buffer)
;;   Of course, it may be available for other hooks to filter messages.

;;; Code:

(defvar latex-math-symbol-table-alist
  '(("\\alpha"		. ",Fa(B")
    ("\\beta"		. ",Fb(B")
    ("\\gamma"		. ",Fc(B")("\\Gamma"	. "$B&#(B")
    ("\\delta"		. ",Fd(B")("\\Delta"	. "$B&$(B")
    ("\\epsilon"	. ",Fe(B")("\\varepsilon"	. "$B&E(B")
    ("\\zeta"		. ",Ff(B")
    ("\\eta"		. ",Fg(B")
    ("\\theta"		. ",Fh(B")("\\Theta"	. "$B&((B")
    ("\\iota"		. ",Fi(B")
    ("\\kappa"		. ",Fj(B")
    ("\\lambda"		. ",Fk(B")("\\Lambda"	. "$B&+(B")
    ("\\mu"		. ",Fl(B")
    ("\\nu"		. ",Fm(B")
    ("\\xi"		. ",Fn(B")("\\Xi"		. "$B&.(B")
    ("\\pi"		. ",Fp(B")("\\Pi"		. "$B&0(B")
    ("\\rho"		. ",Fq(B")
    ("\\sigma"		. ",Fs(B")("\\Sigma"	. "$B&2(B")
    ("\\varsigma"	. ",Fr(B")
    ("\\tau"		. ",Ft(B")
    ("\\upsilon"	. ",Fu(B")("\\Upsilon"	. "$B&4(B")
    ("\\phi"		. "$B&U(B")("\\Phi"		. "$B&5(B")
    ("\\varphi"		. ",Fv(B")
    ("\\chi"		. ",Fw(B")
    ("\\psi"		. ",Fx(B")("\\Psi"		. "$B&7(B")
    ("\\omega"		. ",Fy(B")("\\Omega"	. "$B&8(B")
    
    ("\\{"		. "$B!P(B")("\\}"		. "$B!Q(B")
    ("\\langle\\!\\langle" . "$B!T(B")("\\rangle\\!\\rangle" . "$B!U(B")
    ("\\langle"		. "$B!R(B")("\\rangle"	. "$B!S(B")
    
    ("\\cdots"		. "$B!D(B")
    
    ("\\ln"		. "$(G"L(B")
    ("\\log"		. "$(G"K(B")
    
    ("\\pm"		. "$B!^(B")
    ("\\cdot"		. "$B!&(B")
    ("\\times"		. "$B!_(B")("\\ast"		. "$B!v(B")
    ("\\star"		. "$B!z(B")
    ("\\bullet"		. "$B!&(B")
    ("\\div"		. "$B!`(B")
    ("\\cap"		. "$B"A(B")("\\cup"		. "$B"@(B")
    ("\\lhd"		. "$(C"7(B")("\\rhd"		. "$(C"9(B")
    ("\\bigcirc"	. "$B"~(B")
    ("\\vee"		. "$B"K(B")("\\lor"		. "$B"K(B")
    ("\\wedge"		. "$B"J(B")("\\land"	. "$B"J(B")
    ("\\oplus"		. "$(G"S(B")
    ("\\odot"		. "$(G"T(B")
    ("\\dagger"		. "$B"w(B")("\\ddagger"	. "$B"x(B")
    
    ("\\leq"		. "$(C!B(B")("\\geq"		. "$(C!C(B")
    ("\\le"		. "$(C!B(B")("\\ge"		. "$(C!C(B")
    ("\\ll"		. "$B"c(B")("\\gg"		. "$B"d(B")
    ("\\subseteq"	. "$B"<(B")("\\supseteq"	. "$B"=(B")
    ("\\subset"		. "$B">(B")("\\supset"	. "$B"?(B")
    ("\\in"		. "$B":(B")
    ("\\ni"		. "$B";(B")("\\owns"	. "$B";(B")
    ("\\frown"		. "$B"^(B")
    ("\\mid"		. "$B!C(B")("\\parallel"	. "$B!B(B")
    ("\\sim"		. "$B!A(B")
    ("\\equiv"		. "$B"a(B")
    ("\\approx"		. "$A!V(B")
    ("\\not="		. "$B!b(B")
    ("\\neq"		. "$B!b(B")("\\ne"		. "$B!b(B")
    ("\\perp"		. "$B"](B")
    
    ("\\triangleup"	. "$B"$(B")
    ("\\forall"		. "$B"O(B")
    
    ("\\hbar"		. ",C1(B")("\\imath"	. ",C9(B")
    ("\\ell"		. "$(C'$(B")
    ("\\partial"	. "$B"_(B")
    ("\\infty"		. "$B!g(B")
    ("\\smallint"	. "$B"i(B")
    ("\\P"		. "$B"y(B")
    ("\\prime"		. "$B!l(B")
    ("\\nabla"		. "$B"`(B")
    ("\\top"		. "$(D0#(B")("\\bot"		. "$(D0"(B")
    ("\\vert"		. "$B!C(B")("\\Vert"	. "$B!B(B")
    ("\\angle"		. "$B"\(B")
    ("\\triangle"	. "$B"$(B")
    ("\\backslash"	. "$B!@(B")
    ("\\S"		. "$B!x(B")
    ("\\forall"		. "$B"O(B")
    ("\\exists"		. "$B"P(B")
    ("\\neg"		. "$B"L(B")("\\lnot"	. "$B"L(B")
    ("\\flat"		. "$B"u(B")("\\sharp"	. "$B"t(B")
    ("\\clubsuit"	. "$(C"@(B")
    ("\\diamondsuit"	. "$B!~(B")
    ("\\heartsuit"	. "$(C"=(B")
    ("\\spadesuit"	. "$(C"<(B")
    
    ("\\leftarrow"	. "$B"+(B")("\\rightarrow"	. "$B"*(B")
    ("\\gets"		. "$B"+(B")("\\to"		. "$B"*(B")
    
    ("^1"		. ",A9(B")("^{1}"		. ",A9(B")
    ("^2"		. ",A2(B")("^{2}"		. ",A2(B")
    ("^3"		. ",A3(B")("^{3}"		. ",A3(B")
    ("^4"		. "$(C)y(B")("^{4}"		. "$(C)y(B")
    ("^n"		. "$(C)z(B")("^{n}"		. "$(C)z(B")
    ("_1"		. "$(C){(B")("_{1}"		. "$(C){(B")
    ("_2"		. "$(C)|(B")("_{2}"		. "$(C)|(B")
    ("_3"		. "$(C)}(B")("_{3}"		. "$(C)}(B")
    ("_4"		. "$(C)~(B")("_{4}"		. "$(C)~(B")
    ))

;;;###autoload
(defun latex-math-decode-region (beg end)
  (interactive "r")
  (save-restriction
    (narrow-to-region beg end)
    (let ((rest latex-math-symbol-table-alist)
	  (case-fold-search nil)
	  cell)
      (while rest
	(setq cell (car rest))
	(goto-char beg)
	(while (re-search-forward
		(concat "\\("
			(regexp-quote (car cell))
			"\\)\\([^a-zA-Z]\\|$\\)")
		nil t)
	  (delete-region (match-beginning 1)(match-end 1))
	  (goto-char (match-beginning 0))
	  (insert (cdr cell))
	  )
	(setq rest (cdr rest))
	))))

;;;###autoload
(defun latex-math-decode-buffer ()
  (interactive)
  (latex-math-decode-region (point-min)(point-max))
  )


;;; @ end
;;;

(provide 'latex-math-symbol)

;;; latex-math-symbol.el ends here