From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#55743: 28.1.50; No directory error in comp-run-async-workers Date: Wed, 01 Jun 2022 09:10:56 +0300 Organization: LINKOV.NET Message-ID: <86sfoo7wm7.fsf@mail.linkov.net> References: <86y1yhsxin.fsf@mail.linkov.net> <83wne1h66x.fsf@gnu.org> <86wne1trce.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13722"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) Cc: 55743@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jun 01 08:29:13 2022 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 1nwHqz-0003NR-5P for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 01 Jun 2022 08:29:13 +0200 Original-Received: from localhost ([::1]:47518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nwHqx-0000vq-Ju for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 01 Jun 2022 02:29:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33294) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nwHpq-0000ut-BE for bug-gnu-emacs@gnu.org; Wed, 01 Jun 2022 02:28:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55629) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nwHpq-0006Bz-2G for bug-gnu-emacs@gnu.org; Wed, 01 Jun 2022 02:28:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nwHpp-0001Di-Tv for bug-gnu-emacs@gnu.org; Wed, 01 Jun 2022 02:28:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 01 Jun 2022 06:28:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55743 X-GNU-PR-Package: emacs Original-Received: via spool by 55743-submit@debbugs.gnu.org id=B55743.16540648654650 (code B ref 55743); Wed, 01 Jun 2022 06:28:01 +0000 Original-Received: (at 55743) by debbugs.gnu.org; 1 Jun 2022 06:27:45 +0000 Original-Received: from localhost ([127.0.0.1]:49523 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nwHpY-0001Cw-OB for submit@debbugs.gnu.org; Wed, 01 Jun 2022 02:27:44 -0400 Original-Received: from relay10.mail.gandi.net ([217.70.178.230]:41811) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nwHpX-0001Cj-7C for 55743@debbugs.gnu.org; Wed, 01 Jun 2022 02:27:43 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 9DB89240004; Wed, 1 Jun 2022 06:27:36 +0000 (UTC) In-Reply-To: <86wne1trce.fsf@mail.linkov.net> (Juri Linkov's message of "Tue, 31 May 2022 22:49:37 +0300") 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" Xref: news.gmane.io gmane.emacs.bugs:233478 Archived-At: >>> So here are two problems: why completion sets default-directory to non-existent dir, >> >> That's the real problem. > > Oh, I see, it's a known problem. In completion-setup-function: > > (base-dir > ;; FIXME: This is a bad hack. We try to set the default-directory > ;; in the *Completions* buffer so that the relative file names > ;; displayed there can be treated as valid file names, independently > ;; from the completion context. But this suffers from many problems: > ;; - It's not clear when the completions are file names. With some > ;; completion tables (e.g. bzr revision specs), the listed > ;; completions can mix file names and other things. > ;; - It doesn't pay attention to possible quoting. > ;; - With fancy completion styles, the code below will not always > ;; find the right base directory. > (if minibuffer-completing-file-name > (file-name-as-directory > (expand-file-name > (buffer-substring (minibuffer-prompt-end) (point))))))) > ... > (if base-dir (setq default-directory base-dir)) The problem can be solved by this patch that handles both the most frequent cases: when the completion string is the default directory, and when a file prefix is added to it. diff --git a/lisp/simple.el b/lisp/simple.el index 103e7f33dd..81e04f28e9 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -9803,7 +9802,7 @@ completion-setup-function ;; - With fancy completion styles, the code below will not always ;; find the right base directory. (if minibuffer-completing-file-name - (file-name-as-directory + (file-name-directory (expand-file-name (buffer-substring (minibuffer-prompt-end) (point))))))) (with-current-buffer standard-output