;;; compile.el --- run compiler as inferior of Emacs, parse error messages
;; Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-;; 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+;; 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
;; Free Software Foundation, Inc.
;; Authors: Roland McGrath <roland@gnu.org>,
" in \\([^()\n ]+\\)(\\([0-9]+\\))$" 1 2)
(msft
- ;; AFAWK, The message may be a "warning", "error", or "fatal error".
- "^\\([0-9]+>\\)?\\(\\(?:[a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\)) \
-: \\(?:warnin\\(g\\)\\|[a-z ]+\\) C[0-9]+:" 2 3 nil (4))
+ ;; The message may be a "warning", "error", or "fatal error" with
+ ;; an error code, or "see declaration of" without an error code.
+ "^ *\\([0-9]+>\\)?\\(\\(?:[a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\)) \
+: \\(?:see declaration\\|\\(?:warnin\\(g\\)\\|[a-z ]+\\) C[0-9]+:\\)"
+ 2 3 nil (4))
(omake
;; "omake -P" reports "file foo changed"
(defcustom compilation-read-command t
"Non-nil means \\[compile] reads the compilation command to use.
-Otherwise, \\[compile] just uses the value of `compile-command'."
+Otherwise, \\[compile] just uses the value of `compile-command'.
+
+Note that changing this to nil may be a security risk, because a
+file might define a malicious `compile-command' as a file local
+variable, and you might not notice. Therefore, `compile-command'
+is considered unsafe if this variable is nil."
:type 'boolean
:group 'compilation)
:group 'compilation)
;;;###autoload
-(defcustom compile-command "make -k "
+(defcustom compile-command (purecopy "make -k ")
"Last shell command used to do a compilation; default for next compilation.
Sometimes it is useful for files to supply local values for this variable.
(file-name-sans-extension buffer-file-name))))))"
:type 'string
:group 'compilation)
-;;;###autoload(put 'compile-command 'safe-local-variable 'stringp)
+;;;###autoload(put 'compile-command 'safe-local-variable (lambda (a) (and (stringp a) (or (not (boundp 'compilation-read-command)) compilation-read-command))))
;;;###autoload
(defcustom compilation-disable-input nil
;; another solution is to modify (some?) regexps in
;; `compilation-error-regexp-alist'.
;; note that omake usage is not limited to ocaml and C (for stubs).
- (unless (string-match (concat "^" (regexp-quote "^ *")) pat)
- (setq pat (concat "^ *"
- (if (= ?^ (aref pat 0))
- (substring pat 1)
- pat))))
+ (when (and (= ?^ (aref pat 0)) ; anchored: starts with "^"
+ ;; but does not allow an arbitrary number of leading spaces
+ (not (and (= ? (aref pat 1)) (= ?* (aref pat 2)))))
+ (setq pat (concat "^ *" (substring pat 1))))
(if (consp file) (setq fmt (cdr file) file (car file)))
(if (consp line) (setq end-line (cdr line) line (car line)))
(if (consp col) (setq end-col (cdr col) col (car col)))
;; (`omake -P' polls filesystem for changes and recompiles when needed
;; in the same process and buffer).
;; So, recalculate all markers for that file.
- (unless (and (nth 3 loc) (marker-buffer (nth 3 loc))
- ;; There may be no timestamp info if the loc is a `fake-loc'.
- ;; So we skip the time-check here, although we should maybe
- ;; change `compilation-fake-loc' to add timestamp info.
- (or (null (nth 4 loc))
- (equal (nth 4 loc)
- (setq timestamp
- (with-current-buffer
- (marker-buffer (nth 3 loc))
- (visited-file-modtime))))))
+ (unless (and (nth 3 loc) (marker-buffer (nth 3 loc)) (nthcdr 4 loc)
+ ;; There may be no timestamp info if the loc is a `fake-loc',
+ ;; but we just checked that the file has been visited before!
+ (equal (nth 4 loc)
+ (setq timestamp
+ (with-current-buffer (marker-buffer (nth 3 loc))
+ (visited-file-modtime)))))
(with-current-buffer (compilation-find-file marker (caar (nth 2 loc))
(cadr (car (nth 2 loc))))
(save-restriction
(if (window-dedicated-p (selected-window))
(pop-to-buffer (marker-buffer mk))
(switch-to-buffer (marker-buffer mk))))
- ;; If narrowing gets in the way of going to the right place, widen.
(unless (eq (goto-char mk) (point))
+ ;; If narrowing gets in the way of going to the right place, widen.
(widen)
- (goto-char mk))
+ (if next-error-move-function
+ (funcall next-error-move-function msg mk)
+ (goto-char mk)))
(if end-mk
(push-mark end-mk t)
(if mark-active (setq mark-active)))
(goto-char limit)
nil)
-;; Beware: this is not only compatiblity code. New code stil uses it. --Stef
+;; Beware: this is not only compatibility code. New code stil uses it. --Stef
(defun compilation-forget-errors ()
;; In case we hit the same file/line specs, we want to recompute a new
;; marker for them, so flush our cache.
(eq compilation-scroll-output 'first-error))))
;;;###autoload
-(add-to-list 'auto-mode-alist '("\\.gcov\\'" . compilation-mode))
+(add-to-list 'auto-mode-alist (cons (purecopy "\\.gcov\\'") 'compilation-mode))
(provide 'compile)