122 |
;; info.el (Copyright (C) 1985, 86, 92, 93, 94, 95, 96, 97, 98, 99, |
;; info.el (Copyright (C) 1985, 86, 92, 93, 94, 95, 96, 97, 98, 99, |
123 |
;; 2000, 2001 Free Software Foundation, Inc.) and adapted to the needs |
;; 2000, 2001 Free Software Foundation, Inc.) and adapted to the needs |
124 |
;; of font-latex.el. |
;; of font-latex.el. |
|
(defun font-latex-make-title-faces () |
|
|
"Build the faces used to fontify sectioning commands." |
|
|
(dotimes (i 3) |
|
|
(let* ((num (1+ i)) |
|
|
(face-name (intern (concat "font-latex-title-" (number-to-string num) |
|
|
"-face")))) |
|
|
(if (featurep 'xemacs) |
|
|
(let ((size (concat |
|
|
(number-to-string |
|
|
;; Multiply with .9 because `face-height' returns a |
|
|
;; value slightly larger than the actual font size. |
|
|
(round (* .9 (face-height 'default) |
|
|
(expt 1.2 (- 3 i))))) |
|
|
"pt"))) |
|
|
(eval `(defface ,face-name |
|
|
'((((type tty pc) (class color) (background light)) |
|
|
(:foreground "blue4" :bold t)) |
|
|
(((type tty pc) (class color) (background dark)) |
|
|
(:foreground "yellow" :bold t)) |
|
|
(((class color) (background light)) |
|
|
(:bold t :foreground "blue4" :family "helvetica" |
|
|
:size ,size)) |
|
|
(((class color) (background dark)) |
|
|
(:bold t :foreground "yellow" :family "helvetica" |
|
|
:size ,size)) |
|
|
(t (:size ,size :family "helvetica"))) |
|
|
,(concat "Face for LaTeX titles at level " |
|
|
(number-to-string num) ".") |
|
|
:group 'font-latex-highlighting-faces))) |
|
|
(eval `(defface ,face-name |
|
|
'((t (:height 1.2 :inherit ,(intern |
|
|
(concat |
|
|
"font-latex-title-" |
|
|
(number-to-string (1+ num)) |
|
|
"-face"))))) |
|
|
,(concat "Face for LaTeX titles at level " |
|
|
(number-to-string num) ".") |
|
|
:group 'font-latex-highlighting-faces)))))) |
|
|
(font-latex-make-title-faces) |
|
125 |
|
|
126 |
(defface font-latex-title-4-face |
(defconst font-latex-title-max 5 |
127 |
|
"Highest number for font-latex-title-N-face") |
128 |
|
(defface font-latex-title-5-face |
129 |
(if (featurep 'xemacs) |
(if (featurep 'xemacs) |
130 |
'((((type tty pc) (class color) (background light)) |
'((((type tty pc) (class color) (background light)) |
131 |
(:foreground "blue4" :bold t)) |
(:foreground "blue4" :bold t)) |
145 |
(((class color) (background dark)) |
(((class color) (background dark)) |
146 |
(:weight bold :inherit variable-pitch :foreground "yellow")) |
(:weight bold :inherit variable-pitch :foreground "yellow")) |
147 |
(t (:weight bold :inherit variable-pitch)))) |
(t (:weight bold :inherit variable-pitch)))) |
148 |
"Face for LaTeX titles at level 4." |
"Face for LaTeX titles at level 5." |
149 |
:group 'font-latex-highlighting-faces) |
:group 'font-latex-highlighting-faces) |
150 |
|
|
151 |
(defcustom font-latex-title-fontify 'height |
(defun font-latex-update-title-faces (&optional max height-scale) |
152 |
"Whether to fontify LaTeX titles with varying height faces or a color face." |
"Update sectioning commands faces." |
153 |
:type '(choice (const height) |
(unless height-scale |
154 |
|
(setq height-scale (if (numberp font-latex-title-fontify) |
155 |
|
font-latex-title-fontify |
156 |
|
1.1))) |
157 |
|
(unless max |
158 |
|
(setq max font-latex-title-max)) |
159 |
|
(dotimes (num max) |
160 |
|
(let* (;; reverse for XEmacs: |
161 |
|
(num (- max (1+ num))) |
162 |
|
(face-name (intern (format "font-latex-title-%s-face" num))) |
163 |
|
(f-inherit (intern (format "font-latex-title-%s-face" (1+ num))))) |
164 |
|
(if (featurep 'xemacs) |
165 |
|
(let ((size |
166 |
|
;; Multiply with .9 because `face-height' returns a value |
167 |
|
;; slightly larger than the actual font size. |
168 |
|
;; `make-face-size' takes numeric points according to Aidan |
169 |
|
;; Kehoe in <16989.15536.613916.678965@parhasard.net> (not |
170 |
|
;; documented). |
171 |
|
(round (* 0.9 |
172 |
|
(face-height 'default) |
173 |
|
(expt height-scale (- max 1 num)))))) |
174 |
|
;; (message "%s - %s" face-name size) |
175 |
|
(make-face-size face-name size)) |
176 |
|
(set-face-attribute face-name nil :height height-scale))))) |
177 |
|
|
178 |
|
(defcustom font-latex-title-fontify 1.1 ;; (if (featurep 'xemacs) 'color 1.1) |
179 |
|
"Whether to fontify LaTeX titles with varying height faces or a color face. |
180 |
|
|
181 |
|
If it is a number, use varying height faces. The number is used |
182 |
|
for scaling starting from `font-latex-title-5-face'. Typically |
183 |
|
value from 1.05 to 1.3 give best result, depending on your font |
184 |
|
setup. |
185 |
|
|
186 |
|
If it is `color', use `font-lock-type-face'. |
187 |
|
|
188 |
|
Switching from `color' to a number or vice versa does not take |
189 |
|
effect unless you call \\[font-lock-fontify-buffer] or restart |
190 |
|
Emacs." |
191 |
|
;; Possibly add some word about XEmacs here. :-( |
192 |
|
:type '(choice (number :tag "Scale factor") |
193 |
(const color)) |
(const color)) |
194 |
|
:initialize (lambda (symbol value) |
195 |
|
(set-default symbol (eval value))) |
196 |
|
:set (lambda (symbol value) |
197 |
|
(set-default symbol value) |
198 |
|
(unless (eq value 'color) |
199 |
|
(font-latex-update-title-faces font-latex-title-max value))) |
200 |
:group 'font-latex) |
:group 'font-latex) |
201 |
|
|
202 |
|
(defun font-latex-make-title-faces (max) |
203 |
|
"Build the faces used to fontify sectioning commands." |
204 |
|
(unless max (setq max font-latex-title-max)) |
205 |
|
(dotimes (num max) |
206 |
|
(let* (;; reverse for XEmacs: |
207 |
|
(num (- max (1+ num))) |
208 |
|
(face-name (intern (format "font-latex-title-%s-face" num))) |
209 |
|
(f-inherit (intern (format "font-latex-title-%s-face" (1+ num)))) |
210 |
|
face-exists) |
211 |
|
;; If the use has customized this face (i.e. it already exists), we must |
212 |
|
;; not set the parent/inherit property. |
213 |
|
(setq face-exists (if (featurep 'xemacs) |
214 |
|
(find-face face-name) |
215 |
|
(facep face-name))) |
216 |
|
(eval |
217 |
|
`(defface ,face-name |
218 |
|
nil ;; Set by `font-latex-update-title-faces' when needed. |
219 |
|
(format "Face for LaTeX titles at level %s. |
220 |
|
|
221 |
|
Probably you don't want to customize this face directly. Better |
222 |
|
change the base face `font-latex-title-5-face' or customize the |
223 |
|
variable `font-latex-title-fontify'." num) |
224 |
|
:group 'font-latex-highlighting-faces)) |
225 |
|
(if face-exists |
226 |
|
(message "face:%s already exists, skipping parent" face-name) |
227 |
|
;; (message "face:%s, inherit/parent:%s" face-name f-inherit) |
228 |
|
(if (fboundp 'set-face-parent) |
229 |
|
(set-face-parent face-name f-inherit) |
230 |
|
(set-face-attribute face-name nil :inherit f-inherit)))))) |
231 |
|
|
232 |
|
(font-latex-make-title-faces font-latex-title-max) |
233 |
|
(font-latex-update-title-faces font-latex-title-max) |
234 |
|
|
235 |
;;; Keywords |
;;; Keywords |
236 |
|
|
266 |
"negthinspace" "enspace" "enskip" "quad" "qquad" "nonumber" |
"negthinspace" "enspace" "enskip" "quad" "qquad" "nonumber" |
267 |
"centering" "TeX" "LaTeX") |
"centering" "TeX" "LaTeX") |
268 |
font-lock-function-name-face 2 (command 1 t)) |
font-lock-function-name-face 2 (command 1 t)) |
269 |
|
("title-0" |
270 |
|
("part") |
271 |
|
font-latex-title-0-face 2 (title 1 t)) |
272 |
("title-1" |
("title-1" |
273 |
("part" "chapter") |
("chapter") |
274 |
font-latex-title-1-face 2 (title 1 t)) |
font-latex-title-1-face 2 (title 1 t)) |
275 |
("title-2" |
("title-2" |
276 |
("section") |
("section") |
279 |
("subsection") |
("subsection") |
280 |
font-latex-title-3-face 2 (title 1 t)) |
font-latex-title-3-face 2 (title 1 t)) |
281 |
("title-4" |
("title-4" |
282 |
("subsubsection" "paragraph" "subparagraph" "subsubparagraph") |
("subsubsection") |
283 |
font-latex-title-4-face 2 (title 1 t)) |
font-latex-title-4-face 2 (title 1 t)) |
284 |
|
("title-5" |
285 |
|
("paragraph" "subparagraph" "subsubparagraph") |
286 |
|
font-latex-title-5-face 2 (title 1 t)) |
287 |
("textual" |
("textual" |
288 |
("item" "title" "author" "date" "thanks" "address" "caption" |
("item" "title" "author" "date" "thanks" "address" "caption" |
289 |
"textsuperscript") |
"textsuperscript") |
395 |
`(,(intern (concat prefix name)) |
`(,(intern (concat prefix name)) |
396 |
(0 'font-lock-keyword-face append t) |
(0 'font-lock-keyword-face append t) |
397 |
(1 'font-lock-variable-name-face append t) |
(1 'font-lock-variable-name-face append t) |
398 |
(2 (if (eq font-latex-title-fontify 'height) |
(2 (if (eq font-latex-title-fontify 'color) |
399 |
',face |
'font-lock-type-face |
400 |
'font-lock-type-face) |
',face) |
401 |
append t))) |
append t))) |
402 |
((eq type 'noarg) |
((eq type 'noarg) |
403 |
`(,(intern (concat prefix name)) |
`(,(intern (concat prefix name)) |
406 |
`(,(intern (concat prefix name)) |
`(,(intern (concat prefix name)) |
407 |
(0 'font-lock-keyword-face append t) |
(0 'font-lock-keyword-face append t) |
408 |
(1 ',face append t))))) |
(1 ',face append t))))) |
409 |
|
|
410 |
(defun font-latex-make-built-in-keywords () |
(defun font-latex-make-built-in-keywords () |
411 |
"Build defuns, defvars and defcustoms for built-in keyword fontification." |
"Build defuns, defvars and defcustoms for built-in keyword fontification." |
412 |
(let ((keyword-specs font-latex-built-in-keyword-classes)) |
(let ((keyword-specs font-latex-built-in-keyword-classes)) |