From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Qiang via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#64131: make resolving symlinks in compilation-find-file optional Date: Tue, 12 Sep 2023 07:56:40 +0800 Message-ID: <87h6o0b6x3.wl-qiang.fang@zoho.com.cn> References: <188c9822598.13072238736789.4931166686046079619@zoho.com.cn> Reply-To: Qiang Mime-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14733"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?Q?Goj=C5=8D?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) Cc: Qiang Fang , 64131@debbugs.gnu.org To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Sep 12 01:57:15 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 1qfqmJ-0003cu-1H for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 12 Sep 2023 01:57:15 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qfqm4-0004o5-Gy; Mon, 11 Sep 2023 19:57:00 -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 1qfqm2-0004nq-K7 for bug-gnu-emacs@gnu.org; Mon, 11 Sep 2023 19:56:58 -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 1qfqm2-00018s-Bg for bug-gnu-emacs@gnu.org; Mon, 11 Sep 2023 19:56:58 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qfqm6-0003Vd-H9 for bug-gnu-emacs@gnu.org; Mon, 11 Sep 2023 19:57:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Qiang Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 11 Sep 2023 23:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64131 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 64131-submit@debbugs.gnu.org id=B64131.169447662013482 (code B ref 64131); Mon, 11 Sep 2023 23:57:02 +0000 Original-Received: (at 64131) by debbugs.gnu.org; 11 Sep 2023 23:57:00 +0000 Original-Received: from localhost ([127.0.0.1]:55267 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qfqm4-0003VM-8Z for submit@debbugs.gnu.org; Mon, 11 Sep 2023 19:57:00 -0400 Original-Received: from sender2-pp-o92.zoho.com.cn ([163.53.93.251]:25156) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qfqm2-0003VC-6y for 64131@debbugs.gnu.org; Mon, 11 Sep 2023 19:56:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1694476608; s=admin; d=zoho.com.cn; i=qiang.fang@zoho.com.cn; h=Date:Date:Message-ID:From:From:To:To:Cc:Cc:Subject:Subject:In-Reply-To:References:MIME-Version:Content-Type:Message-Id:Reply-To; bh=YX+U0sCQH72Xwncm0PVb/Vdud8HJhqJD9IICKlrbhsA=; b=B+vknzSqg/XGIqsW6Qkg8c0kjT0hv7x4wFSmiwOkZUCzpPPY7sQ/xa3UxB/GRYUQ oXvdZmxOvcT2kSu64u6j2ibNDv9N5+jyN0zUMNDM1cN8D32/eY1YtthUYD6EF8e6IUi NybdrjX7DII+bf6j3HraTtwhDI88Om+tWLAIDwWU= Original-Received: from mypc.zoho.com.cn (182.136.10.30 [182.136.10.30]) by mx.zoho.com.cn with SMTPS id 1694476607376388.74310962524737; Tue, 12 Sep 2023 07:56:47 +0800 (CST) In-Reply-To: X-ZohoCNMailClient: External 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:270106 Archived-At: No, I couldn't provide a recipe. But it is obvious even to a beginner like me. The solution is just removed the file-truename function from compile-find-file, or make it customisable: (defun compilation-find-file (marker filename directory &rest formats) "Find a buffer for file FILENAME. If FILENAME is not found at all, ask the user where to find it. Pop up the buffer containing MARKER and scroll to MARKER if we ask the user where to find the file. Search the directories in `compilation-search-path'. A nil in `compilation-search-path' means to try the \"current\" directory, which is passed in DIRECTORY. If DIRECTORY is relative, it is combined with `default-directory'. If DIRECTORY is nil, that means use `default-directory'. FORMATS, if given, is a list of formats to reformat FILENAME when looking for it: for each element FMT in FORMATS, this function attempts to find a file whose name is produced by (format FMT FILENAME)." (or formats (setq formats '("%s"))) (let ((dirs compilation-search-path) (spec-dir (if directory (expand-file-name directory) default-directory)) buffer thisdir fmts name) (if (and filename (file-name-absolute-p filename)) ;; The file name is absolute. Use its explicit directory as ;; the first in the search path, and strip it from FILENAME. (setq filename (abbreviate-file-name (expand-file-name filename)) dirs (cons (file-name-directory filename) dirs) filename (file-name-nondirectory filename))) ;; Now search the path. (while (and dirs (null buffer)) (setq thisdir (or (car dirs) spec-dir) fmts formats) ;; For each directory, try each format string. (while (and fmts (null buffer)) (setq name (file-name-concat thisdir (format (car fmts) filename)) buffer (and (file-exists-p name) (find-file-noselect name)) fmts (cdr fmts))) (setq dirs (cdr dirs))) ;; If we haven't found it, this might be a parallel build. ;; Search the directories further up the buffer. (when (and (null buffer) compilation-search-all-directories) (with-current-buffer (marker-buffer marker) (save-excursion (goto-char (marker-position marker)) (when-let ((prev (compilation--previous-directory (point)))) (goto-char prev)) (setq dirs (cdr (or (get-text-property (1- (point)) 'compilation-directory) (get-text-property (point) 'compilation-directory)))))) (while (and dirs (null buffer)) (setq thisdir (car dirs) fmts formats) (while (and fmts (null buffer)) (setq name (file-name-concat thisdir (format (car fmts) filename)) buffer (and (file-exists-p name) (find-file-noselect name)) fmts (cdr fmts))) (setq dirs (cdr dirs)))) (while (null buffer) ;Repeat until the user selects an existing file. ;; The file doesn't exist. Ask the user where to find it. (save-excursion ;This save-excursion is probably not right. (let ((w (let ((pop-up-windows t)) (display-buffer (marker-buffer marker) '(nil (allow-no-window . t)))))) (with-current-buffer (marker-buffer marker) (goto-char marker) (and w (progn (compilation-set-window w marker) (compilation-set-overlay-arrow w)))) (let* ((name (read-file-name (format-prompt "Find this %s in" filename compilation-error) spec-dir filename t nil ;; The predicate below is fine when called from ;; minibuffer-complete-and-exit, but it's too ;; restrictive otherwise, since it also prevents the ;; user from completing "fo" to "foo/" when she ;; wants to enter "foo/bar". ;; ;; Try to make sure the user can only select ;; a valid answer. This predicate may be ignored, ;; tho, so we still have to double-check afterwards. ;; TODO: We should probably fix read-file-name so ;; that it never ignores this predicate, even when ;; using popup dialog boxes. ;; (lambda (name) ;; (if (file-directory-p name) ;; (setq name (expand-file-name filename name))) ;; (file-exists-p name)) )) (origname name)) (cond ((not (file-exists-p name)) (message "Cannot find file `%s'" name) (ding) (sit-for 2)) ((and (file-directory-p name) (not (file-exists-p (setq name (file-name-concat name filename))))) (message "No `%s' in directory %s" filename origname) (ding) (sit-for 2)) (t (setq buffer (find-file-noselect name)))))))) ;; Make intangible overlays tangible. ;; This is weird: it's not even clear which is the current buffer, ;; so the code below can't be expected to DTRT here. -- Stef (dolist (ov (overlays-in (point-min) (point-max))) (when (overlay-get ov 'intangible) (overlay-put ov 'intangible nil))) buffer)))