aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Pfeiffer2004-09-12 18:08:12 +0000
committerDaniel Pfeiffer2004-09-12 18:08:12 +0000
commit489a8034ae9ac4d6f56a363fea3ae1f61816b1ab (patch)
tree3e7c05719d40f0866cb75dc763e7506a23332b78
parent139aea0862e1a0558240dbb1bdcbdb5343a7670e (diff)
downloademacs-489a8034ae9ac4d6f56a363fea3ae1f61816b1ab.tar.gz
emacs-489a8034ae9ac4d6f56a363fea3ae1f61816b1ab.zip
Parse command to see if it starts with a cd, and if so perform it for the *compilation* buffer. Change the header to reflect this.
-rw-r--r--lisp/progmodes/compile.el53
1 files changed, 29 insertions, 24 deletions
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 8ae2a7abe76..2f910608d5c 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -849,6 +849,7 @@ Otherwise, construct a buffer name from MODE-NAME."
849 849
850(defun compilation-start (command &optional mode name-function highlight-regexp) 850(defun compilation-start (command &optional mode name-function highlight-regexp)
851 "Run compilation command COMMAND (low level interface). 851 "Run compilation command COMMAND (low level interface).
852If COMMAND starts with a cd command, that becomes the `default-directory'.
852The rest of the arguments are optional; for them, nil means use the default. 853The rest of the arguments are optional; for them, nil means use the default.
853 854
854MODE is the major mode to set in the compilation buffer. Mode 855MODE is the major mode to set in the compilation buffer. Mode
@@ -861,26 +862,29 @@ global value of `compilation-highlight-regexp'.
861 862
862Returns the compilation buffer created." 863Returns the compilation buffer created."
863 (or mode (setq mode 'compilation-mode)) 864 (or mode (setq mode 'compilation-mode))
864 (let ((name-of-mode 865 (let* ((name-of-mode
865 (if (eq mode t) 866 (if (eq mode t)
866 (prog1 "compilation" (require 'comint)) 867 (prog1 "compilation" (require 'comint))
867 (replace-regexp-in-string "-mode$" "" (symbol-name mode)))) 868 (replace-regexp-in-string "-mode$" "" (symbol-name mode))))
868 (process-environment 869 (process-environment
869 (append 870 (append
870 compilation-environment 871 compilation-environment
871 (if (if (boundp 'system-uses-terminfo) ; `if' for compiler warning 872 (if (if (boundp 'system-uses-terminfo) ; `if' for compiler warning
872 system-uses-terminfo) 873 system-uses-terminfo)
873 (list "TERM=dumb" "TERMCAP=" 874 (list "TERM=dumb" "TERMCAP="
874 (format "COLUMNS=%d" (window-width))) 875 (format "COLUMNS=%d" (window-width)))
875 (list "TERM=emacs" 876 (list "TERM=emacs"
876 (format "TERMCAP=emacs:co#%d:tc=unknown:" 877 (format "TERMCAP=emacs:co#%d:tc=unknown:"
877 (window-width)))) 878 (window-width))))
878 ;; Set the EMACS variable, but 879 ;; Set the EMACS variable, but
879 ;; don't override users' setting of $EMACS. 880 ;; don't override users' setting of $EMACS.
880 (unless (getenv "EMACS") '("EMACS=t")) 881 (unless (getenv "EMACS") '("EMACS=t"))
881 (copy-sequence process-environment))) 882 (copy-sequence process-environment)))
882 (thisdir default-directory) 883 cd-path ; in case process-environment contains CDPATH
883 outwin outbuf) 884 (thisdir (if (string-match "^\\s *cd\\s +\\(.+?\\)\\s *[;&\n]" command)
885 (substitute-in-file-name (match-string 1 command))
886 default-directory))
887 outwin outbuf)
884 (with-current-buffer 888 (with-current-buffer
885 (setq outbuf 889 (setq outbuf
886 (get-buffer-create 890 (get-buffer-create
@@ -901,15 +905,16 @@ Returns the compilation buffer created."
901 (buffer-name))))) 905 (buffer-name)))))
902 ;; Clear out the compilation buffer and make it writable. 906 ;; Clear out the compilation buffer and make it writable.
903 ;; Change its default-directory to the directory where the compilation 907 ;; Change its default-directory to the directory where the compilation
904 ;; will happen, and insert a `cd' command to indicate this. 908 ;; will happen, and insert a `default-directory' to indicate this.
905 (setq buffer-read-only nil) 909 (setq buffer-read-only nil)
906 (buffer-disable-undo (current-buffer)) 910 (buffer-disable-undo (current-buffer))
907 (erase-buffer) 911 (erase-buffer)
908 (buffer-enable-undo (current-buffer)) 912 (buffer-enable-undo (current-buffer))
909 (setq default-directory thisdir) 913 (cd thisdir)
910 ;; output a mode setter, for saving and later reloading this buffer 914 ;; output a mode setter, for saving and later reloading this buffer
911 (insert "cd " thisdir " # -*-" name-of-mode 915 (insert "-*- mode: " name-of-mode
912 "-*-\nEntering directory `" thisdir "'\n" command "\n") 916 "; default-directory: " (prin1-to-string default-directory)
917 " -*-\n" command "\n")
913 (set-buffer-modified-p nil)) 918 (set-buffer-modified-p nil))
914 ;; If we're already in the compilation buffer, go to the end 919 ;; If we're already in the compilation buffer, go to the end
915 ;; of the buffer, so point will track the compilation output. 920 ;; of the buffer, so point will track the compilation output.