From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: JD Smith Newsgroups: gmane.emacs.bugs Subject: bug#57883: compilation-get-file-structure mishandles buffers Date: Sun, 3 Sep 2023 09:36:16 -0400 Message-ID: <18051D5E-0D75-410C-A89C-2BF92BD0C471@gmail.com> References: <87edw93qa6.fsf@gnus.org> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_013DBD16-1BA7-45C4-9DF3-8555120A5FFF" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4287"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Lars Ingebrigtsen , 57883-done@debbugs.gnu.org To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Sep 03 15:37:07 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qcnHl-0000vk-Um for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 03 Sep 2023 15:37:06 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcnHZ-0003m3-7z; Sun, 03 Sep 2023 09:36:53 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qcnHY-0003lc-3O for bug-gnu-emacs@gnu.org; Sun, 03 Sep 2023 09:36:52 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcnHX-0003V4-RU for bug-gnu-emacs@gnu.org; Sun, 03 Sep 2023 09:36:51 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qcnHi-0001jC-5k for bug-gnu-emacs@gnu.org; Sun, 03 Sep 2023 09:37:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: JD Smith Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 03 Sep 2023 13:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57883 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 57883-done@debbugs.gnu.org id=D57883.16937482136627 (code D ref 57883); Sun, 03 Sep 2023 13:37:02 +0000 Original-Received: (at 57883-done) by debbugs.gnu.org; 3 Sep 2023 13:36:53 +0000 Original-Received: from localhost ([127.0.0.1]:40017 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcnHX-0001in-Hw for submit@debbugs.gnu.org; Sun, 03 Sep 2023 09:36:53 -0400 Original-Received: from mail-yw1-x1135.google.com ([2607:f8b0:4864:20::1135]:60524) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcnHT-0001iV-9p for 57883-done@debbugs.gnu.org; Sun, 03 Sep 2023 09:36:49 -0400 Original-Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-58fc4eaa04fso6103547b3.0 for <57883-done@debbugs.gnu.org>; Sun, 03 Sep 2023 06:36:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693748191; x=1694352991; darn=debbugs.gnu.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=g5S5Oq5eZajBR5tOxyNwE10f7H5GGNkIgTRNNo0RZT8=; b=VbFshjXaki3FPQnkxdXmfCYVxddeETHL8MECewx4Wm3r9SpMxM5z+VXqe0iBpCPcSX +xMMLNKnm75YXzyT/wRaM+o4NpeZKFnVNsUKQh/IsNSGUQootsrvt1q6rmMS8j9OQmVx hT7c0B0L/YvwVFvB1Weshc1HU4kvc5TLQqzSmBLGqtuBb3K7eAf0Au2zt8/x4iF7VExy dYPhfmV1oAdD+8yDU3OqmixlPAGiTDaNe1fRA1UBuOlGzRsIFdmM/5AUgKGBJoFHVdfu M7jolBA14yUsXF1mm7G4Ai0Jds88/hGfwGlWQYa4x+zu6vRVgzpvRVXalDjoDiRH3/eD 3N6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693748191; x=1694352991; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=g5S5Oq5eZajBR5tOxyNwE10f7H5GGNkIgTRNNo0RZT8=; b=K6gfHLfeS4/M3fC0twAsrwcKalD5P0oZ9BFDMqCrwwUZEfbtvCgEt/sZE1IMIskxfm Ky7ZstDNS/EI8umDwfL8hBDYRDuH6JStz+8GVg8+h9L/6z5pmccDcfDOYkbCZX0SLjT4 A7c1Jf4g9eRdQS498Akb98qnXteWF6I5UAN5GbXIN0RUaKKcsji69eDkgoG85d4BhEcO xB3DxlJCus3Ct+/hQMuIhld0miLjXWC656C7jBtfAzNuFWstbeSlha3Kf11MCn4T3iHo NRr1+NycVCdlDrpd8XFig/8bH/mN4edm1A1ezipB7eQF6aIk6njUuUaO0prS45hc3d6i 17dA== X-Gm-Message-State: AOJu0YwaTM5+IBrWuGvTlBc0yNJteDsQ0vOKl/jR6jjhTL8CYP3lpN/T J7Jc+D4GdTrFzHyEzk/QH/WvOPCx/zA= X-Google-Smtp-Source: AGHT+IGpoIdKvJMT2SZn3+Cdm1WjpqZNlU6s+ls77tvNah3kP3Slm4sidfXhu7+BBqqiTpZgyxCX+A== X-Received: by 2002:a05:690c:c0e:b0:595:89b0:6b41 with SMTP id cl14-20020a05690c0c0e00b0059589b06b41mr9024181ywb.38.1693748190916; Sun, 03 Sep 2023 06:36:30 -0700 (PDT) Original-Received: from smtpclient.apple (cm-24-53-187-34.buckeyecom.net. [24.53.187.34]) by smtp.gmail.com with ESMTPSA id v139-20020a814891000000b0058c55d40765sm2109712ywa.106.2023.09.03.06.36.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Sep 2023 06:36:30 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3731.700.6) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:269163 Archived-At: --Apple-Mail=_013DBD16-1BA7-45C4-9DF3-8555120A5FFF Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Thanks for the query. This is still an issue in Emacs 29 with emacs -Q. = =20 Short summary: `compilation-error-regexp-alist=E2=80=99 explicitly = allows returning *buffers* from a specified file-name function . But = parsing errors using such a buffer-returning function fails, since = `compilation-get-file-structure=E2=80=99 explicitly assumes that a file = name is returned, checking it with `file-name-absolute-p=E2=80=99. In = my code I=E2=80=99ve worked around this bug by cl-letf=E2=80=99ing the = `file-name-absolute-p=E2=80=99 function like: (defun my/traceback--file-name-absolute-p (file-or-buffer) "A patch for `file-name-absolute-p' to handle buffer names. `compilation-get-file-structure' has a bug in which it calls `file-name-absolute-p' on a file parsed from an error, which explicitly allows FILE-OR-BUFFER to be a buffer." (and (not (bufferp file-or-buffer)) (funcall #=E2=80=99my/traceback--orig-file-name-absolute-p = file-or-buffer))) Reproducer: The reproduction recipe was in the linked emacs-devel = = thread. Here it is again (with Emacs 29 updates in [brackets]): ++++ Reproducing is fairly straightforward. First, evaluate this simple = =E2=80=9Cerror line=E2=80=9D pattern: (defun my/filename-function () (list (get-buffer (match-string 1)))) (defvar my/compilation-error-regexp `((,(rx line-start=20 "Buffer \"" (group (+ (not "\""))) "\", " ; 1: buffer name "line" (+ space) (group (+ digit)) ; 2: line (* nonl) ?\n) my/filename-function 2 nil nil 1))) Then, in a buffer like *compile* put the following fake error for it to = match (including a final newline): Buffer "*scratch*", line 2 In that buffer, evaluate (e.g. via M-:): (progn (compilation-setup) (setq compilation-error-regexp-alist my/compilation-error-regexp) (compilation-parse-errors (point-min) (point-max))) You should see error 1.) pertaining to searching the (nil) filename for = /bin/sh (which may have been fixed in Emacs 28 already). [Emacs 29 = update: it has] [Update: This step is unnecessary in emacs 29] Now, let=E2=80=99s = eliminate that error by evaluating (again in *compile*): (setq compilation-transform-file-match-alist nil) To stop the transform check. Now evaluate again: (compilation-parse-errors (point-min) (point-max)) and you will see a different error (2.) from = `compilation-get-file-structure', which does not appreciate being handed = a buffer instead of a file, despite the documented validity of this = input: Debugger entered--Lisp error: (wrong-type-argument stringp #) #(#) apply(# #) #f(compiled-function (body &rest args) #)(# #) apply(#f(compiled-function (body &rest args) #) # #) file-name-absolute-p(#) compilation-get-file-structure((#) nil) compilation-internal-error-properties((#) 2 nil nil = nil 2 nil nil) compilation-error-properties(my/filename-function 2 nil nil nil 2 nil = nil) (setq props (compilation-error-properties file line end-line col = end-col (or type 2) fmt rule)) (if (setq props (compilation-error-properties file line end-line col = end-col (or type 2) fmt rule)) (progn (if file (progn (let ((this-type = (if ... ... ...))) (compilation--note-type this-type) = (compilation--put-prop file 'font-lock-face (symbol-value (aref ... = this-type)))))) (compilation--put-prop line 'font-lock-face = compilation-line-face) (compilation--put-prop end-line 'font-lock-face = compilation-line-face) (compilation--put-prop col 'font-lock-face = compilation-column-face) (compilation--put-prop end-col 'font-lock-face = compilation-column-face) (let ((tail (nthcdr 6 item))) (while tail (let = ((extra-item (car tail))) (let ((mn ...)) (if (match-beginning mn) = (progn ...))) (setq tail (cdr tail))))) (let ((mn (or (nth 5 item) 0))) = (if compilation-debug (progn (font-lock-append-text-property = (match-beginning 0) (match-end 0) 'compilation-debug (vector 'std item = props)))) (add-text-properties (match-beginning mn) (match-end mn) (cdr = (cdr props))) (font-lock-append-text-property (match-beginning mn) = (match-end mn) 'font-lock-face (car (cdr props)))))) (while (and pat (re-search-forward pat end t)) (if (setq props = (compilation-error-properties file line end-line col end-col (or type 2) = fmt rule)) (progn (if file (progn (let ((this-type ...)) = (compilation--note-type this-type) (compilation--put-prop file = 'font-lock-face (symbol-value ...))))) (compilation--put-prop line = 'font-lock-face compilation-line-face) (compilation--put-prop end-line = 'font-lock-face compilation-line-face) (compilation--put-prop col = 'font-lock-face compilation-column-face) (compilation--put-prop end-col = 'font-lock-face compilation-column-face) (let ((tail (nthcdr 6 item))) = (while tail (let ((extra-item ...)) (let (...) (if ... ...)) (setq tail = (cdr tail))))) (let ((mn (or (nth 5 item) 0))) (if compilation-debug = (progn (font-lock-append-text-property (match-beginning 0) (match-end 0) = 'compilation-debug (vector ... item props)))) (add-text-properties = (match-beginning mn) (match-end mn) (cdr (cdr props))) = (font-lock-append-text-property (match-beginning mn) (match-end mn) = 'font-lock-face (car (cdr props))))))) (let* ((item (if (symbolp rule-item) (cdr (assq rule-item = compilation-error-regexp-alist-alist)) rule-item)) (pat (car item)) = (file (nth 1 item)) (line (nth 2 item)) (col (nth 3 item)) (type (nth 4 = item)) (rule (and (symbolp rule-item) rule-item)) end-line end-col fmt = props) (cond ((or (not omake-included) (not pat)) nil) ((string-match = "\\`\\([^^]\\|\\^\\( \\*\\|\\[\\)\\)" pat) nil) (t (setq pat (concat = "^\\(?: \\)?" (substring pat 1))))) (if (and (consp file) (not = (functionp file))) (progn (setq fmt (cdr file)) (setq file (car file)))) = (if (and (consp line) (not (functionp line))) (progn (setq end-line (cdr = line)) (setq line (car line)))) (if (and (consp col) (not (functionp = col))) (progn (setq end-col (cdr col)) (setq col (car col)))) (if (or = (null (nth 5 item)) (integerp (nth 5 item))) nil (error "HYPERLINK = should be an integer: %s" (nth 5 item))) (goto-char start) (while (and = pat (re-search-forward pat end t)) (if (setq props = (compilation-error-properties file line end-line col end-col (or type 2) = fmt rule)) (progn (if file (progn (let (...) (compilation--note-type = this-type) (compilation--put-prop file ... ...)))) = (compilation--put-prop line 'font-lock-face compilation-line-face) = (compilation--put-prop end-line 'font-lock-face compilation-line-face) = (compilation--put-prop col 'font-lock-face compilation-column-face) = (compilation--put-prop end-col 'font-lock-face compilation-column-face) = (let ((tail (nthcdr 6 item))) (while tail (let (...) (let ... ...) (setq = tail ...)))) (let ((mn (or ... 0))) (if compilation-debug (progn = (font-lock-append-text-property ... ... ... ...))) (add-text-properties = (match-beginning mn) (match-end mn) (cdr (cdr props))) = (font-lock-append-text-property (match-beginning mn) (match-end mn) = 'font-lock-face (car (cdr props)))))))) (let ((rule-item (car tail))) (let* ((item (if (symbolp rule-item) = (cdr (assq rule-item compilation-error-regexp-alist-alist)) rule-item)) = (pat (car item)) (file (nth 1 item)) (line (nth 2 item)) (col (nth 3 = item)) (type (nth 4 item)) (rule (and (symbolp rule-item) rule-item)) = end-line end-col fmt props) (cond ((or (not omake-included) (not pat)) = nil) ((string-match "\\`\\([^^]\\|\\^\\( \\*\\|\\[\\)\\)" pat) nil) (t = (setq pat (concat "^\\(?: \\)?" (substring pat 1))))) (if (and = (consp file) (not (functionp file))) (progn (setq fmt (cdr file)) (setq = file (car file)))) (if (and (consp line) (not (functionp line))) (progn = (setq end-line (cdr line)) (setq line (car line)))) (if (and (consp col) = (not (functionp col))) (progn (setq end-col (cdr col)) (setq col (car = col)))) (if (or (null (nth 5 item)) (integerp (nth 5 item))) nil (error = "HYPERLINK should be an integer: %s" (nth 5 item))) (goto-char start) = (while (and pat (re-search-forward pat end t)) (if (setq props = (compilation-error-properties file line end-line col end-col (or type 2) = fmt rule)) (progn (if file (progn (let ... ... ...))) = (compilation--put-prop line 'font-lock-face compilation-line-face) = (compilation--put-prop end-line 'font-lock-face compilation-line-face) = (compilation--put-prop col 'font-lock-face compilation-column-face) = (compilation--put-prop end-col 'font-lock-face compilation-column-face) = (let ((tail ...)) (while tail (let ... ... ...))) (let ((mn ...)) (if = compilation-debug (progn ...)) (add-text-properties (match-beginning mn) = (match-end mn) (cdr ...)) (font-lock-append-text-property = (match-beginning mn) (match-end mn) 'font-lock-face (car ...))))))) = (setq tail (cdr tail))) (while tail (let ((rule-item (car tail))) (let* ((item (if (symbolp = rule-item) (cdr (assq rule-item compilation-error-regexp-alist-alist)) = rule-item)) (pat (car item)) (file (nth 1 item)) (line (nth 2 item)) = (col (nth 3 item)) (type (nth 4 item)) (rule (and (symbolp rule-item) = rule-item)) end-line end-col fmt props) (cond ((or (not omake-included) = (not pat)) nil) ((string-match "\\`\\([^^]\\|\\^\\( \\*\\|\\[\\)\\)" = pat) nil) (t (setq pat (concat "^\\(?: \\)?" (substring pat 1))))) = (if (and (consp file) (not (functionp file))) (progn (setq fmt (cdr = file)) (setq file (car file)))) (if (and (consp line) (not (functionp = line))) (progn (setq end-line (cdr line)) (setq line (car line)))) (if = (and (consp col) (not (functionp col))) (progn (setq end-col (cdr col)) = (setq col (car col)))) (if (or (null (nth 5 item)) (integerp (nth 5 = item))) nil (error "HYPERLINK should be an integer: %s" (nth 5 item))) = (goto-char start) (while (and pat (re-search-forward pat end t)) (if = (setq props (compilation-error-properties file line end-line col end-col = (or type 2) fmt rule)) (progn (if file (progn ...)) = (compilation--put-prop line 'font-lock-face compilation-line-face) = (compilation--put-prop end-line 'font-lock-face compilation-line-face) = (compilation--put-prop col 'font-lock-face compilation-column-face) = (compilation--put-prop end-col 'font-lock-face compilation-column-face) = (let (...) (while tail ...)) (let (...) (if compilation-debug ...) = (add-text-properties ... ... ...) (font-lock-append-text-property ... = ... ... ...)))))) (setq tail (cdr tail)))) (let ((tail (or rules compilation-error-regexp-alist))) (while tail = (let ((rule-item (car tail))) (let* ((item (if (symbolp rule-item) (cdr = ...) rule-item)) (pat (car item)) (file (nth 1 item)) (line (nth 2 = item)) (col (nth 3 item)) (type (nth 4 item)) (rule (and (symbolp = rule-item) rule-item)) end-line end-col fmt props) (cond ((or (not = omake-included) (not pat)) nil) ((string-match "\\`\\([^^]\\|\\^\\( = \\*\\|\\[\\)\\)" pat) nil) (t (setq pat (concat "^\\(?: \\)?" = ...)))) (if (and (consp file) (not (functionp file))) (progn (setq fmt = (cdr file)) (setq file (car file)))) (if (and (consp line) (not = (functionp line))) (progn (setq end-line (cdr line)) (setq line (car = line)))) (if (and (consp col) (not (functionp col))) (progn (setq = end-col (cdr col)) (setq col (car col)))) (if (or (null (nth 5 item)) = (integerp (nth 5 item))) nil (error "HYPERLINK should be an integer: %s" = (nth 5 item))) (goto-char start) (while (and pat (re-search-forward pat = end t)) (if (setq props (compilation-error-properties file line end-line = col end-col ... fmt rule)) (progn (if file ...) (compilation--put-prop = line ... compilation-line-face) (compilation--put-prop end-line ... = compilation-line-face) (compilation--put-prop col ... = compilation-column-face) (compilation--put-prop end-col ... = compilation-column-face) (let ... ...) (let ... ... ... ...))))) (setq = tail (cdr tail))))) (let ((case-fold-search compilation-error-case-fold-search) = (omake-included (memq 'omake compilation-error-regexp-alist))) (let = ((tail (or rules compilation-error-regexp-alist))) (while tail (let = ((rule-item (car tail))) (let* ((item (if ... ... rule-item)) (pat (car = item)) (file (nth 1 item)) (line (nth 2 item)) (col (nth 3 item)) (type = (nth 4 item)) (rule (and ... rule-item)) end-line end-col fmt props) = (cond ((or ... ...) nil) ((string-match "\\`\\([^^]\\|\\^\\( = \\*\\|\\[\\)\\)" pat) nil) (t (setq pat ...))) (if (and (consp file) = (not ...)) (progn (setq fmt ...) (setq file ...))) (if (and (consp line) = (not ...)) (progn (setq end-line ...) (setq line ...))) (if (and (consp = col) (not ...)) (progn (setq end-col ...) (setq col ...))) (if (or (null = ...) (integerp ...)) nil (error "HYPERLINK should be an integer: %s" = (nth 5 item))) (goto-char start) (while (and pat (re-search-forward pat = end t)) (if (setq props ...) (progn ... ... ... ... ... ... ...)))) = (setq tail (cdr tail)))))) compilation-parse-errors(1 28) eval-expression((compilation-parse-errors (point-min) (point-max)) nil = nil 127) funcall-interactively(eval-expression (compilation-parse-errors = (point-min) (point-max)) nil nil 127) command-execute(eval-expression) +++ > On Sep 3, 2023, at 5:18 AM, Stefan Kangas = wrote: >=20 > Lars Ingebrigtsen writes: >=20 >> JD Smith writes: >>=20 >>> Note that this is useful for modes which report errors in text from = open buffers, which >>> may have no associated file. The issue is this line in = `compilation-get-file-structure=E2=80=99: >>>=20 >>> (if (file-name-absolute-p filename) >>> (setq filename (concat comint-file-name-prefix filename))) >>> which signals an >>=20 >> This is how your email ended, so I think your message may have been = cut >> off? >>=20 >> In any case, do you have a recipe to reproduce the problem, starting >> from "emacs -Q"? >=20 > More information was requested, but none was given within 12 months, = so > I'm closing this bug. >=20 > If this is still an issue, please reply to this email (use "Reply to > all" in your email client) and we can reopen the bug report. --Apple-Mail=_013DBD16-1BA7-45C4-9DF3-8555120A5FFF Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Thanks for the = query.  This is still an issue in Emacs 29 with emacs -Q. =  

