[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[AUCTeX-devel] Re: Fontifying of titles...
From: |
Reiner Steib |
Subject: |
[AUCTeX-devel] Re: Fontifying of titles... |
Date: |
Thu, 21 Apr 2005 20:01:29 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
On Sun, Apr 10 2005, Ralf Angeli wrote:
> * Reiner Steib (2005-04-09) writes:
>> At least the customizable factor (`font-latex-title-fontify') should
>> work.
>
> Yes, but the inheritance should work as well if we want to suggest
> customizing only the "base face".
I think we finally have a version that works sufficiently with Emacs
and XEmacs.
2005-04-21 Reiner Steib <address@hidden>
* font-latex.el (font-latex-make-title-faces): Define the face,
don't set size. Set parent/inherit conditionally.
(font-latex-update-title-faces): New function.
(font-latex-title-fontify): Add :initialize and :set. Using
`font-latex-update-title-faces' allows changing the height within
an Emacs session.
(font-latex-title-5-face): Renamed from title-4-face.
(font-latex-built-in-keyword-classes): Use title-0 and title-5
faces.
Compared to the current code in CVS, I have added title-0 for part and
title-5 ("paragraph" "subparagraph" "subsubparagraph"). It is now
possible to customize the scaling factor for the fonts and changes
done via customize to the factor are applied immediately (using :set
in defcustom). I also did some clean-up (using `format' instead of
`concat') and changed the order of variables and functions (was needed
for the :set stuff, IIRC).
Unless there is strong objection soon, I'll check in the attached
patch. Please let us adjust details and minor corrections (e.g. don't
use title-5 but use title-4 for \subsubsection and \*paragraph; other
default values instead of 1.1) after the patch is in CVS.
If the font height in XEmacs doesn't work on typical end-user systems,
we may change the default of font-latex-title-fontify to (if (featurep
'xemacs) 'color 1.1).
>> Changing the count in `dotimes' isn't really adding complexity to the
>> code in my book. :-)
>
> That's why I put it into perspective in the next sentence. (c:
I couldn't resist. ;-)
Bye, Reiner.
[1] http://thread.gmane.org/address@hidden
--- font-latex.el 13 Apr 2005 15:48:30 +0200 5.105
+++ font-latex.el 21 Apr 2005 19:52:29 +0200
@@ -122,47 +122,10 @@
;; info.el (Copyright (C) 1985, 86, 92, 93, 94, 95, 96, 97, 98, 99,
;; 2000, 2001 Free Software Foundation, Inc.) and adapted to the needs
;; 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)
-(defface font-latex-title-4-face
+(defconst font-latex-title-max 5
+ "Highest number for font-latex-title-N-face")
+(defface font-latex-title-5-face
(if (featurep 'xemacs)
'((((type tty pc) (class color) (background light))
(:foreground "blue4" :bold t))
@@ -182,15 +145,92 @@
(((class color) (background dark))
(:weight bold :inherit variable-pitch :foreground "yellow"))
(t (:weight bold :inherit variable-pitch))))
- "Face for LaTeX titles at level 4."
+ "Face for LaTeX titles at level 5."
:group 'font-latex-highlighting-faces)
-(defcustom font-latex-title-fontify 'height
- "Whether to fontify LaTeX titles with varying height faces or a color face."
- :type '(choice (const height)
+(defun font-latex-update-title-faces (&optional max height-scale)
+ "Update sectioning commands faces."
+ (unless height-scale
+ (setq height-scale (if (numberp font-latex-title-fontify)
+ font-latex-title-fontify
+ 1.1)))
+ (unless max
+ (setq max font-latex-title-max))
+ (dotimes (num max)
+ (let* (;; reverse for XEmacs:
+ (num (- max (1+ num)))
+ (face-name (intern (format "font-latex-title-%s-face" num)))
+ (f-inherit (intern (format "font-latex-title-%s-face" (1+ num)))))
+ (if (featurep 'xemacs)
+ (let ((size
+ ;; Multiply with .9 because `face-height' returns a value
+ ;; slightly larger than the actual font size.
+ ;; `make-face-size' takes numeric points according to Aidan
+ ;; Kehoe in <address@hidden> (not
+ ;; documented).
+ (round (* 0.9
+ (face-height 'default)
+ (expt height-scale (- max 1 num))))))
+ ;; (message "%s - %s" face-name size)
+ (make-face-size face-name size))
+ (set-face-attribute face-name nil :height height-scale)))))
+
+(defcustom font-latex-title-fontify 1.1 ;; (if (featurep 'xemacs) 'color 1.1)
+ "Whether to fontify LaTeX titles with varying height faces or a color face.
+
+If it is a number, use varying height faces. The number is used
+for scaling starting from `font-latex-title-5-face'. Typically
+value from 1.05 to 1.3 give best result, depending on your font
+setup.
+
+If it is `color', use `font-lock-type-face'.
+
+Switching from `color' to a number or vice versa does not take
+effect unless you call \\[font-lock-fontify-buffer] or restart
+Emacs."
+ ;; Possibly add some word about XEmacs here. :-(
+ :type '(choice (number :tag "Scale factor")
(const color))
+ :initialize (lambda (symbol value)
+ (set-default symbol (eval value)))
+ :set (lambda (symbol value)
+ (set-default symbol value)
+ (unless (eq value 'color)
+ (font-latex-update-title-faces font-latex-title-max value)))
:group 'font-latex)
+(defun font-latex-make-title-faces (max)
+ "Build the faces used to fontify sectioning commands."
+ (unless max (setq max font-latex-title-max))
+ (dotimes (num max)
+ (let* (;; reverse for XEmacs:
+ (num (- max (1+ num)))
+ (face-name (intern (format "font-latex-title-%s-face" num)))
+ (f-inherit (intern (format "font-latex-title-%s-face" (1+ num))))
+ face-exists)
+ ;; If the use has customized this face (i.e. it already exists), we must
+ ;; not set the parent/inherit property.
+ (setq face-exists (if (featurep 'xemacs)
+ (find-face face-name)
+ (facep face-name)))
+ (eval
+ `(defface ,face-name
+ nil ;; Set by `font-latex-update-title-faces' when needed.
+ (format "Face for LaTeX titles at level %s.
+
+Probably you don't want to customize this face directly. Better
+change the base face `font-latex-title-5-face' or customize the
+variable `font-latex-title-fontify'." num)
+ :group 'font-latex-highlighting-faces))
+ (if face-exists
+ (message "face:%s already exists, skipping parent" face-name)
+ ;; (message "face:%s, inherit/parent:%s" face-name f-inherit)
+ (if (fboundp 'set-face-parent)
+ (set-face-parent face-name f-inherit)
+ (set-face-attribute face-name nil :inherit f-inherit))))))
+
+(font-latex-make-title-faces font-latex-title-max)
+(font-latex-update-title-faces font-latex-title-max)
;;; Keywords
@@ -226,8 +266,11 @@
"negthinspace" "enspace" "enskip" "quad" "qquad" "nonumber"
"centering" "TeX" "LaTeX")
font-lock-function-name-face 2 (command 1 t))
+ ("title-0"
+ ("part")
+ font-latex-title-0-face 2 (title 1 t))
("title-1"
- ("part" "chapter")
+ ("chapter")
font-latex-title-1-face 2 (title 1 t))
("title-2"
("section")
@@ -236,8 +279,11 @@
("subsection")
font-latex-title-3-face 2 (title 1 t))
("title-4"
- ("subsubsection" "paragraph" "subparagraph" "subsubparagraph")
+ ("subsubsection")
font-latex-title-4-face 2 (title 1 t))
+ ("title-5"
+ ("paragraph" "subparagraph" "subsubparagraph")
+ font-latex-title-5-face 2 (title 1 t))
("textual"
("item" "title" "author" "date" "thanks" "address" "caption"
"textsuperscript")
@@ -349,9 +395,9 @@
`(,(intern (concat prefix name))
(0 'font-lock-keyword-face append t)
(1 'font-lock-variable-name-face append t)
- (2 (if (eq font-latex-title-fontify 'height)
- ',face
- 'font-lock-type-face)
+ (2 (if (eq font-latex-title-fontify 'color)
+ 'font-lock-type-face
+ ',face)
append t)))
((eq type 'noarg)
`(,(intern (concat prefix name))
@@ -360,7 +406,7 @@
`(,(intern (concat prefix name))
(0 'font-lock-keyword-face append t)
(1 ',face append t)))))
-
+
(defun font-latex-make-built-in-keywords ()
"Build defuns, defvars and defcustoms for built-in keyword fontification."
(let ((keyword-specs font-latex-built-in-keyword-classes))
- Re: [AUCTeX-devel] Re: Fontifying of titles..., (continued)
- Re: [AUCTeX-devel] Re: Fontifying of titles..., David Kastrup, 2005/04/09
- [AUCTeX-devel] Re: Fontifying of titles..., Ralf Angeli, 2005/04/09
- Re: [AUCTeX-devel] Re: Fontifying of titles..., David Kastrup, 2005/04/09
- [AUCTeX-devel] Re: Fontifying of titles..., Ralf Angeli, 2005/04/09
- [AUCTeX-devel] Re: Fontifying of titles..., Ralf Angeli, 2005/04/09
- Re: [AUCTeX-devel] Re: Fontifying of titles..., David Kastrup, 2005/04/09
- [AUCTeX-devel] Re: Fontifying of titles..., Reiner Steib, 2005/04/09
- [AUCTeX-devel] Re: Fontifying of titles..., Ralf Angeli, 2005/04/09
- [AUCTeX-devel] Re: Fontifying of titles..., Reiner Steib, 2005/04/09
- [AUCTeX-devel] Re: Fontifying of titles..., Ralf Angeli, 2005/04/10
- [AUCTeX-devel] Re: Fontifying of titles...,
Reiner Steib <=
- [AUCTeX-devel] Re: Fontifying of titles..., Reiner Steib, 2005/04/22
- [AUCTeX-devel] Renaming font-latex-title-fontify and font-latex-title-N-face (was: Fontifying of titles...), Reiner Steib, 2005/04/27
- Re: [AUCTeX-devel] Renaming font-latex-title-fontify and font-latex-title-N-face, David Kastrup, 2005/04/27
- [AUCTeX-devel] Re: Renaming font-latex-title-fontify and font-latex-title-N-face, Ralf Angeli, 2005/04/27
- [AUCTeX-devel] Re: Renaming font-latex-title-fontify and font-latex-title-N-face, Reiner Steib, 2005/04/27
- [AUCTeX-devel] Re: Renaming font-latex-title-fontify and font-latex-title-N-face, Ralf Angeli, 2005/04/27
- [AUCTeX-devel] Re: Renaming font-latex-title-fontify and font-latex-title-N-face, Reiner Steib, 2005/04/28
- [AUCTeX-devel] Re: Renaming font-latex-title-fontify and font-latex-title-N-face, Ralf Angeli, 2005/04/28
- [AUCTeX-devel] Re: Renaming font-latex-title-fontify and font-latex-title-N-face, Reiner Steib, 2005/04/28
- [AUCTeX-devel] Re: Fontifying of titles..., Reiner Steib, 2005/04/25