comparison lisp/progmodes/compile.el @ 62859:c18eb4cd2ef7

(compilation-start): Set the mode before inserting the initial text.
author Richard M. Stallman <rms@gnu.org>
date Sun, 29 May 2005 08:32:57 +0000
parents c531c5fa55c5
children 6b3810cab95a
comparison
equal deleted inserted replaced
62858:c23f28be371c 62859:c18eb4cd2ef7
933 (cd (if (string-match "^\\s *cd\\(?:\\s +\\(\\S +?\\)\\)?\\s *[;&\n]" command) 933 (cd (if (string-match "^\\s *cd\\(?:\\s +\\(\\S +?\\)\\)?\\s *[;&\n]" command)
934 (if (match-end 1) 934 (if (match-end 1)
935 (substitute-env-vars (match-string 1 command)) 935 (substitute-env-vars (match-string 1 command))
936 "~") 936 "~")
937 default-directory)) 937 default-directory))
938 ;; Select the desired mode.
939 (if (not (eq mode t))
940 (funcall mode)
941 (setq buffer-read-only nil)
942 (with-no-warnings (comint-mode))
943 (compilation-shell-minor-mode))
944 (if highlight-regexp
945 (set (make-local-variable 'compilation-highlight-regexp)
946 highlight-regexp))
938 (erase-buffer) 947 (erase-buffer)
939 ;; output a mode setter, for saving and later reloading this buffer 948 ;; Output a mode setter, for saving and later reloading this buffer.
940 (insert "-*- mode: " name-of-mode 949 (insert "-*- mode: " name-of-mode
941 "; default-directory: " (prin1-to-string default-directory) 950 "; default-directory: " (prin1-to-string default-directory)
942 " -*-\n" command "\n") 951 " -*-\n" command "\n") (setq thisdir default-directory))
943 (setq thisdir default-directory))
944 (set-buffer-modified-p nil)) 952 (set-buffer-modified-p nil))
945 ;; If we're already in the compilation buffer, go to the end 953 ;; If we're already in the compilation buffer, go to the end
946 ;; of the buffer, so point will track the compilation output. 954 ;; of the buffer, so point will track the compilation output.
947 (if (eq outbuf (current-buffer)) 955 (if (eq outbuf (current-buffer))
948 (goto-char (point-max))) 956 (goto-char (point-max)))
961 (window-width)))) 969 (window-width))))
962 ;; Set the EMACS variable, but 970 ;; Set the EMACS variable, but
963 ;; don't override users' setting of $EMACS. 971 ;; don't override users' setting of $EMACS.
964 (unless (getenv "EMACS") '("EMACS=t")) 972 (unless (getenv "EMACS") '("EMACS=t"))
965 (copy-sequence process-environment)))) 973 (copy-sequence process-environment))))
966 (if (not (eq mode t))
967 (funcall mode)
968 (setq buffer-read-only nil)
969 (with-no-warnings (comint-mode))
970 (compilation-shell-minor-mode))
971 (if highlight-regexp
972 (set (make-local-variable 'compilation-highlight-regexp)
973 highlight-regexp))
974 (set (make-local-variable 'compilation-arguments) 974 (set (make-local-variable 'compilation-arguments)
975 (list command mode name-function highlight-regexp)) 975 (list command mode name-function highlight-regexp))
976 (set (make-local-variable 'revert-buffer-function) 976 (set (make-local-variable 'revert-buffer-function)
977 'compilation-revert-buffer) 977 'compilation-revert-buffer)
978 (set-window-start outwin (point-min)) 978 (set-window-start outwin (point-min))