From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#24441: 24.5; rename directory in dired to change case Date: Fri, 11 Nov 2016 10:27:35 +0200 Message-ID: <83fumye808.fsf@gnu.org> References: < < <<3c49fbe5-9ae0-4ae2-8fa0-3c44fa85c981@default> <<83d1k56wwt.fsf@gnu.org> <7a1c7e15-4d84-400d-9735-a72a31408d6b@default> <834m5h6vg3.fsf@gnu.org> <5965f396-a65a-3d70-e67e-c3d680fe9e65@cornell.edu> <83zin95ddg.fsf@gnu.org> <8da158f4-21bb-8fb8-a56d-21d4cd967109@cornell.edu> <61dc70de-7dfc-269c-e974-839f8d138d33@cornell.edu> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1478852926 27001 195.159.176.226 (11 Nov 2016 08:28:46 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 11 Nov 2016 08:28:46 +0000 (UTC) Cc: 24441@debbugs.gnu.org, schwab@suse.de, brady@bradyt.com To: Ken Brown , Michael Albinus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Nov 11 09:28:41 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c57Bz-0002vm-Bb for geb-bug-gnu-emacs@m.gmane.org; Fri, 11 Nov 2016 09:28:11 +0100 Original-Received: from localhost ([::1]:51308 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c57C2-0001oi-G0 for geb-bug-gnu-emacs@m.gmane.org; Fri, 11 Nov 2016 03:28:14 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35315) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c57Bt-0001n4-JD for bug-gnu-emacs@gnu.org; Fri, 11 Nov 2016 03:28:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c57Bq-0001Nh-BW for bug-gnu-emacs@gnu.org; Fri, 11 Nov 2016 03:28:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:37580) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c57Bq-0001NZ-7K for bug-gnu-emacs@gnu.org; Fri, 11 Nov 2016 03:28:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1c57Bp-0004FA-Vm for bug-gnu-emacs@gnu.org; Fri, 11 Nov 2016 03:28:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 11 Nov 2016 08:28:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24441 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 24441-submit@debbugs.gnu.org id=B24441.147885287416297 (code B ref 24441); Fri, 11 Nov 2016 08:28:01 +0000 Original-Received: (at 24441) by debbugs.gnu.org; 11 Nov 2016 08:27:54 +0000 Original-Received: from localhost ([127.0.0.1]:52979 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c57Be-0004Ej-9F for submit@debbugs.gnu.org; Fri, 11 Nov 2016 03:27:54 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:44276) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c57Bc-0004EW-AQ for 24441@debbugs.gnu.org; Fri, 11 Nov 2016 03:27:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c57BV-0001JU-R0 for 24441@debbugs.gnu.org; Fri, 11 Nov 2016 03:27:43 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:56546) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c57BM-0001GH-VG; Fri, 11 Nov 2016 03:27:32 -0500 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:1354 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1c57BM-0007YN-0h; Fri, 11 Nov 2016 03:27:32 -0500 In-reply-to: <61dc70de-7dfc-269c-e974-839f8d138d33@cornell.edu> (message from Ken Brown on Thu, 10 Nov 2016 20:42:53 -0500) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:125603 Archived-At: > Cc: 24441@debbugs.gnu.org, schwab@suse.de, brady@bradyt.com > From: Ken Brown > Date: Thu, 10 Nov 2016 20:42:53 -0500 > > On 11/10/2016 5:25 PM, Ken Brown wrote: > > The attached patch attempts to do this for both Cygwin and OS X. I > > don't have access to an OS X system, so someone else will have to test > > the OS X part. > > Here's a simpler version. Thanks, please see a few comments below. > + (if (and (file-name-case-insensitive-p > + (expand-file-name (car fn-list))) You shouldn't need to expand-file-name here, as all primitives do that internally. (Yours didn't, but that's a mistake, see below.) > +/* Filesystems are case-sensitive on all supported systems except > + MS-Windows, MS-DOS, Cygwin, and OS X. They are always > + case-insensitive on the first two, but they may or may not be > + case-insensitive on Cygwin and OS X. The following function > + attempts to provide a runtime test on those two systems. If the > + test is not conclusive, we assume case-insensitivity on Cygwin and > + case-sensitivity on OS X. */ > +static bool > +file_name_case_insensitive_p (const char *filename) What about filesystems mounted on Posix hosts, like Samba, NFS-mounted Windows volumes, etc. -- do those behave as case-sensitive or not? If the latter, can that be detected? Just asking, this shouldn't hold the patch, unless incorporating that is easy (or you feel like it even if it isn't ;-). > +DEFUN ("file-name-case-insensitive-p", Ffile_name_case_insensitive_p, > + Sfile_name_case_insensitive_p, 1, 1, 0, > + doc: /* Return t if file FILENAME is on a case-insensitive filesystem. > +The arg must be a string. */) > + (Lisp_Object filename) > +{ > + CHECK_STRING (filename); > + return file_name_case_insensitive_p (SSDATA (filename)) ? Qt : Qnil; > +} This "needs work"™. First, it should call expand-file-name, as all file-related primitives do. Second, it should see if there's a file handler for this operation, and if so, call it instead (Michael, please take note ;-). Finally, it should run the expanded file name through ENCODE_FILE before it calls file_name_case_insensitive_p, and pass to the latter the result of the encoding, otherwise the call to getattrlist will most certainly fail in some cases. > DEFUN ("rename-file", Frename_file, Srename_file, 2, 3, > "fRename file: \nGRename %s to file: \np", > doc: /* Rename FILE as NEWNAME. Both args must be strings. > @@ -2250,12 +2301,11 @@ This is what happens in interactive use with M-x. */) > file = Fexpand_file_name (file, Qnil); > > if ((!NILP (Ffile_directory_p (newname))) > -#ifdef DOS_NT > - /* If the file names are identical but for the case, > - don't attempt to move directory to itself. */ > - && (NILP (Fstring_equal (Fdowncase (file), Fdowncase (newname)))) > -#endif > - ) > + /* If the filesystem is case-insensitive and the file names are > + identical but for the case, don't attempt to move directory > + to itself. */ > + && (NILP (Ffile_name_case_insensitive_p (file)) > + || NILP (Fstring_equal (Fdowncase (file), Fdowncase (newname))))) This should call file_name_case_insensitive_p, and pass it the encoded file names. That's because the file handlers for rename-file were already called, so we are now sure the file doesn't have any handlers. > @@ -2276,14 +2326,12 @@ This is what happens in interactive use with M-x. */) > encoded_file = ENCODE_FILE (file); > encoded_newname = ENCODE_FILE (newname); > > -#ifdef DOS_NT > - /* If the file names are identical but for the case, don't ask for > - confirmation: they simply want to change the letter-case of the > - file name. */ > - if (NILP (Fstring_equal (Fdowncase (file), Fdowncase (newname)))) > -#endif > - if (NILP (ok_if_already_exists) > - || INTEGERP (ok_if_already_exists)) > + /* If the filesystem is case-insensitive and the file names are > + identical but for the case, don't ask for confirmation: they > + simply want to change the letter-case of the file name. */ > + if ((NILP (Ffile_name_case_insensitive_p (file)) Likewise here. Finally, please provide a NEWS entry for the new primitive and its documentation in the ELisp manual. Thanks again for working on this.