Initial Commit
[packages] / xemacs-packages / auctex / style / fancyhdr.el
1 ;;; fancyhdr.el --- AUCTeX style for `fancyhdr.sty'
2
3 ;; Copyright (C) 2012, 2013 Free Software Foundation, Inc.
4
5 ;; Author: Mads Jensen <mje@inducks.org>
6 ;; Maintainer: auctex-devel@gnu.org
7 ;; Keywords: tex
8
9 ;; This file is part of AUCTeX.
10
11 ;; AUCTeX is free software; you can redistribute it and/or modify it
12 ;; under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 3, or (at your option)
14 ;; any later version.
15
16 ;; AUCTeX is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 ;; General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with AUCTeX; see the file COPYING.  If not, write to the Free
23 ;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
24 ;; 02110-1301, USA.
25
26 ;;; Commentary:
27
28 ;; This file adds support for `fancyhdr.sty', version 3.2
29
30 ;;; Code:
31
32 (TeX-add-style-hook
33  "fancyhdr"
34  (lambda ()
35    (TeX-add-symbols
36     '("lhead" t)
37     '("lfoot" t)
38     '("chead" t)
39     '("cfoot" t)
40     '("rhead" t)
41     '("rfoot" t)
42     '("nouppercase" t)
43     '("MakeUppercase" t)
44     '("fancyhead" [ TeX-arg-fancyhdr-position ] t)
45     '("fancyfoot" [ TeX-arg-fancyhdr-position ] t)
46     '("fancyheadoffset"
47       [ (TeX-arg-fancyhdr-position
48          "Position" ("LO" "LE" "L" "RE" "RO" "R" "0")) ] t)
49     '("fancyfootoffset"
50       [ (TeX-arg-fancyhdr-position
51          "Position" ("LO" "LE" "L" "RE" "RO" "R" "O")) ] t)
52     '("fancyhfoffset"
53       [ (TeX-arg-fancyhdr-position "Position" ("E" "O" "L" "R")) ] t)
54     '("fancypagestyle" TeX-arg-pagestyle t)
55
56     "headrulewidth" "footrulewidth" "plainfootrulewidth"
57     "plainheadrulewidth" "leftmark" "rightmark"
58     ;; the manual does not mention any subsubsectionmark (!)
59     "chaptermark" "sectionmark" "subsectionmark" "paragraphmark"
60     "subparagraphmark" "footrule" "headrule")
61
62    ;; `fancyhdr.sty' supplies these two pagestyles
63    (LaTeX-add-pagestyles "fancy" "fancyplain")
64
65    ;; Fontification
66    (when (and (featurep 'font-latex)
67               (eq TeX-install-font-lock 'font-latex-setup))
68      (font-latex-add-keywords '(("fancyhead" "[{")
69                                 ("fancyfoot" "[{")
70                                 ("lhead" "{")
71                                 ("lfoot" "{")
72                                 ("chead" "{")
73                                 ("cfoot" "{")
74                                 ("rhead" "{")
75                                 ("rfoot" "{")
76                                 ("fancyheadoffset" "[{")
77                                 ("fancyfootoffset" "[{")
78                                 ("fancypagestyle" "{{")) 'function)
79      (font-latex-add-keywords '(("headrulewidth" "")
80                                 ("footrulewidth" "")
81                                 ("plainheadrulewidth" "")
82                                 ("plainfootrulewidth" "")) 'variable)
83      ;; Tell font-lock about the update.
84      (setq font-lock-set-defaults nil)
85      (font-lock-set-defaults)))
86  LaTeX-dialect)
87
88 ;; Because there can be many positions, `TeX-completing-read-multiple' is used
89 ;; instead of just `completing-read', and a `collection' argument is provided as
90 ;; the list of positions differs between the macros
91 (defun TeX-arg-fancyhdr-position (optional &optional prompt collection)
92   "Prompt for a fancyhdr position with completion.
93 If OPTIONAL is non-nil, insert the resulting value as an optional
94 argument, otherwise as a mandatory one.  If non-nil, PROMPT is
95 used as the prompt.  If non-nil, COLLECTION is used as the
96 completion list for the position."
97   (let* ((positions (if (not collection)
98                         ;; Standard positions with no restrictions.  Lower-case
99                         ;; versions, and reverse versions (e.g., OC) are left
100                         ;; out for simplicity.
101                         '("LO" "LE" "L" "CO" "CE" "C" "RE" "RO" "R")
102                       collection))
103         (arguments
104          (mapconcat 'identity
105                     (TeX-completing-read-multiple
106                      (TeX-argument-prompt optional prompt "Position")
107                      (mapcar 'list positions)) ",")))
108     (TeX-argument-insert arguments optional)))
109
110 (defvar LaTeX-fancyhdr-package-options nil
111   "Package options for fancyhdr.")
112
113 ;;; fancyhdr.el ends here
114