From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juanma Barranquero Newsgroups: gmane.emacs.bugs Subject: bug#3224: 23.0.92; vc-dir vs uniquify: wrong directory used Date: Thu, 7 Jan 2010 12:14:01 +0100 Message-ID: References: <84my9rfuhg.fsf@linux-b2a3.site> <200908041230.n74CUQUd025123@godzilla.ics.uci.edu> Reply-To: Juanma Barranquero , 3224@debbugs.gnu.org NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1262863315 8243 80.91.229.12 (7 Jan 2010 11:21:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 7 Jan 2010 11:21:55 +0000 (UTC) Cc: 3224@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jan 07 12:21:47 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NSqQn-0003tC-8i for geb-bug-gnu-emacs@m.gmane.org; Thu, 07 Jan 2010 12:21:33 +0100 Original-Received: from localhost ([127.0.0.1]:52011 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NSqQn-0004eG-Mj for geb-bug-gnu-emacs@m.gmane.org; Thu, 07 Jan 2010 06:21:33 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NSqOH-0003mB-JK for bug-gnu-emacs@gnu.org; Thu, 07 Jan 2010 06:18:57 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NSqOB-0003jG-UP for bug-gnu-emacs@gnu.org; Thu, 07 Jan 2010 06:18:56 -0500 Original-Received: from [199.232.76.173] (port=44774 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NSqOB-0003j7-OC for bug-gnu-emacs@gnu.org; Thu, 07 Jan 2010 06:18:51 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:33096) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NSqOB-0007Wh-C5 for bug-gnu-emacs@gnu.org; Thu, 07 Jan 2010 06:18:51 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1NSqKU-0005AA-OF; Thu, 07 Jan 2010 06:15:02 -0500 X-Loop: bug-gnu-emacs@gnu.org Mail-Followup-To: Juanma Barranquero , 3224@debbugs.gnu.org Resent-From: Juanma Barranquero Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 07 Jan 2010 11:15:02 +0000 Resent-Message-ID: Resent-Sender: bug-gnu-emacs@gnu.org X-Emacs-PR-Message: followup 3224 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 3224-submit@debbugs.gnu.org id=B3224.126286286819813 (code B ref 3224); Thu, 07 Jan 2010 11:15:02 +0000 Original-Received: (at 3224) by debbugs.gnu.org; 7 Jan 2010 11:14:28 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NSqJw-00059W-94 for submit@debbugs.gnu.org; Thu, 07 Jan 2010 06:14:28 -0500 Original-Received: from mail-bw0-f216.google.com ([209.85.218.216]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NSqJu-00059R-Im for 3224@debbugs.gnu.org; Thu, 07 Jan 2010 06:14:27 -0500 Original-Received: by bwz8 with SMTP id 8so11684302bwz.39 for <3224@debbugs.gnu.org>; Thu, 07 Jan 2010 03:14:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:cc:content-type; bh=gwZBrlEARBEDdxdt1JteQGfHfeZpdJ5oca+Dgd210I0=; b=wS7O315/ZPLxzUlGnwX2MmC1Jt9NRNm3dZpztPgeVzYgJCGJUZGN+qM95KPh0Bl0Pm h2y3BGYuLT9iGH6n/1ggVy32Ftl49mVsnpsXh+JeNswg9QPIQlZegHOEtWP8DiHV76Pr f/ok/vwAcLa3gtgqebKsygvyg+3iSs9IC2+0s= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=vi9wpL74DOL2fVKN95Ry1gZRC4GupTLHqW2SxqZici5EnqIpnOQqqwh+ZM2bOeM7fb rWJGsirs/sKi/1zofnZieNTE0+I7wyaKvZZirBgwdjfx6snZ57UFwjAvbLz72o3IFyuC 9b8ScajgbrKfxeldATJPYZ9Hol5KQvAI8PgSw= Original-Received: by 10.204.156.3 with SMTP id u3mr410520bkw.179.1262862862918; Thu, 07 Jan 2010 03:14:22 -0800 (PST) In-Reply-To: X-Spam-Score: -2.6 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list X-Spam-Score: -2.6 (--) Resent-Date: Thu, 07 Jan 2010 06:15:02 -0500 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) 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: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:34027 Archived-At: On Wed, Jan 6, 2010 at 15:28, Stefan Monnier wrote: > AFAIK it already *does* the right thing (try it with Dired buffers, > since these are the (only?) ones that should have a directory name), > unless maybe we don't agree on what is the right thing in that case. The dired and vc-dired cases are not exactly equivalent. In the dired case, uniquify-buffer-file-name is called when there's a conflict like (dired "/my/dir-1/A") (dired "/my/dir-2/A") (because /my/dir/A vs my/dir/B obviously does not produce any conflict). In this case, u-b-f-n gets, via `list-buffers-directory', the full path including the A: /my/dir1/A, and strips the last element and returns /my/dir1. That works for uniquify, because it will be getting path elements from /my/dir1 vs. /my/dir2, just as it needs. The resulting buffers (with forward syntax) will be "A|dir-1" and "A|dir-2". In the OP's vc-dir case, the conflicts happens in this: (vc-dir "/my/dir/A") (vc-dir "/my/dir/B") because the conflict uniquify tries to solve is at the buffer-name level, which is always *vc-dir*. /my/dir/A and /my/dir/B are directories, and so elements for uniquifying; the expected result is "*vc-dir*|A" and "*vc-dir*|B". However, u-b-f-n gets "/my/dir/B" (via list-buffers-directory), which is correct, and again strips the last element and returns "/my/dir". So uniquify ends producting "*vc-dir*|A" and "*vc-dir*|dir", which is incorrect. Now, if you consider than always removing an element from BUFFER is the right thing to do for u-b-f-n, we'll have to agree to disagree; IMHO, that's not what its docstring says. From it, I would expect u-b-f-n to return a directory unchanged. That said, my "fix" to u-b-f-n would break uniquifying of dired buffers (thanks for pointing that out), so perhaps we'll have to live with such behavior. In that case, I'd suggest reworking the docstring of u-b-f-n. Going with your proposed fix via `list-buffers-directory', the following patch works. I have not added a comment to the change to `list-buffers-directory' because I don't really know how to explain it; it seems a hack to me to force a variable named `list-buffers-directory' to contain a bogus name part just to help uniquify. Comments? Dan, what do you think? Juanma === modified file 'lisp/vc-dir.el' --- lisp/vc-dir.el 2009-12-05 00:24:03 +0000 +++ lisp/vc-dir.el 2010-01-07 11:09:16 +0000 @@ -101,7 +101,9 @@ (return buffer)))))))) (or buf ;; Create a new buffer named BNAME. - (with-current-buffer (create-file-buffer bname) + ;; We pass a filename to create-file-buffer because it is what + ;; the function expects, and also what uniquify needs (if active) + (with-current-buffer (create-file-buffer (expand-file-name bname dir)) (cd dir) (vc-setup-buffer (current-buffer)) ;; Reset the vc-parent-buffer-name so that it does not appear @@ -928,7 +930,7 @@ (set (make-local-variable 'vc-ewoc) (ewoc-create #'vc-dir-printer)) (set (make-local-variable 'revert-buffer-function) 'vc-dir-revert-buffer-function) - (setq list-buffers-directory default-directory) + (setq list-buffers-directory (expand-file-name "*vc-dir*" default-directory)) (add-to-list 'vc-dir-buffers (current-buffer)) ;; Make sure that if the directory buffer is killed, the update ;; process running in the background is also killed.