? style/babel.sty.el ? style/graphicx.sty.el Index: Makefile.in =================================================================== RCS file: /cvsroot/auctex/auctex/Makefile.in,v retrieving revision 1.124 diff -u -r1.124 Makefile.in --- Makefile.in 17 Dec 2005 14:55:46 -0000 1.124 +++ Makefile.in 26 Dec 2005 16:51:09 -0000 @@ -76,7 +76,7 @@ style/amsopn.el style/amsthm.el style/natbib.el \ style/index.el style/makeidx.el style/multind.el \ style/varioref.el style/fancyref.el style/mdwlist.el \ - style/ngerman.el style/graphicx.el style/graphics.el \ + style/ngerman.el style/graphicx.sty.el style/graphics.el \ style/verbatim.el style/scrbase.el style/scrartcl.el \ style/scrbook.el style/scrreprt.el style/scrlttr2.el \ style/scrpage2.el style/captcont.el style/subfigure.el \ @@ -86,7 +86,7 @@ style/ltxdoc.el style/ltx-base.el style/units.el \ style/nicefrac.el style/url.el style/listings.el \ style/jurabib.el style/csquotes.el style/jsarticle.el \ - style/jsbook.el style/babel.el style/dk-bib.el \ + style/jsbook.el style/babel.sty.el style/dk-bib.el \ style/inputenc.el style/frenchb.el style/francais.el \ style/MinionPro.el STYLEELC = $(STYLESRC:.el=.elc) Index: latex.el =================================================================== RCS file: /cvsroot/auctex/auctex/latex.el,v retrieving revision 5.393 diff -u -r5.393 latex.el --- latex.el 21 Dec 2005 09:53:19 -0000 5.393 +++ latex.el 26 Dec 2005 16:51:10 -0000 @@ -1177,9 +1177,9 @@ (,(concat "\\\\newenvironment\\*?{?\\(" token "+\\)}?") 1 LaTeX-auto-environment) (,(concat "\\\\newtheorem{\\(" token "+\\)}") 1 LaTeX-auto-environment) ("\\\\input{\\(\\.*[^#}%\\\\\\.\n\r]+\\)\\(\\.[^#}%\\\\\\.\n\r]+\\)?}" - 1 TeX-auto-file) + 1 TeX-auto-add-file) ("\\\\include{\\(\\.*[^#}%\\\\\\.\n\r]+\\)\\(\\.[^#}%\\\\\\.\n\r]+\\)?}" - 1 TeX-auto-file) + 1 TeX-auto-add-file) (, (concat "\\\\bibitem{\\(" token "[^, \n\r\t%\"#'()={}]*\\)}") 1 LaTeX-auto-bibitem) (, (concat "\\\\bibitem\\[[^][\n\r]+\\]{\\(" token "[^, \n\r\t%\"#'()={}]*\\)}") 1 LaTeX-auto-bibitem) @@ -1239,18 +1239,20 @@ ;; Get the options. (setq options (LaTeX-listify-package-options options)) - ;; Add them, to the style list. - (dolist (elt options) - (add-to-list 'TeX-auto-file elt)) - ;; Treat documentclass/documentstyle specially. (if (or (string-equal "package" class) (string-equal "Package" class)) (dolist (elt (TeX-split-string "\\([ \t\r\n]\\|%[^\n\r]*[\n\r]\\|,\\)+" style)) - (add-to-list 'TeX-auto-file elt)) + (add-to-list 'TeX-auto-file (list (concat elt ".sty") + :type 'package + :options options))) + ;; FIXME: Better set a separate variable which can be + ;; queried more easily, e.g. for language options? + (add-to-list 'TeX-auto-file (list (concat style ".cls") + :type 'class + :options options)) ;; And a special "art10" style file combining style and size. - (add-to-list 'TeX-auto-file style) (add-to-list 'TeX-auto-file (concat (cond ((string-equal "article" style) @@ -1617,8 +1619,19 @@ (TeX-argument-prompt optionel prompt "File"))))) (if (null file) (setq file "")) - (if (not (string-equal "" file)) - (TeX-run-style-hooks file)) + (unless (string-equal "" file) + ;; FIXME: Heuristic warning! Instead, provide unified way to + ;; determine file names with extensions from those without. + ;; Something like `reftex-locate-file' could be used. + (let ((file (cond ((string= prompt "Package") + (concat file ".sty")) + ((not (string-match "\\.[A-Za-z]+\\'" file)) + (concat file ".tex")) + (t file)))) + ;; FIXME: How and where should the information about :type and + ;; :options be added (`TeX-auto-file' is not necessarily + ;; defined)? + (TeX-run-style-hooks file))) (TeX-argument-insert file optionel))) (defvar BibTeX-global-style-files nil Index: tex-buf.el =================================================================== RCS file: /cvsroot/auctex/auctex/tex-buf.el,v retrieving revision 1.241 diff -u -r1.241 tex-buf.el --- tex-buf.el 17 Nov 2005 17:03:23 -0000 1.241 +++ tex-buf.el 26 Dec 2005 16:51:10 -0000 @@ -83,7 +83,9 @@ (setq name (TeX-master-file))) (TeX-check-files (concat name "." (TeX-output-extension)) - (cons name (TeX-style-list)) + (cons name (mapcar (lambda (style) + (if (listp style) (car style) style)) + (TeX-style-list))) TeX-file-extensions)) (defun TeX-command-master (&optional override-confirm) @@ -463,11 +465,44 @@ (setq expansion (replace-match printer t t expansion 0))) expansion))) +(defun TeX-style-match (s-or-regexp1 s2) + "Return non-nil, if S-OR-REGEXP1 fuzzily matches style S2. +The styles do not need to be exactly the same but one at least +has to be a subset of the other." + (cond ((and (stringp s-or-regexp1) (stringp s2)) + (string-match s-or-regexp1 s2)) + ((and (listp s-or-regexp1) (listp s2)) + (let ((plist1 (cdr s-or-regexp1)) + (plist2 (cdr s2))) + (and (string= (car s-or-regexp1) (car s2)) + (eq (plist-get :type plist1) (plist-get :type plist2)) + (if (eq (plist-get :type plist1) 'file) + t + (let* ((options1 (plist-get :options plist1)) + (options2 (plist-get :options plist2)) + (options-short (or (if (> (length options1) + (length options2)) + options2 + options1) + '())) + (options-long (or (if (> (length options1) + (length options2)) + options1 + options2) + '())) + (retval t)) + (catch 'mismatch + (dolist (elt options-short) + (unless (member elt options-long) + (setq retval nil) + (throw 'mismatch nil)))) + retval))))))) + (defun TeX-style-check (styles) "Check STYLES compared to the current style options." (let ((files (TeX-style-list))) (while (and styles - (not (TeX-member (car (car styles)) files 'string-match))) + (not (TeX-member (caar styles) files 'TeX-style-match))) (setq styles (cdr styles)))) (if styles (nth 1 (car styles)) @@ -518,10 +553,10 @@ ((listp style) (while (and style - (TeX-member (car style) files 'string-match)) + (TeX-member (car style) files 'TeX-style-match)) (setq style (cdr style))) style) - ((not (TeX-member style files 'string-match))))))) + ((not (TeX-member style files 'TeX-style-match))))))) (setq styles (cdr styles))) (if styles (nth 2 (car styles)) Index: tex.el =================================================================== RCS file: /cvsroot/auctex/auctex/tex.el,v retrieving revision 5.552 diff -u -r5.552 tex.el --- tex.el 8 Dec 2005 19:37:16 -0000 5.552 +++ tex.el 26 Dec 2005 16:51:11 -0000 @@ -1604,6 +1604,7 @@ (defun TeX-load-style (style) "Search for and load each definition for STYLE in `TeX-style-path'." + (when (listp style) (setq style (car style))) (cond ((assoc style TeX-style-hook-list)) ; We already found it ((string-match "\\`\\(.+[/\\]\\)\\([^/\\]*\\)\\'" style) ;Complex path (let* ((dir (substring style (match-beginning 1) (match-end 1))) @@ -1690,9 +1691,10 @@ "Run the TeX style hooks STYLES." (mapcar (lambda (style) ;; Avoid recursion. - (unless (TeX-member style TeX-active-styles 'string-equal) + (unless (TeX-member style TeX-active-styles 'equal) (setq TeX-active-styles (cons style TeX-active-styles)) + (when (listp style) (setq style (car style))) (TeX-load-style style) (let ((default-directory default-directory)) ;; Complex path. @@ -1727,16 +1729,16 @@ TeX-style-hook-applied-p)) (setq TeX-style-hook-applied-p t) (message "Applying style hooks...") - (TeX-run-style-hooks (TeX-strip-extension nil nil t)) + (TeX-run-style-hooks (TeX-buffer-file-name-or-none t)) ;; Run parent style hooks if it has a single parent that isn't itself. (if (or (not (memq TeX-master '(nil t))) (and (buffer-file-name) (string-match TeX-one-master (file-name-nondirectory (buffer-file-name))))) - (TeX-run-style-hooks (TeX-master-file))) + (TeX-run-style-hooks (TeX-master-file t))) (if (and TeX-parse-self - (null (cdr-safe (assoc (TeX-strip-extension nil nil t) + (null (cdr-safe (assoc (TeX-buffer-file-name-or-none t) TeX-style-hook-list)))) (TeX-auto-apply)) @@ -2532,7 +2534,7 @@ (let* ((file (expand-file-name (concat (file-name-as-directory TeX-auto-local) - (TeX-strip-extension nil TeX-all-extensions t) + (TeX-buffer-file-name-or-none t) ".el") (TeX-master-directory))) (dir (file-name-directory file))) @@ -2590,7 +2592,7 @@ ((not (file-newer-than-file-p tex (concat (file-name-as-directory auto) - (TeX-strip-extension tex TeX-all-extensions t) + (file-name-nondirectory tex) ".el")))) ((TeX-match-extension tex (append TeX-file-extensions BibTeX-file-extensions)) @@ -2599,9 +2601,7 @@ (find-file-noselect tex))) (message "Parsing %s..." tex) (TeX-auto-store (concat (file-name-as-directory auto) - (TeX-strip-extension tex - TeX-all-extensions - t) + (file-name-nondirectory tex) ".el")) (kill-buffer (current-buffer)) (message "Parsing %s... done" tex))))) @@ -2623,7 +2623,7 @@ (TeX-auto-parse) (if (member nil (mapcar 'TeX-auto-entry-clear-p TeX-auto-parser)) - (let ((style (TeX-strip-extension nil TeX-all-extensions t))) + (let ((style (TeX-buffer-file-name-or-none t))) (TeX-unload-style style) (save-excursion (set-buffer (generate-new-buffer file)) @@ -2703,7 +2703,7 @@ (,(concat "\\\\newfont{?\\\\\\(" token "+\\)}?") 1 TeX-auto-symbol) (,(concat "\\\\typein\\[\\\\\\(" token "+\\)\\]") 1 TeX-auto-symbol) ("\\\\input +\\(\\.*[^#%\\\\\\.\n\r]+\\)\\(\\.[^#%\\\\\\.\n\r]+\\)?" - 1 TeX-auto-file) + 1 TeX-auto-add-file) (,(concat "\\\\mathchardef\\\\\\(" token "+\\)address@hidden") 1 TeX-auto-symbol))) "List of regular expression matching common LaTeX macro definitions.") @@ -2867,6 +2867,21 @@ (add-to-list 'TeX-auto-symbol elt)) (add-to-list 'TeX-auto-symbol symbol))))) +(defun TeX-auto-add-file (match) + "Add file relating to MATCH to `TeX-auto-file'." + (let ((file (TeX-match-buffer match)) + (files (TeX-search-files nil nil t))) ; FIXME: Potentially slow. + (when (and (not (member file files)) + (or (member (concat file ".tex") files) + ;; Heuristic (if there is no extension, add one) + (not (string-match "\\.[A-Za-z]+\\'" file)))) + (setq file (concat file ".tex"))) + ;; FIXME: Do we need a list with the added :type here? How about + ;; getting rid of the art10 and latex2e stuff in `TeX-auto-file'? + (setq file (list file :type 'file)) + (add-to-list 'TeX-auto-file file))) + + ;;; Utilities ;; ;; Some of these functions has little to do with TeX, but nonetheless we @@ -2964,6 +2979,14 @@ (case-fold-search t)) (string-match regexp file))) +(defun TeX-buffer-file-name-or-none (&optional nodir) + "Return file name of current buffer or \"\" if it has none. +If optional argument NODIR is non-nil, strip directory part." + (let ((file (buffer-file-name))) + (cond ((and file nodir) (file-name-nondirectory file)) + (file file) + (t "")))) + (defun TeX-strip-extension (&optional string extensions nodir nostrip) "Return STRING without any trailing extension in EXTENSIONS. If NODIR is t, also remove directory part of STRING.