From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#41424: bug#41412: 27.0.90; Value of default directory in completions buffer Date: Fri, 22 Jan 2021 21:28:14 +0100 Message-ID: <87k0s4wwbl.fsf@gnus.org> References: <87pnay7azg.fsf@penguin> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39177"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 41424@debbugs.gnu.org, 41412@debbugs.gnu.org, Stefan Monnier To: Omar =?UTF-8?Q?Antol=C3=ADn?= Camarena Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jan 22 21:29:13 2021 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 1l333P-0009zP-UO for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 22 Jan 2021 21:29:11 +0100 Original-Received: from localhost ([::1]:53202 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l333O-00053U-VL for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 22 Jan 2021 15:29:10 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53888) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l333G-000534-JB for bug-gnu-emacs@gnu.org; Fri, 22 Jan 2021 15:29:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49934) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l333G-0003oj-9j for bug-gnu-emacs@gnu.org; Fri, 22 Jan 2021 15:29:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l333G-0000VJ-6W for bug-gnu-emacs@gnu.org; Fri, 22 Jan 2021 15:29:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 22 Jan 2021 20:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41424 X-GNU-PR-Package: emacs Original-Received: via spool by 41424-submit@debbugs.gnu.org id=B41424.16113473131893 (code B ref 41424); Fri, 22 Jan 2021 20:29:02 +0000 Original-Received: (at 41424) by debbugs.gnu.org; 22 Jan 2021 20:28:33 +0000 Original-Received: from localhost ([127.0.0.1]:33246 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l332m-0000UN-Uq for submit@debbugs.gnu.org; Fri, 22 Jan 2021 15:28:33 -0500 Original-Received: from quimby.gnus.org ([95.216.78.240]:45190) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l332j-0000U3-MY; Fri, 22 Jan 2021 15:28:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=zwp7TqYg6EERKOg0cN/q3EooWCaca9ktXS8CoHYJ4Vk=; b=sVcmvXPTLa9RqtKEJNyPOzlt2P wLQ9G+3SQYls5U1S0nrE2U6SDB3wbwlgNJ6GQF2N//A3UTRI2PPadWPwEL/TCwRpoJKZJNykk8HLa ZLHbac++sXTn63wOYfb/lmSqJMiluh04fOCqm+1fs3CGBEux/0DWOIxqxienRBYZ0auI=; Original-Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l332V-0005Kn-Sj; Fri, 22 Jan 2021 21:28:20 +0100 X-Now-Playing: Various's _Deathbomb Digital Singles Club Year 2_: "L.C.D." In-Reply-To: <87pnay7azg.fsf@penguin> ("Omar =?UTF-8?Q?Antol=C3=ADn?= Camarena"'s message of "Wed, 20 May 2020 12:49:23 -0500") 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:198407 Archived-At: Omar Antol=C3=ADn Camarena writes: > There is a bit of logic in `complete-setup-function' (from simple.el) > to set the default directory in the *Completions* buffer: > > ;; 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) (or completion-base-size 0)))))) > > As the comment says, this is brittle, but better than nothing. I > believe, however, that the `file-name-as-directory' is a typo and > probably `file-name-directory' was intended instead. I think that sounds likely. The patch that introduced this code is below, and it indeed changes the `file-name-directory' to `file-name-as-directory' (among other things). I've added Stafan M to the CCs -- was this done on purpose, or should we go back to `file-name-directory' here? diff --git a/lisp/simple.el b/lisp/simple.el index 082605f659..13c75c4d7b 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -5851,20 +5851,22 @@ completion-root-regexp ;; after the text of the completion list buffer is written. (defun completion-setup-function () (let* ((mainbuf (current-buffer)) - (mbuf-contents (minibuffer-completion-contents)) - common-string-length) - ;; When reading a file name in the minibuffer, - ;; set default-directory in the minibuffer - ;; so it will get copied into the completion list buffer. - (if minibuffer-completing-file-name - (with-current-buffer mainbuf - (setq default-directory - (file-name-directory (expand-file-name mbuf-contents))))) + (base-dir + ;; When reading a file name in the minibuffer, + ;; try and find the right default-directory to set in the + ;; completion list buffer. + ;; FIXME: Why do we do that, actually? --Stef + (if minibuffer-completing-file-name + (file-name-as-directory + (expand-file-name + (substring (minibuffer-completion-contents) + 0 (or completion-base-size 0))))))) (with-current-buffer standard-output (let ((base-size completion-base-size)) ;Read before killing localva= rs. (completion-list-mode) (set (make-local-variable 'completion-base-size) base-size)) (set (make-local-variable 'completion-reference-buffer) mainbuf) + (if base-dir (setq default-directory base-dir)) (unless completion-base-size ;; This shouldn't be needed any more, but further analysis is need= ed ;; to make sure it's the case. --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no