/[emacs]/emacs/lisp/textmodes/tex-mode.el
ViewVC logotype

Diff of /emacs/lisp/textmodes/tex-mode.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.146 by jpw, Mon Aug 30 19:04:18 2004 UTC revision 1.147 by monnier, Sun Oct 3 19:53:22 2004 UTC
# Line 1  Line 1 
1  ;;; tex-mode.el --- TeX, LaTeX, and SliTeX mode commands -*- coding: utf-8 -*-  ;;; tex-mode.el --- TeX, LaTeX, and SliTeX mode commands -*- coding: utf-8 -*-
2    
3  ;; Copyright (C) 1985,86,89,92,94,95,96,97,98,1999,2002,03,2004  ;; Copyright (C) 1985, 1986, 1989, 1992, 1994, 1995, 1996, 1997, 1998, 1999,
4  ;;       Free Software Foundation, Inc.  ;;   2002, 2003, 2004  Free Software Foundation, Inc.
5    
6  ;; Maintainer: FSF  ;; Maintainer: FSF
7  ;; Keywords: tex  ;; Keywords: tex
# Line 196  use." Line 196  use."
196    :group 'tex-view)    :group 'tex-view)
197    
198  ;;;###autoload  ;;;###autoload
199  (defcustom tex-dvi-view-command '(if (eq window-system 'x) "xdvi" "dvi2tty * | cat -s")  (defcustom tex-dvi-view-command
200      '(cond
201        ((eq window-system 'x) "xdvi")
202        ((eq window-system 'w32) "yap")
203        (t "dvi2tty * | cat -s"))
204    "*Command used by \\[tex-view] to display a `.dvi' file.    "*Command used by \\[tex-view] to display a `.dvi' file.
205  If it is a string, that specifies the command directly.  If it is a string, that specifies the command directly.
206  If this string contains an asterisk (`*'), that is replaced by the file name;  If this string contains an asterisk (`*'), that is replaced by the file name;
# Line 453  An alternative value is \" . \", if you Line 457  An alternative value is \" . \", if you
457                        '("input" "include" "includeonly" "bibliography"                        '("input" "include" "includeonly" "bibliography"
458                          "epsfig" "psfig" "epsf" "nofiles" "usepackage"                          "epsfig" "psfig" "epsf" "nofiles" "usepackage"
459                          "documentstyle" "documentclass" "verbatiminput"                          "documentstyle" "documentclass" "verbatiminput"
460                          "includegraphics" "includegraphics*")                          "includegraphics" "includegraphics*"
461                            "url" "nolinkurl")
462                        t))                        t))
463             ;; Miscellany.             ;; Miscellany.
464             (slash "\\\\")             (slash "\\\\")
# Line 771  Inherits `shell-mode-map' with a few add Line 776  Inherits `shell-mode-map' with a few add
776                                      "part" "chapter" "newcommand"                                      "part" "chapter" "newcommand"
777                                      "renewcommand") 'words)                                      "renewcommand") 'words)
778                        "\\|NeedsTeXFormat{LaTeX")))                        "\\|NeedsTeXFormat{LaTeX")))
779                    (if (looking-at                    (if (and (looking-at
780                         "document\\(style\\|class\\)\\(\\[.*\\]\\)?{slides}")                              "document\\(style\\|class\\)\\(\\[.*\\]\\)?{slides}")
781                               ;; SliTeX is almost never used any more nowadays.
782                               (tex-executable-exists-p slitex-run-command))
783                        'slitex-mode                        'slitex-mode
784                      'latex-mode)                      'latex-mode)
785                  'plain-tex-mode))))                  'plain-tex-mode))))
# Line 1219  A prefix arg inhibits the checking." Line 1226  A prefix arg inhibits the checking."
1226  (defvar latex-block-default "enumerate")  (defvar latex-block-default "enumerate")
1227    
1228  (defvar latex-block-args-alist  (defvar latex-block-args-alist
1229    '(("array" nil ?\{ (skeleton-read "[options]: ") ?\})    '(("array" nil ?\{ (skeleton-read "Format: ") ?\})
1230      ("tabular" nil ?\{ (skeleton-read "[options]: ") ?\}))      ("tabular" nil ?\{ (skeleton-read "Format: ") ?\})
1231        ("minipage" nil ?\{ (skeleton-read "Size: ") ?\})
1232        ("picture" nil ?\( (skeleton-read "SizeX,SizeY: ") ?\))
1233        ;; FIXME: This is right for Prosper, but not for seminar.
1234        ;; ("slide" nil ?\{ (skeleton-read "Title: ") ?\})
1235        )
1236    "Skeleton element to use for arguments to particular environments.    "Skeleton element to use for arguments to particular environments.
1237  Every element of the list has the form (NAME . SKEL-ELEM) where NAME is  Every element of the list has the form (NAME . SKEL-ELEM) where NAME is
1238  the name of the environment and SKEL-ELEM is an element to use in  the name of the environment and SKEL-ELEM is an element to use in
# Line 1229  a skeleton (see `skeleton-insert').") Line 1241  a skeleton (see `skeleton-insert').")
1241  (defvar latex-block-body-alist  (defvar latex-block-body-alist
1242    '(("enumerate" nil '(latex-insert-item) > _)    '(("enumerate" nil '(latex-insert-item) > _)
1243      ("itemize" nil '(latex-insert-item) > _)      ("itemize" nil '(latex-insert-item) > _)
1244      ("table" nil "\\caption{" > - "}" > \n _)      ("table" nil "\\caption{" > (skeleton-read "Caption: ") "}" > \n
1245      ("figure" nil  > _ \n "\\caption{" > _ "}" >))       '(if (and (boundp 'reftex-mode) reftex-mode) (reftex-label "table"))
1246         \n _)
1247        ("figure" nil  > _ \n "\\caption{" > (skeleton-read "Caption: ") "}" > \n
1248         '(if (and (boundp 'reftex-mode) reftex-mode) (reftex-label "table"))))
1249    "Skeleton element to use for the body of particular environments.    "Skeleton element to use for the body of particular environments.
1250  Every element of the list has the form (NAME . SKEL-ELEM) where NAME is  Every element of the list has the form (NAME . SKEL-ELEM) where NAME is
1251  the name of the environment and SKEL-ELEM is an element to use in  the name of the environment and SKEL-ELEM is an element to use in
# Line 1254  Puts point on a blank line between them. Line 1269  Puts point on a blank line between them.
1269      choice)      choice)
1270    \n "\\begin{" str "}"    \n "\\begin{" str "}"
1271    (cdr (assoc str latex-block-args-alist))    (cdr (assoc str latex-block-args-alist))
1272    > \n (or (cdr (assoc str latex-block-body-alist)) '(nil > _)) \n    > \n (or (cdr (assoc str latex-block-body-alist)) '(nil > _))
1273      (unless (bolp) '\n)
1274    "\\end{" str "}" > \n)    "\\end{" str "}" > \n)
1275    
1276  (define-skeleton latex-insert-item  (define-skeleton latex-insert-item
# Line 1598  If NOT-ALL is non-nil, save the `.dvi' f Line 1614  If NOT-ALL is non-nil, save the `.dvi' f
1614      ("texindex %r.??")      ("texindex %r.??")
1615      ("dvipdfm %r" "%r.dvi" "%r.pdf")      ("dvipdfm %r" "%r.dvi" "%r.pdf")
1616      ("dvipdf %r" "%r.dvi" "%r.pdf")      ("dvipdf %r" "%r.dvi" "%r.pdf")
1617      ("dvips %r" "%r.dvi" "%r.ps")      ("dvips -o %r.ps %r" "%r.dvi" "%r.ps")
1618      ("ps2pdf %r.ps" "%r.ps" "%r.pdf")      ("ps2pdf %r.ps" "%r.ps" "%r.pdf")
1619      ("gv %r.ps &" "%r.ps")      ("gv %r.ps &" "%r.ps")
1620      ("gv %r.pdf &" "%r.pdf")      ("gv %r.pdf &" "%r.pdf")
# Line 1767  FILE is typically the output DVI or PDF Line 1783  FILE is typically the output DVI or PDF
1783          (not (tex-uptodate-p (format-spec out fspec)))))))          (not (tex-uptodate-p (format-spec out fspec)))))))
1784    
1785  (defun tex-compile-default (fspec)  (defun tex-compile-default (fspec)
1786    "Guess a default command given the format-spec FSPEC."    "Guess a default command given the `format-spec' FSPEC."
1787    ;; TODO: Learn to do latex+dvips!    ;; TODO: Learn to do latex+dvips!
1788    (let ((cmds nil)    (let ((cmds nil)
1789          (unchanged-in nil))          (unchanged-in nil))
# Line 1777  FILE is typically the output DVI or PDF Line 1793  FILE is typically the output DVI or PDF
1793          (if (tex-command-active-p cmd fspec)          (if (tex-command-active-p cmd fspec)
1794              (push cmd cmds)              (push cmd cmds)
1795            (push (nth 1 cmd) unchanged-in))))            (push (nth 1 cmd) unchanged-in))))
1796        ;; If no command seems to be applicable, arbitrarily pick the first one.
1797        (unless cmds
1798          (setq cmds (list (car tex-compile-commands))))
1799      ;; Remove those commands whose input was considered stable for      ;; Remove those commands whose input was considered stable for
1800      ;; some other command (typically if (t . "%.pdf") is inactive      ;; some other command (typically if (t . "%.pdf") is inactive
1801      ;; then we're using pdflatex and the fact that the dvi file      ;; then we're using pdflatex and the fact that the dvi file
# Line 2261  Runs the shell command defined by `tex-s Line 2280  Runs the shell command defined by `tex-s
2280  (defvar tex-indent-basic 2)  (defvar tex-indent-basic 2)
2281  (defvar tex-indent-item tex-indent-basic)  (defvar tex-indent-item tex-indent-basic)
2282  (defvar tex-indent-item-re "\\\\\\(bib\\)?item\\>")  (defvar tex-indent-item-re "\\\\\\(bib\\)?item\\>")
2283    (defvar latex-noindent-environments '("document"))
2284    
2285  (defvar tex-latex-indent-syntax-table  (defvar tex-latex-indent-syntax-table
2286    (let ((st (make-syntax-table tex-mode-syntax-table)))    (let ((st (make-syntax-table tex-mode-syntax-table)))
# Line 2311  There might be text before point." Line 2331  There might be text before point."
2331                (latex-find-indent 'virtual))))                (latex-find-indent 'virtual))))
2332       ;; Default (maybe an argument)       ;; Default (maybe an argument)
2333       (let ((pos (point))       (let ((pos (point))
            (char (char-after))  
2334             ;; Outdent \item if necessary.             ;; Outdent \item if necessary.
2335             (indent (if (looking-at tex-indent-item-re) (- tex-indent-item) 0))             (indent (if (looking-at tex-indent-item-re) (- tex-indent-item) 0))
2336             up-list-pos)             up-list-pos)
# Line 2329  There might be text before point." Line 2348  There might be text before point."
2348           ;; Have to indent relative to the open-paren.           ;; Have to indent relative to the open-paren.
2349           (goto-char up-list-pos)           (goto-char up-list-pos)
2350           (if (and (not tex-indent-allhanging)           (if (and (not tex-indent-allhanging)
2351                      (save-excursion
2352                        ;; Make sure we're an argument to a macro and
2353                        ;; that the macro is at the beginning of a line.
2354                        (condition-case nil
2355                            (progn
2356                              (while (eq (char-syntax (char-after)) ?\()
2357                                (forward-sexp -1))
2358                              (and (eq (char-syntax (char-after)) ?/)
2359                                   (progn (skip-chars-backward " \t&")
2360                                          (bolp))))
2361                          (scan-error nil)))
2362                    (> pos (progn (latex-down-list)                    (> pos (progn (latex-down-list)
2363                                  (forward-comment (point-max))                                  (forward-comment (point-max))
2364                                  (point))))                                  (point))))
# Line 2336  There might be text before point." Line 2366  There might be text before point."
2366               (current-column)               (current-column)
2367             ;; We're the first element after a hanging brace.             ;; We're the first element after a hanging brace.
2368             (goto-char up-list-pos)             (goto-char up-list-pos)
2369             (+ indent tex-indent-basic (latex-find-indent 'virtual))))             (+ (if (and (looking-at "\\\\begin *{\\([^\n}]+\\)")
2370                           (member (match-string 1)
2371                                   latex-noindent-environments))
2372                      0 tex-indent-basic)
2373                  indent (latex-find-indent 'virtual))))
2374          ;; We're now at the "beginning" of a line.          ;; We're now at the "beginning" of a line.
2375          ((not (and (not virtual) (eq (char-after) ?\\)))          ((not (and (not virtual) (eq (char-after) ?\\)))
2376           ;; Nothing particular here: just keep the same indentation.           ;; Nothing particular here: just keep the same indentation.
2377           (+ indent (current-column)))           (+ indent (current-column)))
2378          ;; We're now looking at a macro call.          ;; We're now looking at a macro call.
2379            ((looking-at tex-indent-item-re)          ((looking-at tex-indent-item-re)
2380             ;; Indenting relative to an item, have to re-add the outdenting.           ;; Indenting relative to an item, have to re-add the outdenting.
2381           (+ indent (current-column) tex-indent-item))           (+ indent (current-column) tex-indent-item))
2382          (t          (t
2383           (let ((col (current-column)))           (let ((col (current-column)))
2384             (if (or (null char) (not (eq (char-syntax char) ?\()))             (if (or (not (eq (char-syntax (or (char-after pos) ?\ )) ?\())
2385                       ;; Can't be an arg if there's an empty line inbetween.
2386                       (save-excursion (re-search-forward "^[ \t]*$" pos t)))
2387                 ;; If the first char was not an open-paren, there's                 ;; If the first char was not an open-paren, there's
2388                 ;; a risk that this is really not an argument to the                 ;; a risk that this is really not an argument to the
2389                 ;; macro at all.                 ;; macro at all.
# Line 2422  There might be text before point." Line 2458  There might be text before point."
2458    
2459  (provide 'tex-mode)  (provide 'tex-mode)
2460    
2461  ;;; arch-tag: c0a680b1-63aa-4547-84b9-4193c29c0080  ;; arch-tag: c0a680b1-63aa-4547-84b9-4193c29c0080
2462  ;;; tex-mode.el ends here  ;;; tex-mode.el ends here

Legend:
Removed from v.1.146  
changed lines
  Added in v.1.147

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26