aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAugusto Stoffel2022-12-08 21:05:10 +0100
committerJuri Linkov2023-02-27 21:14:41 +0200
commitb699c380286151c97ffae65010d733a092d2db14 (patch)
tree2d0960c7c39237a9c3cc8f92ad4eb154bf70273c
parentb5c13032538377b0037c745715613693a1580f81 (diff)
downloademacs-b699c380286151c97ffae65010d733a092d2db14.tar.gz
emacs-b699c380286151c97ffae65010d733a092d2db14.zip
Introduce 'compilation-annotation' text property
It is meant to mark parts of compilation buffers which do not correspond to process output (bug#59888). * lisp/progmodes/compile.el (compilation-insert-annotation): New function. (compilation-start, compilation-handle-exit): Use it. (compilation--ensure-parse) Rely on 'compilation-annotation' property instead of 'compilation-header-end'.
-rw-r--r--lisp/progmodes/compile.el35
1 files changed, 21 insertions, 14 deletions
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index ccf64fb670b..6d151db8a83 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -1706,7 +1706,7 @@ to `compilation-error-regexp-alist' if RULES is nil."
1706 (set-marker (make-marker) 1706 (set-marker (make-marker)
1707 (save-excursion 1707 (save-excursion
1708 (goto-char (point-min)) 1708 (goto-char (point-min))
1709 (text-property-search-forward 'compilation-header-end) 1709 (text-property-search-forward 'compilation-annotation)
1710 ;; If we have no end marker, this will be 1710 ;; If we have no end marker, this will be
1711 ;; `point-min' still. 1711 ;; `point-min' still.
1712 (point))))) 1712 (point)))))
@@ -1854,6 +1854,14 @@ If nil, don't hide anything."
1854 ;; buffers when it changes from nil to non-nil or vice-versa. 1854 ;; buffers when it changes from nil to non-nil or vice-versa.
1855 (unless compilation-in-progress (force-mode-line-update t))) 1855 (unless compilation-in-progress (force-mode-line-update t)))
1856 1856
1857(defun compilation-insert-annotation (&rest args)
1858 "Insert ARGS at point, adding the `compilation-annotation' text property.
1859This property is used to distinguish output of the compilation
1860process from additional information inserted by Emacs."
1861 (let ((start (point)))
1862 (apply #'insert args)
1863 (put-text-property start (point) 'compilation-annotation t)))
1864
1857;;;###autoload 1865;;;###autoload
1858(defun compilation-start (command &optional mode name-function highlight-regexp 1866(defun compilation-start (command &optional mode name-function highlight-regexp
1859 continue) 1867 continue)
@@ -1975,17 +1983,16 @@ Returns the compilation buffer created."
1975 (setq-local compilation-auto-jump-to-next t)) 1983 (setq-local compilation-auto-jump-to-next t))
1976 (when (zerop (buffer-size)) 1984 (when (zerop (buffer-size))
1977 ;; Output a mode setter, for saving and later reloading this buffer. 1985 ;; Output a mode setter, for saving and later reloading this buffer.
1978 (insert "-*- mode: " name-of-mode 1986 (compilation-insert-annotation
1979 "; default-directory: " 1987 "-*- mode: " name-of-mode
1980 (prin1-to-string (abbreviate-file-name default-directory)) 1988 "; default-directory: "
1981 " -*-\n")) 1989 (prin1-to-string (abbreviate-file-name default-directory))
1982 (insert (format "%s started at %s\n\n" 1990 " -*-\n"))
1983 mode-name 1991 (compilation-insert-annotation
1984 (substring (current-time-string) 0 19)) 1992 (format "%s started at %s\n\n"
1985 command "\n") 1993 mode-name
1986 ;; Mark the end of the header so that we don't interpret 1994 (substring (current-time-string) 0 19))
1987 ;; anything in it as an error. 1995 command "\n")
1988 (put-text-property (1- (point)) (point) 'compilation-header-end t)
1989 (setq thisdir default-directory)) 1996 (setq thisdir default-directory))
1990 (set-buffer-modified-p nil)) 1997 (set-buffer-modified-p nil))
1991 ;; Pop up the compilation buffer. 1998 ;; Pop up the compilation buffer.
@@ -2467,13 +2474,13 @@ commands of Compilation major mode are available. See
2467 (cur-buffer (current-buffer))) 2474 (cur-buffer (current-buffer)))
2468 ;; Record where we put the message, so we can ignore it later on. 2475 ;; Record where we put the message, so we can ignore it later on.
2469 (goto-char omax) 2476 (goto-char omax)
2470 (insert ?\n mode-name " " (car status)) 2477 (compilation-insert-annotation ?\n mode-name " " (car status))
2471 (if (and (numberp compilation-window-height) 2478 (if (and (numberp compilation-window-height)
2472 (zerop compilation-window-height)) 2479 (zerop compilation-window-height))
2473 (message "%s" (cdr status))) 2480 (message "%s" (cdr status)))
2474 (if (bolp) 2481 (if (bolp)
2475 (forward-char -1)) 2482 (forward-char -1))
2476 (insert " at " (substring (current-time-string) 0 19)) 2483 (compilation-insert-annotation " at " (substring (current-time-string) 0 19))
2477 (goto-char (point-max)) 2484 (goto-char (point-max))
2478 ;; Prevent that message from being recognized as a compilation error. 2485 ;; Prevent that message from being recognized as a compilation error.
2479 (add-text-properties omax (point) 2486 (add-text-properties omax (point)