* Pierre Lorenzon (2008-05-15) writes:

> In fact there appears to me that there are at least two
> problems that should solved : style naming, and style storing
> which are not totally disjoint but not totally equal ! Thus we
> have to take care then on the style retrieving question which
> is closely related to the two problems above ! 

Another problem is that styles can represent different things,
e.g. files, document class options or package options.  And all of them
are stored in one variable with no indication what they actually refer
to.  But this is probably not sooo bad because I don't recall a
particular bug report related to this deficiency.

If you want to look at the file extension stuff, you can have a look at
the attached patch.  It contains changes I made probably years ago.

-- 
Ralf
Index: tex.el
===================================================================
RCS file: /cvsroot/auctex/auctex/tex.el,v
retrieving revision 5.618
diff -u -r5.618 tex.el
--- tex.el	4 May 2008 18:58:53 -0000	5.618
+++ tex.el	15 May 2008 20:24:51 -0000
@@ -1875,15 +1875,15 @@
 		   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 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 t)
 				    TeX-style-hook-list))))
 	(TeX-auto-apply))
     (run-hooks 'TeX-update-style-hook)
@@ -2708,13 +2708,10 @@
   (if TeX-auto-untabify
       (untabify (point-min) (point-max)))
   (if (and TeX-auto-save TeX-auto-local)
-      (let* ((file (expand-file-name
-		    (concat
-		     (file-name-as-directory TeX-auto-local)
-		     (TeX-strip-extension nil TeX-all-extensions t)
-		     ".el")
-		    (TeX-master-directory)))
-	     (dir (file-name-directory file)))
+      (let* ((style (TeX-buffer-file-name t))
+	     (dir (expand-file-name (file-name-as-directory TeX-auto-local)
+				    (TeX-master-directory)))
+	     (file (concat dir style ".el")))
 	;; Create auto directory if possible.
 	(if (not (file-exists-p dir))
 	    (condition-case name
@@ -2723,7 +2720,7 @@
 	(if (file-writable-p file)
 	    (save-excursion
 	      (TeX-update-style)
-	      (TeX-auto-store file))
+	      (TeX-auto-store style file))
 	  (message "Can't write style information.")))))
 
 (defcustom TeX-macro-default (car-safe TeX-macro-private)
@@ -2769,7 +2766,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))
@@ -2777,10 +2774,9 @@
 	   (set-buffer (let (enable-local-eval)
 			 (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)
+	   (TeX-auto-store (TeX-buffer-file-name t)
+			   (concat (file-name-as-directory auto)
+				   (TeX-buffer-file-name t)
 				   ".el"))
 	   (kill-buffer (current-buffer))
 	   (message "Parsing %s... done" tex)))))
@@ -2797,22 +2793,23 @@
 	    TeX-macro-global))
   (byte-recompile-directory TeX-auto-global 0))
 
-(defun TeX-auto-store (file)
-  "Extract information for AUCTeX from current buffer and store it in FILE."
+(defun TeX-auto-store (style file)
+  "Extract information about STYLE from current buffer and store it in FILE."
   (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)))
+      (progn
 	(TeX-unload-style style)
 	(save-excursion
 	  (set-buffer (generate-new-buffer file))
 	  (erase-buffer)
-	  (insert "(TeX-add-style-hook \"" style "\"\n"
+	  (insert "(TeX-add-style-hook\n"
+		  " \"" style "\"\n"
 		  " (lambda ()")
 	  (mapcar (lambda (el)
 		    (TeX-auto-insert el style))
 		  TeX-auto-parser)
-	  (insert "))\n\n")
+	  (insert "))\n")
 	  (write-region (point-min) (point-max) file nil 'silent)
 	  (kill-buffer (current-buffer))))
     (if (file-exists-p (concat file "c"))
@@ -2832,13 +2829,13 @@
   (let ((name (symbol-name (nth TeX-auto-parser-add entry)))
 	(list (symbol-value (nth TeX-auto-parser-temporary entry))))
     (unless (null list)
-      (insert "\n    (" name)
+      (insert "\n   (" name)
       (dolist (el list)
 	(cond ((and (stringp el) (not (string= el skip)))
-	       (insert "\n     ")
+	       (insert "\n    ")
 	       (insert (prin1-to-string el)))
 	      ((not (stringp el))
-	       (insert "\n     ")
+	       (insert "\n    ")
 	       (insert "'" (prin1-to-string el)))))
       (insert ")"))))
 
@@ -3143,6 +3140,15 @@
 	(case-fold-search t))
     (string-match regexp file)))
 
+(defun TeX-buffer-file-name (&optional nodir)
+  "Return file name of current buffer or nil.
+Nil is returned if no file is associated with the buffer.  If
+optional argument NODIR is non-nil, strip directory part."
+  (let ((file (buffer-file-name)))
+    (if (and file nodir)
+	(file-name-nondirectory file)
+      file)))
+
 (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.
_______________________________________________
auctex-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/auctex-devel

Reply via email to