Short summary: = `compilation-error-regexp-alist=E2=80=99 explicitly allows returning = *buffers* from a specified file-name function .  But parsing errors = using such a buffer-returning function fails, since `compilation-get-file-structure=E2=80=99 explicitly assumes = that a file name is returned, checking it with `file-name-absolute-p=E2=80= =99.  In my code I=E2=80=99ve worked around this bug by = cl-letf=E2=80=99ing the `file-name-absolute-p=E2=80=99 = function like:

(defun = my/traceback--file-name-absolute-p (file-or-buffer)
  "A = patch for `file-name-absolute-p' to handle buffer = names.
`compilation-get-file-structure' has a bug in which it = calls
`file-name-absolute-p' on a file parsed from an error, = which
explicitly allows FILE-OR-BUFFER to be a = buffer."
  (and (not (bufferp = file-or-buffer))
       (funcall = #=E2=80=99my/traceback--orig-file-name-absolute-p = file-or-buffer)))

Reproducer: The = reproduction recipe was in the linked emacs-devel thread.  Here it is again (with = Emacs 29 updates in = [brackets]):

++++

Reproducing is = fairly straightforward.  First, evaluate this simple =E2=80=9Cerror = line=E2=80=9D pattern:

(defun = my/filename-function () (list (get-buffer (match-string = 1))))
(defvar = my/compilation-error-regexp
  `((,(rx = line-start 
  "Buffer \"" (group (+ (not "\""))) "\", " ; = 1: buffer name
=   "line" (+ space) (group (+ digit)) =     ; 2: = line
=   (* nonl) = ?\n)
    =  my/filename-function
    =  2
     nil nil = 1)))

Then, in a = buffer like *compile* put the following fake error for it to match = (including a final newline):

Buffer = "*scratch*", line 2

In that buffer, evaluate (e.g. via = M-:):

(progn = (compilation-setup)
       (setq compilation-error-regexp-alist = my/compilation-error-regexp)
      =  (compilation-parse-errors (point-min) = (point-max)))

You should see error 1.) pertaining = to searching the (nil) filename for /bin/sh (which may have been fixed = in Emacs 28 already). [Emacs 29 update: it has]

[Update: This = step is unnecessary in emacs 29] Now, let=E2=80=99s eliminate that error = by evaluating (again in *compile*):

(setq compilation-transform-file-match-alist = nil)

To stop the transform check.  Now evaluate = again:

(compilation-parse-errors = (point-min) (point-max))

and you will = see a different error (2.) from `compilation-get-file-structure', which = does not appreciate being handed a buffer instead of a file, despite the = documented validity of this = input:

Debugger entered--Lisp error: = (wrong-type-argument stringp #<buffer *scratch*>)
  = #<subr file-name-absolute-p>(#<buffer = *scratch*>)
  apply(#<subr file-name-absolute-p> = #<buffer *scratch*>)
  #f(compiled-function (body = &rest args) #<bytecode 0x1a0bc3925a352795>)(#<subr = file-name-absolute-p> #<buffer *scratch*>)
  = apply(#f(compiled-function (body &rest args) #<bytecode = 0x1a0bc3925a352795>) #<subr file-name-absolute-p> #<buffer = *scratch*>)
  file-name-absolute-p(#<buffer = *scratch*>)
  = compilation-get-file-structure((#<buffer *scratch*>) = nil)
  compilation-internal-error-properties((#<buffer = *scratch*>) 2 nil nil nil 2 nil nil)
  = compilation-error-properties(my/filename-function 2 nil nil nil 2 nil = nil)
  (setq props (compilation-error-properties file = line end-line col end-col (or type 2) fmt rule))
  (if = (setq props (compilation-error-properties file line end-line col end-col = (or type 2) fmt rule)) (progn (if file (progn (let ((this-type (if ... = ... ...))) (compilation--note-type this-type) (compilation--put-prop = file 'font-lock-face (symbol-value (aref ... this-type)))))) = (compilation--put-prop line 'font-lock-face compilation-line-face) = (compilation--put-prop end-line 'font-lock-face compilation-line-face) = (compilation--put-prop col 'font-lock-face compilation-column-face) = (compilation--put-prop end-col 'font-lock-face compilation-column-face) = (let ((tail (nthcdr 6 item))) (while tail (let ((extra-item (car tail))) = (let ((mn ...)) (if (match-beginning mn) (progn ...))) (setq tail (cdr = tail))))) (let ((mn (or (nth 5 item) 0))) (if compilation-debug (progn = (font-lock-append-text-property (match-beginning 0) (match-end 0) = 'compilation-debug (vector 'std item props)))) (add-text-properties = (match-beginning mn) (match-end mn) (cdr (cdr props))) = (font-lock-append-text-property (match-beginning mn) (match-end mn) = 'font-lock-face (car (cdr props))))))
  (while (and pat = (re-search-forward pat end t)) (if (setq props = (compilation-error-properties file line end-line col end-col (or type 2) = fmt rule)) (progn (if file (progn (let ((this-type ...)) = (compilation--note-type this-type) (compilation--put-prop file = 'font-lock-face (symbol-value ...))))) (compilation--put-prop line = 'font-lock-face compilation-line-face) (compilation--put-prop end-line = 'font-lock-face compilation-line-face) (compilation--put-prop col = 'font-lock-face compilation-column-face) (compilation--put-prop end-col = 'font-lock-face compilation-column-face) (let ((tail (nthcdr 6 item))) = (while tail (let ((extra-item ...)) (let (...) (if ... ...)) (setq tail = (cdr tail))))) (let ((mn (or (nth 5 item) 0))) (if compilation-debug = (progn (font-lock-append-text-property (match-beginning 0) (match-end 0) = 'compilation-debug (vector ... item props)))) (add-text-properties = (match-beginning mn) (match-end mn) (cdr (cdr props))) = (font-lock-append-text-property (match-beginning mn) (match-end mn) = 'font-lock-face (car (cdr props)))))))
  (let* ((item (if = (symbolp rule-item) (cdr (assq rule-item = compilation-error-regexp-alist-alist)) rule-item)) (pat (car item)) = (file (nth 1 item)) (line (nth 2 item)) (col (nth 3 item)) (type (nth 4 = item)) (rule (and (symbolp rule-item) rule-item)) end-line end-col fmt = props) (cond ((or (not omake-included) (not pat)) nil) ((string-match = "\\`\\([^^]\\|\\^\\( \\*\\|\\[\\)\\)" pat) nil) (t (setq pat (concat = "^\\(?:      \\)?" (substring pat 1))))) (if (and (consp = file) (not (functionp file))) (progn (setq fmt (cdr file)) (setq file = (car file)))) (if (and (consp line) (not (functionp line))) (progn (setq = end-line (cdr line)) (setq line (car line)))) (if (and (consp col) (not = (functionp col))) (progn (setq end-col (cdr col)) (setq col (car col)))) = (if (or (null (nth 5 item)) (integerp (nth 5 item))) nil (error = "HYPERLINK should be an integer: %s" (nth 5 item))) (goto-char start) = (while (and pat (re-search-forward pat end t)) (if (setq props = (compilation-error-properties file line end-line col end-col (or type 2) = fmt rule)) (progn (if file (progn (let (...) (compilation--note-type = this-type) (compilation--put-prop file ... ...)))) = (compilation--put-prop line 'font-lock-face compilation-line-face) = (compilation--put-prop end-line 'font-lock-face compilation-line-face) = (compilation--put-prop col 'font-lock-face compilation-column-face) = (compilation--put-prop end-col 'font-lock-face compilation-column-face) = (let ((tail (nthcdr 6 item))) (while tail (let (...) (let ... ...) (setq = tail ...)))) (let ((mn (or ... 0))) (if compilation-debug (progn = (font-lock-append-text-property ... ... ... ...))) (add-text-properties = (match-beginning mn) (match-end mn) (cdr (cdr props))) = (font-lock-append-text-property (match-beginning mn) (match-end mn) = 'font-lock-face (car (cdr props))))))))
  (let = ((rule-item (car tail))) (let* ((item (if (symbolp rule-item) (cdr (assq = rule-item compilation-error-regexp-alist-alist)) rule-item)) (pat (car = item)) (file (nth 1 item)) (line (nth 2 item)) (col (nth 3 item)) (type = (nth 4 item)) (rule (and (symbolp rule-item) rule-item)) end-line = end-col fmt props) (cond ((or (not omake-included) (not pat)) nil) = ((string-match "\\`\\([^^]\\|\\^\\( \\*\\|\\[\\)\\)" pat) nil) (t (setq = pat (concat "^\\(?:      \\)?" (substring pat 1))))) (if = (and (consp file) (not (functionp file))) (progn (setq fmt (cdr file)) = (setq file (car file)))) (if (and (consp line) (not (functionp line))) = (progn (setq end-line (cdr line)) (setq line (car line)))) (if (and = (consp col) (not (functionp col))) (progn (setq end-col (cdr col)) (setq = col (car col)))) (if (or (null (nth 5 item)) (integerp (nth 5 item))) = nil (error "HYPERLINK should be an integer: %s" (nth 5 item))) = (goto-char start) (while (and pat (re-search-forward pat end t)) (if = (setq props (compilation-error-properties file line end-line col end-col = (or type 2) fmt rule)) (progn (if file (progn (let ... ... ...))) = (compilation--put-prop line 'font-lock-face compilation-line-face) = (compilation--put-prop end-line 'font-lock-face compilation-line-face) = (compilation--put-prop col 'font-lock-face compilation-column-face) = (compilation--put-prop end-col 'font-lock-face compilation-column-face) = (let ((tail ...)) (while tail (let ... ... ...))) (let ((mn ...)) (if = compilation-debug (progn ...)) (add-text-properties (match-beginning mn) = (match-end mn) (cdr ...)) (font-lock-append-text-property = (match-beginning mn) (match-end mn) 'font-lock-face (car ...))))))) = (setq tail (cdr tail)))
  (while tail (let ((rule-item = (car tail))) (let* ((item (if (symbolp rule-item) (cdr (assq rule-item = compilation-error-regexp-alist-alist)) rule-item)) (pat (car item)) = (file (nth 1 item)) (line (nth 2 item)) (col (nth 3 item)) (type (nth 4 = item)) (rule (and (symbolp rule-item) rule-item)) end-line end-col fmt = props) (cond ((or (not omake-included) (not pat)) nil) ((string-match = "\\`\\([^^]\\|\\^\\( \\*\\|\\[\\)\\)" pat) nil) (t (setq pat (concat = "^\\(?:      \\)?" (substring pat 1))))) (if (and (consp = file) (not (functionp file))) (progn (setq fmt (cdr file)) (setq file = (car file)))) (if (and (consp line) (not (functionp line))) (progn (setq = end-line (cdr line)) (setq line (car line)))) (if (and (consp col) (not = (functionp col))) (progn (setq end-col (cdr col)) (setq col (car col)))) = (if (or (null (nth 5 item)) (integerp (nth 5 item))) nil (error = "HYPERLINK should be an integer: %s" (nth 5 item))) (goto-char start) = (while (and pat (re-search-forward pat end t)) (if (setq props = (compilation-error-properties file line end-line col end-col (or type 2) = fmt rule)) (progn (if file (progn ...)) (compilation--put-prop line = 'font-lock-face compilation-line-face) (compilation--put-prop end-line = 'font-lock-face compilation-line-face) (compilation--put-prop col = 'font-lock-face compilation-column-face) (compilation--put-prop end-col = 'font-lock-face compilation-column-face) (let (...) (while tail ...)) = (let (...) (if compilation-debug ...) (add-text-properties ... ... ...) = (font-lock-append-text-property ... ... ... ...)))))) (setq tail (cdr = tail))))
  (let ((tail (or rules = compilation-error-regexp-alist))) (while tail (let ((rule-item (car = tail))) (let* ((item (if (symbolp rule-item) (cdr ...) rule-item)) (pat = (car item)) (file (nth 1 item)) (line (nth 2 item)) (col (nth 3 item)) = (type (nth 4 item)) (rule (and (symbolp rule-item) rule-item)) end-line = end-col fmt props) (cond ((or (not omake-included) (not pat)) nil) = ((string-match "\\`\\([^^]\\|\\^\\( \\*\\|\\[\\)\\)" pat) nil) (t (setq = pat (concat "^\\(?:      \\)?" ...)))) (if (and (consp = file) (not (functionp file))) (progn (setq fmt (cdr file)) (setq file = (car file)))) (if (and (consp line) (not (functionp line))) (progn (setq = end-line (cdr line)) (setq line (car line)))) (if (and (consp col) (not = (functionp col))) (progn (setq end-col (cdr col)) (setq col (car col)))) = (if (or (null (nth 5 item)) (integerp (nth 5 item))) nil (error = "HYPERLINK should be an integer: %s" (nth 5 item))) (goto-char start) = (while (and pat (re-search-forward pat end t)) (if (setq props = (compilation-error-properties file line end-line col end-col ... fmt = rule)) (progn (if file ...) (compilation--put-prop line ... = compilation-line-face) (compilation--put-prop end-line ... = compilation-line-face) (compilation--put-prop col ... = compilation-column-face) (compilation--put-prop end-col ... = compilation-column-face) (let ... ...) (let ... ... ... ...))))) (setq = tail (cdr tail)))))
  (let ((case-fold-search = compilation-error-case-fold-search) (omake-included (memq 'omake = compilation-error-regexp-alist))) (let ((tail (or rules = compilation-error-regexp-alist))) (while tail (let ((rule-item (car = tail))) (let* ((item (if ... ... rule-item)) (pat (car item)) (file (nth = 1 item)) (line (nth 2 item)) (col (nth 3 item)) (type (nth 4 item)) = (rule (and ... rule-item)) end-line end-col fmt props) (cond ((or ... = ...) nil) ((string-match "\\`\\([^^]\\|\\^\\( \\*\\|\\[\\)\\)" pat) nil) = (t (setq pat ...))) (if (and (consp file) (not ...)) (progn (setq fmt = ...) (setq file ...))) (if (and (consp line) (not ...)) (progn (setq = end-line ...) (setq line ...))) (if (and (consp col) (not ...)) (progn = (setq end-col ...) (setq col ...))) (if (or (null ...) (integerp ...)) = nil (error "HYPERLINK should be an integer: %s" (nth 5 item))) = (goto-char start) (while (and pat (re-search-forward pat end t)) (if = (setq props ...) (progn ... ... ... ... ... ... ...)))) (setq tail (cdr = tail))))))
  compilation-parse-errors(1 = 28)
  eval-expression((compilation-parse-errors = (point-min) (point-max)) nil nil 127)
  = funcall-interactively(eval-expression (compilation-parse-errors = (point-min) (point-max)) nil nil 127)
  = command-execute(eval-expression)

+++
On Sep 3, 2023, at 5:18 AM, Stefan = Kangas <stefankangas@gmail.com> wrote:

Lars Ingebrigtsen = <larsi@gnus.org> writes:

JD Smith = <jdtsmith@gmail.com> writes:

Note = that this is useful for modes which report errors in text from open = buffers, which
may have no associated file.   The issue is = this line in `compilation-get-file-structure=E2=80=99:

(if = (file-name-absolute-p filename)
  (setq filename (concat = comint-file-name-prefix filename)))
which signals = an

This is how your email ended, so I think your = message may have been cut
off?

In any case, do you have a = recipe to reproduce the problem, starting
from "emacs = -Q"?

More information was requested, but none was = given within 12 months, so
I'm closing this bug.

If this is = still an issue, please reply to this email (use "Reply to
all" in = your email client) and we can reopen the bug = report.

= --Apple-Mail=_013DBD16-1BA7-45C4-9DF3-8555120A5FFF--