From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Daniel =?UTF-8?Q?Mart=C3=ADn?= via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#64198: Feature request: compile.el's "Find this in" prompt should be hookable. Date: Thu, 22 Jun 2023 19:58:43 +0200 Message-ID: References: <837crx5a8x.fsf@gnu.org> <03EC2FC3-A297-4CD1-91FB-2262A319A6F3@boostpro.com> <83ilbf2zx6.fsf@gnu.org> <3D7A63CD-5B7B-412A-8C55-90EFFA294F09@boostpro.com> Reply-To: Daniel =?UTF-8?Q?Mart=C3=ADn?= Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5843"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (darwin) Cc: Eli Zaretskii , 64198@debbugs.gnu.org To: Dave Abrahams Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jun 22 19:59:20 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 1qCOaU-0001C5-34 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 22 Jun 2023 19:59:18 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qCOaG-0007Th-32; Thu, 22 Jun 2023 13:59:04 -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 1qCOaE-0007SF-Ch for bug-gnu-emacs@gnu.org; Thu, 22 Jun 2023 13:59:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qCOaE-00047E-4G for bug-gnu-emacs@gnu.org; Thu, 22 Jun 2023 13:59:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qCOaE-00070l-1A for bug-gnu-emacs@gnu.org; Thu, 22 Jun 2023 13:59:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Daniel =?UTF-8?Q?Mart=C3=ADn?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 22 Jun 2023 17:59:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64198 X-GNU-PR-Package: emacs Original-Received: via spool by 64198-submit@debbugs.gnu.org id=B64198.168745673626939 (code B ref 64198); Thu, 22 Jun 2023 17:59:01 +0000 Original-Received: (at 64198) by debbugs.gnu.org; 22 Jun 2023 17:58:56 +0000 Original-Received: from localhost ([127.0.0.1]:36683 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qCOa7-00070R-KW for submit@debbugs.gnu.org; Thu, 22 Jun 2023 13:58:55 -0400 Original-Received: from sonic312-26.consmr.mail.ir2.yahoo.com ([77.238.178.97]:38158) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qCOa5-00070B-Iz for 64198@debbugs.gnu.org; Thu, 22 Jun 2023 13:58:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.es; s=s2048; t=1687456727; bh=odIFtAPItpPno2fkkSw96HrG1+sEwjg5bX1sOrjdooE=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=GwOuaYVSkfw4ECPzU+M2ulYV03qSrU7zlxeLF/eJ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vZs56ot8DRoei0wS1eBHfNtxX2 qUxk5iuTtnyveoZvZbxONiSdgsHvKcEWRH0QIHKTOLsAKSbGxcxh0ootgaEWoqYgfYA3IzgONgiF R4IarvKNvvb9U4rwUw9W3cAXdw_n3tZ8JQ3KI9sSi2g1sQez_IJKTO9y2TaSqF.Dq4eEOHIEuRgm IyT7UgI6oZfJmMTURzZSKaBsnszW50AAP9ctP3vzyubvQTWF4cZfAq5aY8WSTVwxQYysVnu5QKHR nAm.L3YfilBAXp6YqGESwpPfrXWCsxy50Jaew2M7TN5MtnVHml0_cZrtKwWH_YV1aMDYZM8gw.Zh ddSMud7.npfzZea4undVR_ez6.XwbCJgTlI4WJUGk._KXRHxcRwtPuuLScNHCHwjTcTDQTBmPhVK GcmMxxBxpqeSgTCKUaIXhXHztSqAMmyyvB5SglmJCxkgA5UMA1cACO0w2l30MwIT3Jw3pIJyECkk QqJ2y6RvK.lOxNqv8IHuCx5rq9oDXiodRFFwW72jtTF4hSVXHZh9ew3O35UUcJSvc_zzhdH6sE12 ZcjDqXEsMmOp6kQ5lcB0D1YQHcXsi5kV4NEtrEntuj X-Sonic-MF: X-Sonic-ID: 9d199d59-6672-4dc4-af9a-3b9f97e8bded Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic312.consmr.mail.ir2.yahoo.com with HTTP; Thu, 22 Jun 2023 17:58:47 +0000 Original-Received: by hermes--production-ir2-7867f454fc-hvmwx (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID d6a5634d285f768a2a7bfaf915444e57; Thu, 22 Jun 2023 17:58:44 +0000 (UTC) In-Reply-To: <3D7A63CD-5B7B-412A-8C55-90EFFA294F09@boostpro.com> (Dave Abrahams's message of "Thu, 22 Jun 2023 10:11:29 -0700") X-Mailer: WebService/1.1.21557 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo 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:263906 Archived-At: Dave Abrahams writes: > > Swift is a programming language. When its assertions (like C's > assert() macro) fail, a diagnostic is output with a file ID and > line. The file ID looks like a path, but it's really not. If it's a > path in the filesystem, that's coincidental but it's likely to point > to the right file. I don't want to manually hunt down the file every > time an assertion fails; I'd rather emacs made an educated guess based > on the current project. It's obviously not the right answer for > everyone, but I'd like to have the hooks needed to implement that > without too much hackery. This is the Elisp code you posted on GitHub, based on customizing compilation-parse-errors-filename-function: (defun dwa/path-tails-matching (path paths) "Returns the elements of PATHS with PATH as their suffix, matching by path component." (let ((tail (file-name-concat "/" path))) (seq-filter (lambda (full-path) (string-suffix-p tail full-path)) paths))) (defun dwa/compilation-parse-errors-filename-in-project (path-in-error) "If PATH-IN-ERROR is found in the filesystem, returns it unchanged; otherwise tries to return a unique file in the current project likely to be identified by PATH-IN-ERROR. Returns PATH-IN-ERROR unchanged if no such file can be found." (if (file-exists-p path-in-error) path-in-error ;; First look for relative path suffixes. (let* ((candidates (project-files (project-current t))) (full-matches (dwa/path-tails-matching path-in-error candidates))) ;; If not found, try just the filename component of ;; path-in-error; Swift assertions are weird and include a ;; module name that doesn't necessarily correspond to anything in the ;; filesystem. (cond ((null full-matches) (let ((filename-matches (dwa/path-tails-matching (file-name-nondirectory path-in-error) candidates))) (cond ((null filename-matches) path-in-error) ;; unique match; return it ((null (cadr filename-matches)) (car filename-matches)) ;; multiple matches; consider prompting for the user to select one. (t path-in-error)))) ;; unique match; return it ((null (cadr matches)) (car matches)) ; multiple matches; consider prompting for the user to select one. (t path-in-error))))) (setq compilation-parse-errors-filename-function 'dwa/compilation-parse-errors-filename-in-project) I've tried it and it seems to work well, although I agree that the code is a bit hacky and prone to error. How would the new hooks you propose simplify this customization code? Similar use cases have been discussed in the mailing list in the past. Someone proposed to make compilation-find-file customizable, which may not be a bad idea. See https://lists.gnu.org/archive/html/emacs-devel/2021-04/msg00910.html