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: Wed, 6 Jan 2010 05:00:38 +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 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1262751555 15320 80.91.229.12 (6 Jan 2010 04:19:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 6 Jan 2010 04:19:15 +0000 (UTC) Cc: Magnus Henoch , 3224@debbugs.gnu.org To: Dan Nicolaescu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jan 06 05:19:07 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 1NSNMR-00075t-6t for geb-bug-gnu-emacs@m.gmane.org; Wed, 06 Jan 2010 05:19:07 +0100 Original-Received: from localhost ([127.0.0.1]:48566 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NSNMR-0000td-Gx for geb-bug-gnu-emacs@m.gmane.org; Tue, 05 Jan 2010 23:19:07 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NSNMC-0000md-Fc for bug-gnu-emacs@gnu.org; Tue, 05 Jan 2010 23:18:52 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NSNM7-0000kd-Rh for bug-gnu-emacs@gnu.org; Tue, 05 Jan 2010 23:18:52 -0500 Original-Received: from [199.232.76.173] (port=33273 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NSNM7-0000kX-F2 for bug-gnu-emacs@gnu.org; Tue, 05 Jan 2010 23:18:47 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:54137) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NSNM7-0001Q3-0H for bug-gnu-emacs@gnu.org; Tue, 05 Jan 2010 23:18:47 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1NSN5u-0005LI-23; Tue, 05 Jan 2010 23:02: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: Wed, 06 Jan 2010 04:02: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.126275047820524 (code B ref 3224); Wed, 06 Jan 2010 04:02:02 +0000 Original-Received: (at 3224) by debbugs.gnu.org; 6 Jan 2010 04:01:18 +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 1NSN4z-0005Kz-SG for submit@debbugs.gnu.org; Tue, 05 Jan 2010 23:01:18 -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 1NSN4w-0005Kd-DG for 3224@debbugs.gnu.org; Tue, 05 Jan 2010 23:01:04 -0500 Original-Received: by bwz8 with SMTP id 8so10833872bwz.39 for <3224@debbugs.gnu.org>; Tue, 05 Jan 2010 20:00:58 -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 :content-transfer-encoding; bh=B675Ik/TA6bshtAd09T9PRw1RqXTPOEYsudG60zuyYo=; b=GXRwIDRucheY79ZmJhPZzQ/FLlsEdSZfXB1GumoeMOqm0M7BYUcgtwzmo5LA3V6Key ECs3QbZgSg4uzLGubYUd+SQSWXdimURpCH93/m84ocgf+Gp/Vxj+rFsDYOi4PG4E7BGp SYCCRlkEvRXFFXhvKDJ0ORwH2DnByq8lV9J/c= 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:content-transfer-encoding; b=NSAr7PpscPfzGwM7mmzKdFlXXt+eAidw3B3F2OzS0PmCVuWlr5cIUuow6djdxP+Jy6 HApa0TB4FYXMjCWmkjmSm1o246eudapNzfPrvpvdgYe7sn1XLYjXG7AxS13SVsBoF0+E odCz1UeP7V/zPx9VtnjIZbOeOH5iN14kRLg6c= Original-Received: by 10.204.4.71 with SMTP id 7mr3138687bkq.87.1262750458397; Tue, 05 Jan 2010 20:00:58 -0800 (PST) In-Reply-To: <200908041230.n74CUQUd025123@godzilla.ics.uci.edu> 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: Tue, 05 Jan 2010 23:02: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:33983 Archived-At: On Tue, Aug 4, 2009 at 13:30, Dan Nicolaescu wrote: > I am not familiar with uniquify, but after binding default-directory in > vc-dir-prepare-status-buffer, I get the result above. > And it is identical to what happens when doing: > > > (progn > =C2=A0(require 'uniquify) > =C2=A0(setq uniquify-buffer-name-style 'post-forward) > =C2=A0(cd "/tmp") > =C2=A0(make-directory "foo") > =C2=A0(make-directory "bar") > =C2=A0(cd "/tmp/foo") > =C2=A0(create-file-buffer "*vc-dir*") > =C2=A0(cd "/tmp/bar") > =C2=A0(create-file-buffer "*vc-dir*")) In fact, I think the two problems are not exactly the same, though they are related. If my analysis, and the following patch, are correct, Dan's example is caused by a bug in `uniquify-rationalize-file-buffer-names', which sometimes, while trying to refresh the dirname of a candidate, fails to check that it is setting it to nil. Fixing that problem makes Dan's example to work, but Magnus' vc-dir example still fails. The reason of the other bug is twofold: On one hand, vc-dir (specifically `vc-dir-prepare-status-buffer') is calling `create-file-buffer' passing "*vc-dir*" to it; but that function expects to be passed a filename; in this case, the difference is relevant because uniquify tries to use that filename's directory information to decide the dirname for the candidates. On the other hand, `uniquify-buffer-file-name' should return a directory, but fails to deal with the case that the "filename" is already a directory (which can happen, for example, when it is getting this "filename" from `list-buffers-directory'). In this case it should just remove any trailing slash and pass it back unscathed. Please, try the attached patch to see whether it helps. Thanks, Juanma 2010-01-06 Juanma Barranquero Bug#3224 =09 * uniquify.el (uniquify-rationalize-file-buffer-names): Don't set uniquify-item-dirname to nil. (uniquify-buffer-file-name): If the "filename" is already a directory name, do not modify it. * vc-dir.el (vc-dir-prepare-status-buffer): Pass a (fake) filename to `create-file-buffer' as it expects, not just a buffer name. =3D=3D=3D modified file 'lisp/uniquify.el' --- lisp/uniquify.el 2010-01-04 05:35:18 +0000 +++ lisp/uniquify.el 2010-01-06 03:22:51 +0000 @@ -232,9 +232,9 @@ ;; of code like in set-visited-file-name: ;; (or (string=3D new-name (buffer-name)) (rename-buffer new-name t)) ;; So we need to refresh the dirname of the uniquify-item. - (setf (uniquify-item-dirname (car items)) - (uniquify-buffer-file-name - (uniquify-item-buffer (car items)))) + (let ((bfn (uniquify-buffer-file-name (uniquify-item-buffer (car items))))) + (when bfn + (setf (uniquify-item-dirname (car items)) bfn))) ;; This shouldn't happen, but maybe there's no dirname any more. (unless (uniquify-item-dirname (car items)) (with-current-buffer (uniquify-item-buffer (car items)) @@ -265,9 +265,11 @@ list-buffers-directory)))) (when filename (directory-file-name - (file-name-directory - (expand-file-name - (directory-file-name filename)))))))) + (if (file-directory-p filename) + (file-name-as-directory filename) + (file-name-directory + (expand-file-name + (directory-file-name filename))))))))) (defun uniquify-rerationalize-w/o-cb (fix-list) "Re-rationalize the buffers in FIX-LIST, but ignoring `current-buffer'." =3D=3D=3D modified file 'lisp/vc-dir.el' --- lisp/vc-dir.el 2009-12-05 00:24:03 +0000 +++ lisp/vc-dir.el 2010-01-06 03:26:33 +0000 @@ -101,7 +101,7 @@ (return buffer)))))))) (or buf ;; Create a new buffer named BNAME. - (with-current-buffer (create-file-buffer bname) + (with-current-buffer (create-file-buffer (expand-file-name bname d= ir)) (cd dir) (vc-setup-buffer (current-buffer)) ;; Reset the vc-parent-buffer-name so that it does not appear