>>>>> "Stefan" == Stefan Heimann <[EMAIL PROTECTED]> writes:

  Stefan> Hi!

  Stefan> I want to select the compiler based in the extension of the
  Stefan> file to compile. For `normal' source code I use jikes, but I
  Stefan> also use pizza, which adds some stuff to java. Files for the
  Stefan> pizza-compiler ends with `.pizza'. Any ideas how I can
  Stefan> switch between the 2 compilers depending on the filename
  Stefan> extension?

        I can get you half of the way there....

        To make a change based on the file extension I use 
the defadvice package on "find-file-noselect". In my case I use this
to unwind paths with symlinks, or other wise the jde-package utilities
get things wrong (maybe I am doing them an injustice here. They used
to get things wrong. They may no longer do so). 


(defvar phil-find-file-truename-regexp "java$" )

(defadvice find-file-noselect (around phil-set-find-file-truename-for-buffer activate)
  "This advice sets `find-file-truename' to true if the file name matches 
`phil-find-file-truename-regexp'. When the before part of the this
advice gets run there is no buffer, so it has to be set globally. Afterwards it is 
reset
and set only locally"
  (if (string-match phil-find-file-truename-regexp (ad-get-arg 0))
      (progn
        ;; set find-file-true-name
        (setq find-file-visit-truename 't)
        ;; find the file
        ad-do-it
        (setq find-file-visit-truename nil)
        (save-excursion
          (set-buffer ad-return-value)
          (make-local-variable 'find-file-visit-truename)
          (setq find-file-visit-truename 't))))
  ad-do-it)
        


        Now in your case instead of setting the variable 
that I do, you want to set up a buffer local value for whatever
variable is used to set the compiler. I used to use this....



;; (defun phil-java-toggle-compiler()
;;   "Toggles the compiler being used jikes, or javac"
;;   (interactive)
;;   (if (equal jde-compiler "jikes" )
;;       ;;Set the compiler to javac and switch of +E option (javac doesnt understand 
it)
;;       (progn(setq jde-compiler "/opt/java/blackdown/jdk1.2.2rc4/bin/javac")
;;          (setq jde-compile-option-command-line-args "")
;;          (message "Javac in use"))
;;     ;;Set the compiler to jikes and switch on +E option cause I usually use it
;;     (progn(setq jde-compiler "jikes" )
;;        (setq jde-compile-option-command-line-args "+E")
;;        (message "Jikes in use"))))

        
        which I them presented as a menu item, but since that time
Paul has changed things enough that it breaks, and I have not got
around yet to repairing things. Anyway combining the two approaches
should make things work okay. 

        
        Cheers

        Phil

Reply via email to