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. |
125 |
|
|
126 |
(defconst font-latex-title-max 5 |
(defconst font-latex-sectioning-max 5 |
127 |
"Highest number for font-latex-title-N-face") |
"Highest number for font-latex-sectioning-N-face") |
128 |
(defface font-latex-title-5-face |
(defface font-latex-sectioning-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 5." |
"Face for sectioning commands at level 5." |
149 |
:group 'font-latex-highlighting-faces) |
:group 'font-latex-highlighting-faces) |
150 |
|
|
151 |
(defun font-latex-update-title-faces (&optional max height-scale) |
(defun font-latex-update-sectioning-faces (&optional max height-scale) |
152 |
"Update sectioning commands faces." |
"Update sectioning commands faces." |
153 |
(unless height-scale |
(unless height-scale |
154 |
(setq height-scale (if (numberp font-latex-title-fontify) |
(setq height-scale (if (numberp font-latex-fontify-sectioning) |
155 |
font-latex-title-fontify |
font-latex-fontify-sectioning |
156 |
1.1))) |
1.1))) |
157 |
(unless max |
(unless max |
158 |
(setq max font-latex-title-max)) |
(setq max font-latex-sectioning-max)) |
159 |
(dotimes (num max) |
(dotimes (num max) |
160 |
(let* (;; reverse for XEmacs: |
(let* (;; reverse for XEmacs: |
161 |
(num (- max (1+ num))) |
(num (- max (1+ num))) |
162 |
(face-name (intern (format "font-latex-title-%s-face" num)))) |
(face-name (intern (format "font-latex-sectioning-%s-face" num)))) |
163 |
(unless (get face-name 'saved-face) ; Do not touch customized faces. |
(unless (get face-name 'saved-face) ; Do not touch customized faces. |
164 |
(if (featurep 'xemacs) |
(if (featurep 'xemacs) |
165 |
(let ((size |
(let ((size |
175 |
(make-face-size face-name size)) |
(make-face-size face-name size)) |
176 |
(set-face-attribute face-name nil :height height-scale)))))) |
(set-face-attribute face-name nil :height height-scale)))))) |
177 |
|
|
178 |
(defcustom font-latex-title-fontify 1.1 |
(defcustom font-latex-fontify-sectioning 1.1 |
179 |
"Whether to fontify LaTeX titles with varying height faces or a color face. |
"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 |
If it is a number, use varying height faces. The number is used |
182 |
for scaling starting from `font-latex-title-5-face'. Typically |
for scaling starting from `font-latex-sectioning-5-face'. Typically |
183 |
value from 1.05 to 1.3 give best result, depending on your font |
value from 1.05 to 1.3 give best result, depending on your font |
184 |
setup. If it is `color', use `font-lock-type-face'. |
setup. If it is `color', use `font-lock-type-face'. |
185 |
|
|
186 |
Caveats: Customizing the scaling factor applies to all sectioning |
Caveats: Customizing the scaling factor applies to all sectioning |
187 |
faces unless those face have been saved by customize. Setting |
faces unless those face have been saved by customize. Setting |
188 |
this variable directly does not take effect; unless you call |
this variable directly does not take effect; unless you call |
189 |
`font-latex-update-title-faces' or restart Emacs. |
`font-latex-update-sectioning-faces' or restart Emacs. |
190 |
|
|
191 |
Switching from `color' to a number or vice versa does not take |
Switching from `color' to a number or vice versa does not take |
192 |
effect unless you call \\[font-lock-fontify-buffer] or restart |
effect unless you call \\[font-lock-fontify-buffer] or restart |
198 |
:set (lambda (symbol value) |
:set (lambda (symbol value) |
199 |
(set-default symbol value) |
(set-default symbol value) |
200 |
(unless (eq value 'color) |
(unless (eq value 'color) |
201 |
(font-latex-update-title-faces font-latex-title-max value))) |
(font-latex-update-sectioning-faces font-latex-sectioning-max value))) |
202 |
:group 'font-latex) |
:group 'font-latex) |
203 |
|
|
204 |
(defun font-latex-make-title-faces (max &optional height-scale) |
(defun font-latex-make-sectioning-faces (max &optional height-scale) |
205 |
"Build the faces used to fontify sectioning commands." |
"Build the faces used to fontify sectioning commands." |
206 |
(unless max (setq max font-latex-title-max)) |
(unless max (setq max font-latex-sectioning-max)) |
207 |
(unless height-scale |
(unless height-scale |
208 |
(setq height-scale (if (numberp font-latex-title-fontify) |
(setq height-scale (if (numberp font-latex-fontify-sectioning) |
209 |
font-latex-title-fontify |
font-latex-fontify-sectioning |
210 |
1.1))) |
1.1))) |
211 |
(dotimes (num max) |
(dotimes (num max) |
212 |
(let* (;; reverse for XEmacs: |
(let* (;; reverse for XEmacs: |
213 |
(num (- max (1+ num))) |
(num (- max (1+ num))) |
214 |
(face-name (intern (format "font-latex-title-%s-face" num))) |
(face-name (intern (format "font-latex-sectioning-%s-face" num))) |
215 |
(f-inherit (intern (format "font-latex-title-%s-face" (1+ num)))) |
(f-inherit (intern (format "font-latex-sectioning-%s-face" (1+ num)))) |
216 |
(size (when (featurep 'xemacs) |
(size (when (featurep 'xemacs) |
217 |
(round (* 0.9 (face-height 'default) |
(round (* 0.9 (face-height 'default) |
218 |
(expt height-scale (- max 1 num))))))) |
(expt height-scale (- max 1 num))))))) |
224 |
(format "Face for sectioning commands at level %s. |
(format "Face for sectioning commands at level %s. |
225 |
|
|
226 |
Probably you don't want to customize this face directly. Better |
Probably you don't want to customize this face directly. Better |
227 |
change the base face `font-latex-title-5-face' or customize the |
change the base face `font-latex-sectioning-5-face' or customize the |
228 |
variable `font-latex-title-fontify'." num) |
variable `font-latex-fontify-sectioning'." num) |
229 |
:group 'font-latex-highlighting-faces)) |
:group 'font-latex-highlighting-faces)) |
230 |
(when (and (featurep 'xemacs) |
(when (and (featurep 'xemacs) |
231 |
;; Do not touch customized faces. |
;; Do not touch customized faces. |
232 |
(not (get face-name 'saved-face))) |
(not (get face-name 'saved-face))) |
233 |
(set-face-parent face-name f-inherit))))) |
(set-face-parent face-name f-inherit))))) |
234 |
|
|
235 |
(font-latex-make-title-faces font-latex-title-max) |
(font-latex-make-sectioning-faces font-latex-sectioning-max) |
236 |
|
|
237 |
|
;; These aliases should be removed after the next release: |
238 |
|
;; Provide face aliases for version 11.50-11.55: |
239 |
|
(dolist (num '(1 2 3 4)) |
240 |
|
(let ((old (intern (format "font-latex-title-%s-face" num))) |
241 |
|
(new (intern (format "font-latex-sectioning-%s-face" num)))) |
242 |
|
;; Does this work at all? |
243 |
|
(when t; (get old 'saved-face) |
244 |
|
(put old 'face-alias new)))) |
245 |
|
;; Provide alias for version 11.55: |
246 |
|
(condition-case nil |
247 |
|
(make-obsolete-variable 'font-latex-title-fontify |
248 |
|
'font-latex-fontify-sectioning |
249 |
|
"AUCTeX 11.80") |
250 |
|
(wrong-number-of-arguments 'font-latex-title-fontify |
251 |
|
'font-latex-fontify-sectioning)) |
252 |
|
;; Should we provide an alias for version 11.50-11.54? |
253 |
|
;; (make-obsolete-variable 'font-latex-title-fontity |
254 |
|
;; 'font-latex-title-fontify "AUCTEX 11.55") |
255 |
|
|
256 |
;;; Keywords |
;;; Keywords |
257 |
|
|
289 |
font-lock-function-name-face 2 (command 1 t)) |
font-lock-function-name-face 2 (command 1 t)) |
290 |
("title-0" |
("title-0" |
291 |
("part") |
("part") |
292 |
font-latex-title-0-face 2 (title 1 t)) |
font-latex-sectioning-0-face 2 (title 1 t)) |
293 |
("title-1" |
("title-1" |
294 |
("chapter") |
("chapter") |
295 |
font-latex-title-1-face 2 (title 1 t)) |
font-latex-sectioning-1-face 2 (title 1 t)) |
296 |
("title-2" |
("title-2" |
297 |
("section") |
("section") |
298 |
font-latex-title-2-face 2 (title 1 t)) |
font-latex-sectioning-2-face 2 (title 1 t)) |
299 |
("title-3" |
("title-3" |
300 |
("subsection") |
("subsection") |
301 |
font-latex-title-3-face 2 (title 1 t)) |
font-latex-sectioning-3-face 2 (title 1 t)) |
302 |
("title-4" |
("title-4" |
303 |
("subsubsection") |
("subsubsection") |
304 |
font-latex-title-4-face 2 (title 1 t)) |
font-latex-sectioning-4-face 2 (title 1 t)) |
305 |
("title-5" |
("title-5" |
306 |
("paragraph" "subparagraph" "subsubparagraph") |
("paragraph" "subparagraph" "subsubparagraph") |
307 |
font-latex-title-5-face 2 (title 1 t)) |
font-latex-sectioning-5-face 2 (title 1 t)) |
308 |
("textual" |
("textual" |
309 |
("item" "title" "author" "date" "thanks" "address" "caption" |
("item" "title" "author" "date" "thanks" "address" "caption" |
310 |
"textsuperscript") |
"textsuperscript") |
357 |
macros of the form \"\\foo[bar]{baz}\", or a list of the form |
macros of the form \"\\foo[bar]{baz}\", or a list of the form |
358 |
`(title <num>)' which is basically the same as the `(comman <num>)' |
`(title <num>)' which is basically the same as the `(comman <num>)' |
359 |
list but puts conditional into the keyword highlighter which |
list but puts conditional into the keyword highlighter which |
360 |
tests for `font-latex-title-fontify'.") |
tests for `font-latex-fontify-sectioning'.") |
361 |
|
|
362 |
(defun font-latex-make-match-defun (prefix name type) |
(defun font-latex-make-match-defun (prefix name type) |
363 |
"Return a function definition for keyword matching. |
"Return a function definition for keyword matching. |
416 |
`(,(intern (concat prefix name)) |
`(,(intern (concat prefix name)) |
417 |
(0 'font-lock-keyword-face append t) |
(0 'font-lock-keyword-face append t) |
418 |
(1 'font-lock-variable-name-face append t) |
(1 'font-lock-variable-name-face append t) |
419 |
(2 (if (eq font-latex-title-fontify 'color) |
(2 (if (eq font-latex-fontify-sectioning 'color) |
420 |
'font-lock-type-face |
'font-lock-type-face |
421 |
',face) |
',face) |
422 |
append t))) |
append t))) |