Hello,

The package fancyhdr appears to be used a lot, and support in AUCTeX
would be a great plus IMO.  I simplified the implementation a bit, and
kept the values for the completion to the LO, RO etc., even though ol,
or and other reverse and lower-case combinations are also allowed
according to the manual.  I hope this is not a problem?  If not, it's
easy to add the lowercase and reverse options (ol etc.).  I hope the
file will be added.

I also sent a patch with some lengths a couple of weeks ago but it has
not yet been added. Was there something wrong with it?

A small style file for fancynum is also attached.

ChangeLog entry:

2013-02-08  Mads Jensen  <[email protected]>

        * style/fancynum.el: New style.

        * style/fancyhdr.el: New style.
-- 
Med Venlig Hilsen / Kind Regards,
Mads Jensen
Rubinsteinsvej 31,st.th
DK-2450 Kbh. SV
Denmark
+45 6168 8518
My brain is my second favorite organ.
      -- Woody Allen
;;; fancynum.el --- AUCTeX style for `fancynum.sty'

;; Copyright (C) 2013 Free Software Foundation, Inc.

;; Author: Mads Jensen <[email protected]>
;; Maintainer: [email protected]
;; Keywords: tex

;; This file is part of AUCTeX.

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

;; AUCTeX 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 AUCTeX; see the file COPYING.  If not, write to the Free
;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
;; 02110-1301, USA.

;;; Commentary:

;; This file adds support for `fancynum.sty'

;;; Code:

(TeX-add-style-hook
 "fancynum"
 (lambda ()
   (TeX-add-symbols
    '("fnum" t)
    '("setfnumdsym" t)
    '("setfnummsym" t)
    '("setfnumgsym" t))))

(defvar LaTeX-fancynum-package-options
  '("english" "french" "tight" "loose" "commas" "thinspaces" "plain")
  "Package options for fancynum.")

;; fancynum.el ends here

;;; fancyhdr.el --- AUCTeX style for `fancyhdr.sty'

;; Copyright (C) 2012, 2013 Free Software Foundation, Inc.

;; Author: Mads Jensen <[email protected]>
;; Maintainer: [email protected]
;; Keywords: tex

;; This file is part of AUCTeX.

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

;; AUCTeX 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 AUCTeX; see the file COPYING.  If not, write to the Free
;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
;; 02110-1301, USA.

;;; Commentary:

;; This file adds support for `fancyhdr.sty', version 3.2

;;; Code:

;; They're simplified a bit; actually, LO = ol etc. but they're left out as in
;; most documents, the convention seems to be use uppercase letters, with the
;; position as the first letter
(defvar fancyhdr-fancy-positions
  '("LO" "LE" "L" "CO" "CE" "C" "RE" "RO" "R")
  "Options that can be used in some of the fancyhdr commands.")

(TeX-add-style-hook
 "fancyhdr"
 (lambda ()
   (TeX-add-symbols
    '("lhead" t)
    '("lfoot" t)
    '("chead" t)
    '("cfoot" t)
    '("rhead" t)
    '("rfoot" t)
    '("nouppercase" t)
    '("MakeUppercase" t)
    '("fancyhead" [ TeX-arg-fancyhdr-position ] t)
    '("fancyfoot" [ TeX-arg-fancyhdr-position ] t)
    '("fancyheadoffset"
      [ (TeX-arg-fancyhdr-position 
         "Position" ("LO" "LE" "L" "RE" "RO" "R" "0")) ] t)
    '("fancyfootoffset"
      [ (TeX-arg-fancyhdr-position 
         "Position" ("LO" "LE" "L" "RE" "RO" "R" "O")) ] t)
    '("fancyhfoffset"
      [ (TeX-arg-fancyhdr-position "Position" ("E" "O" "L" "R")) ] t)
    '("fancypagestyle" TeX-arg-pagestyle t)

    "headrulewidth" "footrulewidth" "plainfootrulewidth"
    "plainheadrulewidth" "leftmark" "rightmark"
    ;; the manual does not mention any subsubsectionmark (!)
    "chaptermark" "sectionmark" "subsectionmark" "paragraphmark"
    "subparagraphmark" "footrule" "headrule")

   ;; Fontification
   (when (and (featurep 'font-latex)
	      (eq TeX-install-font-lock 'font-latex-setup))
     (font-latex-add-keywords '(("fancyhead" "[{")
                                ("fancyfoot" "[{")
                                ("lhead" "{")
                                ("lfoot" "{")
                                ("chead" "{")
                                ("cfoot" "{")
                                ("rhead" "{")
                                ("rfoot" "{")
                                ("fancyheadoffset" "[{")
                                ("fancyfootoffset" "[{")
                                ("fancypagestyle" "{{")) 'function)
     (font-latex-add-keywords '(("headrulewidth" "")
                                ("footrulewidth" "")
                                ("plainheadrulewidth" "")
                                ("plainfootrulewidth" "")) 'variable)
     ;; Tell font-lock about the update.
     (setq font-lock-set-defaults nil)
     (font-lock-set-defaults))))

;; Because there can be many positions, `TeX-completing-read-multiple' is used
;; instead of just `completing-read', and a `collection' argument is provided as
;; the list of positions differs between the macros
(defun TeX-arg-fancyhdr-position (optional &optional prompt collection)
  "Prompt for the position argument for various commands of the
fancyhdr package."
  (let* ((positions (if (not collection) fancyhdr-fancy-positions
                      collection))
        (arguments
         (mapconcat 'identity 
                    (TeX-completing-read-multiple
                     (TeX-argument-prompt optional prompt "Position")
                     (mapcar 'list positions)) ",")))
    (TeX-argument-insert arguments optional)))

(defvar LaTeX-fancyhdr-package-options nil
  "Package options for fancyhdr.")

;;; fancyhdr.el ends here

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
auctex-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/auctex-devel

Reply via email to