* bug#24441: 24.5; rename directory in dired to change case @ 2016-09-15 3:32 Brady Trainor 2016-09-15 9:05 ` Tino Calancha ` (3 more replies) 0 siblings, 4 replies; 23+ messages in thread From: Brady Trainor @ 2016-09-15 3:32 UTC (permalink / raw) To: 24441 If I have a directory `a', and try to rename it `A' in dired, it errors. `(file-error Renaming Invalid argument /tmp/a /tmp/A/a)'. In GNU Emacs 24.5.1 (x86_64-apple-darwin15.6.0, NS apple-appkit-1404.47) of 2016-08-15 on heeere.PK5001Z Windowing system distributor `Apple', version 10.3.1404 Configured using: `configure --disable-dependency-tracking --disable-silent-rules --enable-locallisppath=/usr/local/share/emacs/site-lisp --infodir=/usr/local/Cellar/emacs/24.5/share/info/emacs --prefix=/usr/local/Cellar/emacs/24.5 --without-x --with-xml2 --without-dbus --with-gnutls --with-rsvg --with-ns --disable-ns-self-contained' Important settings: value of $LC_ALL: en_US.UTF-8 value of $LC_CTYPE: en_US.UTF-8 value of $LANG: en_US.UTF-8 locale-coding-system: nil Major mode: Dired Minor modes in effect: global-auto-revert-mode: t shell-dirtrack-mode: t TeX-PDF-mode: t evil-escape-mode: t global-undo-tree-mode: t gdb-many-windows: t yas-global-mode: t yas-minor-mode: t dired-hide-details-mode: t override-global-mode: t winner-mode: t tooltip-mode: t electric-indent-mode: t mouse-wheel-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t buffer-read-only: t column-number-mode: t line-number-mode: t transient-mark-mode: t Recent messages: (file-error Renaming Invalid argument /Users/iam/my-learning-resources/x /Users/iam/my-learning-resources/X/x) Quit Delete x (y or n) y Deleting...done x -> X Quit Making completion list... Quit Making completion list... Load-path shadows: /Users/iam/.emacs.d/elpa/helm-20160409.357/helm-multi-match hides /Users/iam/.emacs.d/elpa/helm-core-20160407.2135/helm-multi-match /Users/iam/.emacs.d/elpa/color-theme-solarized-20160219.924/solarized-theme hides /Users/iam/.emacs.d/elpa/solarized-theme-1.2.2/solarized-theme /Users/iam/.emacs.d/elpa/circe-20160119.11/tracking hides /Users/iam/.emacs.d/elpa/tracking-20151129.319/tracking /Users/iam/.emacs.d/elpa/circe-20160119.11/shorten hides /Users/iam/.emacs.d/elpa/tracking-20151129.319/shorten /Users/iam/.emacs.d/elpa/ledger-mode-20160111.1834/ledger-xact hides /usr/local/share/emacs/site-lisp/ledger/ledger-xact /Users/iam/.emacs.d/elpa/ledger-mode-20160111.1834/ledger-texi hides /usr/local/share/emacs/site-lisp/ledger/ledger-texi /Users/iam/.emacs.d/elpa/ledger-mode-20160111.1834/ledger-test hides /usr/local/share/emacs/site-lisp/ledger/ledger-test /Users/iam/.emacs.d/elpa/ledger-mode-20160111.1834/ledger-state hides /usr/local/share/emacs/site-lisp/ledger/ledger-state /Users/iam/.emacs.d/elpa/ledger-mode-20160111.1834/ledger-sort hides /usr/local/share/emacs/site-lisp/ledger/ledger-sort /Users/iam/.emacs.d/elpa/ledger-mode-20160111.1834/ledger-schedule hides /usr/local/share/emacs/site-lisp/ledger/ledger-schedule /Users/iam/.emacs.d/elpa/ledger-mode-20160111.1834/ledger-report hides /usr/local/share/emacs/site-lisp/ledger/ledger-report /Users/iam/.emacs.d/elpa/ledger-mode-20160111.1834/ledger-regex hides /usr/local/share/emacs/site-lisp/ledger/ledger-regex /Users/iam/.emacs.d/elpa/ledger-mode-20160111.1834/ledger-reconcile hides /usr/local/share/emacs/site-lisp/ledger/ledger-reconcile /Users/iam/.emacs.d/elpa/ledger-mode-20160111.1834/ledger-post hides /usr/local/share/emacs/site-lisp/ledger/ledger-post /Users/iam/.emacs.d/elpa/ledger-mode-20160111.1834/ledger-occur hides /usr/local/share/emacs/site-lisp/ledger/ledger-occur /Users/iam/.emacs.d/elpa/ledger-mode-20160111.1834/ledger-navigate hides /usr/local/share/emacs/site-lisp/ledger/ledger-navigate /Users/iam/.emacs.d/elpa/ledger-mode-20160111.1834/ledger-mode hides /usr/local/share/emacs/site-lisp/ledger/ledger-mode /Users/iam/.emacs.d/elpa/ledger-mode-20160111.1834/ledger-init hides /usr/local/share/emacs/site-lisp/ledger/ledger-init /Users/iam/.emacs.d/elpa/ledger-mode-20160111.1834/ledger-fonts hides /usr/local/share/emacs/site-lisp/ledger/ledger-fonts /Users/iam/.emacs.d/elpa/ledger-mode-20160111.1834/ledger-fontify hides /usr/local/share/emacs/site-lisp/ledger/ledger-fontify /Users/iam/.emacs.d/elpa/ledger-mode-20160111.1834/ledger-exec hides /usr/local/share/emacs/site-lisp/ledger/ledger-exec /Users/iam/.emacs.d/elpa/ledger-mode-20160111.1834/ledger-context hides /usr/local/share/emacs/site-lisp/ledger/ledger-context /Users/iam/.emacs.d/elpa/ledger-mode-20160111.1834/ledger-complete hides /usr/local/share/emacs/site-lisp/ledger/ledger-complete /Users/iam/.emacs.d/elpa/ledger-mode-20160111.1834/ledger-commodities hides /usr/local/share/emacs/site-lisp/ledger/ledger-commodities Features: (shadow sort mail-extr emacsbug message idna rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mail-utils misearch multi-isearch wdired dired-aux pdf-outline pdf-links pdf-isearch let-alist pdf-misc imenu face-remap lisp-mnt finder-inf doc-view tramp-cache tramp-sh tramp tramp-compat tramp-loaddefs trampver helm-bookmark helm-net browse-url xml url url-proxy url-privacy url-expand url-methods url-history url-cookie url-domsuf url-util url-parse auth-source gnus-util mm-util mail-prsvr password-cache url-vars mailcap helm-adaptive helm-info helm-plugin helm-utils helm-types helm-help helm helm-source eieio eieio-core helm-multi-match helm-lib server paren autorevert filenotify bracketed-paste shm shm-debug shm-manipulation shm-nav shm-yank-kill shm-type shm-constraint shm-edit-string shm-insert-del shm-languages shm-stack shm-indent shm-simple-indent shm-slot shm-layout shm-ast shm-overlays shm-in shm-node shm-ast-documentation shm-customizations shm-evaporate shm-macros outshine outorg rainbow-delimiters evil-leader dropdown-list graphviz-dot-mode org-protocol ob-sh shell ob-scheme ob-python ob-org ob-makefile ob-ledger ob-latex ob-js ob-C cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs org org-macro org-footnote org-pcomplete org-list org-faces org-entities time-date org-version ob-emacs-lisp org-loaddefs find-func cal-menu calendar cal-loaddefs ob-haskell ob ob-tangle ob-ref ob-lob ob-table ob-exp org-src ob-keys ob-comint ob-core ob-eval org-compat org-macs weechat-complete pcomplete weechat-button weechat weechat-color weechat-relay weechat-core s ucs-normalize tex crm evil-escape evil evil-integration undo-tree diff evil-maps evil-commands evil-command-window evil-types evil-search evil-ex evil-macros evil-repeat evil-states evil-core evil-common thingatpt rect evil-digraphs evil-vars gdb-mi bindat json gud haskell-snippets yasnippet nlinum linum exec-path-from-shell haskell-mode haskell-indentation haskell-string haskell-sort-imports haskell-lexeme rx haskell-align-imports haskell-compat haskell-complete-module noutline outline flymake etags dabbrev haskell-customize bookmark+ bookmark+-key derived dired-x dired bookmark+-1 bookmark+-bmu help-mode bookmark+-lit autoinsert pdf-tools compile comint ansi-color cus-edit cus-start cus-load wid-edit pdf-view mule-util bookmark pp jka-compr pdf-cache pdf-info tq pdf-util byte-opt advice format-spec image-mode use-package diminish bytecomp byte-compile cl-extra cconv bind-key easy-mmode tex-site help-fns cl-macs cl gv info easymenu package epg-config windmove winner ring edmacro kmacro cl-loaddefs cl-lib tooltip electric uniquify ediff-hook vc-hooks lisp-float-type mwheel ns-win tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment lisp-mode prog-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote make-network-process cocoa ns multi-tty emacs) Memory information: ((conses 16 636015 31930) (symbols 48 50457 0) (miscs 40 746 1251) (strings 32 123811 14666) (string-bytes 1 14700604) (vectors 16 68251) (vector-slots 8 1104614 23015) (floats 8 3927 904) (intervals 56 2724 0) (buffers 960 38)) -- Brady Brady Trainor brady@bradyt.com 206-898-4124 ^ permalink raw reply [flat|nested] 23+ messages in thread
* bug#24441: 24.5; rename directory in dired to change case 2016-09-15 3:32 bug#24441: 24.5; rename directory in dired to change case Brady Trainor @ 2016-09-15 9:05 ` Tino Calancha 2016-09-15 9:28 ` Andreas Schwab ` (2 subsequent siblings) 3 siblings, 0 replies; 23+ messages in thread From: Tino Calancha @ 2016-09-15 9:05 UTC (permalink / raw) To: brady; +Cc: 24441, tino.calancha Thanks for your report. On Thu, 14 Sep 2016, Brady Trainor wrote: >If I have a directory `a', and try to rename it `A' in dired, it errors. >`(file-error Renaming Invalid argument /tmp/a /tmp/A/a)'. How did you try to rename it? What exact commands did you input? In Dired i would do this operation using `R' or `wdired' as follows: I) emacs -Q -r M-: (dired temporary-file-directory) RET + a RET R A RET II) emacs -Q -r M-: (dired temporary-file-directory) RET + b RET C-x C-q M-u C-c C-c I have tried both in emacs-24.5.1 and they works as expected. Could you check if I), II) work for you? Tino ^ permalink raw reply [flat|nested] 23+ messages in thread
* bug#24441: 24.5; rename directory in dired to change case 2016-09-15 3:32 bug#24441: 24.5; rename directory in dired to change case Brady Trainor 2016-09-15 9:05 ` Tino Calancha @ 2016-09-15 9:28 ` Andreas Schwab 2016-09-15 13:43 ` Drew Adams 2016-09-15 14:31 ` Eli Zaretskii 2016-11-14 20:33 ` Paul Eggert 2017-05-21 6:17 ` Paul Eggert 3 siblings, 2 replies; 23+ messages in thread From: Andreas Schwab @ 2016-09-15 9:28 UTC (permalink / raw) To: Brady Trainor; +Cc: 24441 On Sep 15 2016, Brady Trainor <brady@bradyt.com> wrote: > If I have a directory `a', and try to rename it `A' in dired, it errors. > > `(file-error Renaming Invalid argument /tmp/a /tmp/A/a)'. That's because your filesystem is case-insensitve, thus /tmp/A already exists. Andreas. -- Andreas Schwab, SUSE Labs, schwab@suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different." ^ permalink raw reply [flat|nested] 23+ messages in thread
* bug#24441: 24.5; rename directory in dired to change case 2016-09-15 9:28 ` Andreas Schwab @ 2016-09-15 13:43 ` Drew Adams 2016-09-15 14:49 ` Eli Zaretskii 2016-09-15 14:31 ` Eli Zaretskii 1 sibling, 1 reply; 23+ messages in thread From: Drew Adams @ 2016-09-15 13:43 UTC (permalink / raw) To: Andreas Schwab, Brady Trainor; +Cc: 24441 > > If I have a directory `a', and try to rename it `A' in dired, it errors. > > `(file-error Renaming Invalid argument /tmp/a /tmp/A/a)'. > > That's because your filesystem is case-insensitve, thus /tmp/A already > exists. FWIW, MS Windows is case-insensitive, but it nevertheless shows files and directories using both uppercase and lowercase letters. And it lets you rename "aa" to "AA", "Aa", etc. The fact that the file already exists does not prevent you from renaming it to use different letter case. And for MS Windows, at least, Emacs supports this as well, including using Dired. ^ permalink raw reply [flat|nested] 23+ messages in thread
* bug#24441: 24.5; rename directory in dired to change case 2016-09-15 13:43 ` Drew Adams @ 2016-09-15 14:49 ` Eli Zaretskii 0 siblings, 0 replies; 23+ messages in thread From: Eli Zaretskii @ 2016-09-15 14:49 UTC (permalink / raw) To: Drew Adams; +Cc: 24441, schwab, brady > Date: Thu, 15 Sep 2016 06:43:21 -0700 (PDT) > From: Drew Adams <drew.adams@oracle.com> > Cc: 24441@debbugs.gnu.org > > FWIW, MS Windows is case-insensitive, but it nevertheless shows > files and directories using both uppercase and lowercase letters. > And it lets you rename "aa" to "AA", "Aa", etc. The fact that > the file already exists does not prevent you from renaming it > to use different letter case. That's because we have special code for that, which is only compiled in the Windows build. ^ permalink raw reply [flat|nested] 23+ messages in thread
* bug#24441: 24.5; rename directory in dired to change case 2016-09-15 9:28 ` Andreas Schwab 2016-09-15 13:43 ` Drew Adams @ 2016-09-15 14:31 ` Eli Zaretskii 1 sibling, 0 replies; 23+ messages in thread From: Eli Zaretskii @ 2016-09-15 14:31 UTC (permalink / raw) To: Andreas Schwab; +Cc: 24441, brady > From: Andreas Schwab <schwab@suse.de> > Date: Thu, 15 Sep 2016 11:28:25 +0200 > Cc: 24441@debbugs.gnu.org > > On Sep 15 2016, Brady Trainor <brady@bradyt.com> wrote: > > > If I have a directory `a', and try to rename it `A' in dired, it errors. > > > > `(file-error Renaming Invalid argument /tmp/a /tmp/A/a)'. > > That's because your filesystem is case-insensitve, thus /tmp/A already > exists. Right. This is a duplicate of bug#22300. As explained there, patches are welcome to introduce a run-time test for case-sensitivity of the underlying filesystem, which then could enable on Darwin the same code as we already use on MS-Windows. ^ permalink raw reply [flat|nested] 23+ messages in thread
* bug#24441: 24.5; rename directory in dired to change case 2016-09-15 3:32 bug#24441: 24.5; rename directory in dired to change case Brady Trainor 2016-09-15 9:05 ` Tino Calancha 2016-09-15 9:28 ` Andreas Schwab @ 2016-11-14 20:33 ` Paul Eggert 2016-11-15 19:59 ` Ken Brown 2017-05-21 6:17 ` Paul Eggert 3 siblings, 1 reply; 23+ messages in thread From: Paul Eggert @ 2016-11-14 20:33 UTC (permalink / raw) To: Ken Brown Cc: Keith David Bershatsky, Andreas Schwab, Brady Trainor, Michael Albinus, 24441 [-- Attachment #1: Type: text/plain, Size: 1351 bytes --] Three comments about that fix. 1. Emacs seems to conflate whether a file system is case-sensitive, and whether it is case-preserving. Darwin pathconf distinguishes between _PC_CASE_SENSITIVE and _PC_CASE_PRESERVING. For example, perhaps the following code in dired-do-create-files: (if (and (file-name-case-insensitive-p (car fn-list)) (eq op-symbol 'move) dired-one-file should also check whether (car fn-list) is on a case-preserving file system (if not, there's no point going ahead, as the user can't change the case anyway). I suppose this would require adding a Lisp predicate for _PC_CASE_PRESERVING. (Possibly the MS-Windows code already deals with this, and Cygwin and macOS are currently broken.) 2. From my reading of the Apple documentation, the code taken from that circa-2007 website should have problems on some file systems. It does not match what Wine does in a similar situation. 3. Nowadays, I hope pathconf works on Apple; that's simpler. If not, I think the Wine approach should be better. So I installed the attached patch to try to do that. If you have access to a case-insensitive file system on macOS, please try it out as-is, or compiled with -DDARWIN_OS_CASE_SENSITIVE_FIXME=1 or -DDARWIN_OS_CASE_SENSITIVE_FIXME=2, and let me know how it works. [-- Attachment #2: 0001-Improve-case-insensitive-checks-Bug-24441.patch --] [-- Type: application/x-patch, Size: 6857 bytes --] ^ permalink raw reply [flat|nested] 23+ messages in thread
* bug#24441: 24.5; rename directory in dired to change case 2016-11-14 20:33 ` Paul Eggert @ 2016-11-15 19:59 ` Ken Brown 2016-11-15 20:30 ` Eli Zaretskii 0 siblings, 1 reply; 23+ messages in thread From: Ken Brown @ 2016-11-15 19:59 UTC (permalink / raw) To: Paul Eggert Cc: Keith David Bershatsky, Andreas Schwab, Brady Trainor, Michael Albinus, 24441 On 11/14/2016 3:33 PM, Paul Eggert wrote: > 1. Emacs seems to conflate whether a file system is case-sensitive, and > whether it is case-preserving. Darwin pathconf distinguishes between > _PC_CASE_SENSITIVE and _PC_CASE_PRESERVING. For example, perhaps the > following code in dired-do-create-files: > > (if (and (file-name-case-insensitive-p (car fn-list)) > (eq op-symbol 'move) > dired-one-file > > should also check whether (car fn-list) is on a case-preserving file > system (if not, there's no point going ahead, as the user can't change > the case anyway). I suppose this would require adding a Lisp predicate > for _PC_CASE_PRESERVING. (Possibly the MS-Windows code already deals > with this, and Cygwin and macOS are currently broken.) I'm not aware of any reported problems on non-case-preserving filesystems. Unless someone reports such a problem, my inclination is to leave things as they are. Ken ^ permalink raw reply [flat|nested] 23+ messages in thread
* bug#24441: 24.5; rename directory in dired to change case 2016-11-15 19:59 ` Ken Brown @ 2016-11-15 20:30 ` Eli Zaretskii 2016-11-30 22:22 ` Ken Brown 0 siblings, 1 reply; 23+ messages in thread From: Eli Zaretskii @ 2016-11-15 20:30 UTC (permalink / raw) To: Ken Brown; +Cc: esq, schwab, brady, eggert, michael.albinus, 24441 > Cc: 24441@debbugs.gnu.org, Brady Trainor <brady@bradyt.com>, > Eli Zaretskii <eliz@gnu.org>, Andreas Schwab <schwab@suse.de>, > Keith David Bershatsky <esq@lawlist.com>, > Michael Albinus <michael.albinus@gmx.de> > From: Ken Brown <kbrown@cornell.edu> > Date: Tue, 15 Nov 2016 14:59:12 -0500 > > On 11/14/2016 3:33 PM, Paul Eggert wrote: > > 1. Emacs seems to conflate whether a file system is case-sensitive, and > > whether it is case-preserving. Darwin pathconf distinguishes between > > _PC_CASE_SENSITIVE and _PC_CASE_PRESERVING. For example, perhaps the > > following code in dired-do-create-files: > > > > (if (and (file-name-case-insensitive-p (car fn-list)) > > (eq op-symbol 'move) > > dired-one-file > > > > should also check whether (car fn-list) is on a case-preserving file > > system (if not, there's no point going ahead, as the user can't change > > the case anyway). I suppose this would require adding a Lisp predicate > > for _PC_CASE_PRESERVING. (Possibly the MS-Windows code already deals > > with this, and Cygwin and macOS are currently broken.) > > I'm not aware of any reported problems on non-case-preserving > filesystems. Unless someone reports such a problem, my inclination is > to leave things as they are. The only case that I know of where a filesystem is case-insensitive, but not case-preserving, is that of DOS FAT16 filesystems, and the MSDOS port of Emacs already considers renaming a file in such a case as a no-op that should not trigger an error. So I think we can safely ignore this hypothetical situation until someone actually describes it. ^ permalink raw reply [flat|nested] 23+ messages in thread
* bug#24441: 24.5; rename directory in dired to change case 2016-11-15 20:30 ` Eli Zaretskii @ 2016-11-30 22:22 ` Ken Brown 0 siblings, 0 replies; 23+ messages in thread From: Ken Brown @ 2016-11-30 22:22 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 24441-done, eggert, schwab, brady, esq, michael.albinus Version: 26.1 There's been no further comment, so I'm closing this bug. Ken ^ permalink raw reply [flat|nested] 23+ messages in thread
* bug#24441: 24.5; rename directory in dired to change case 2016-09-15 3:32 bug#24441: 24.5; rename directory in dired to change case Brady Trainor ` (2 preceding siblings ...) 2016-11-14 20:33 ` Paul Eggert @ 2017-05-21 6:17 ` Paul Eggert 3 siblings, 0 replies; 23+ messages in thread From: Paul Eggert @ 2017-05-21 6:17 UTC (permalink / raw) To: 24441; +Cc: Brady Trainor [-- Attachment #1: Type: text/plain, Size: 636 bytes --] As mentioned in the thread containing this message: http://lists.gnu.org/archive/html/emacs-devel/2017-05/msg00521.html the DARWIN_OS_CASE_SENSITIVE_FIXME code was getting in the way of maintenance, and doesn't seem to be working or needed or used. I attempted to get it to work in the first attached patch (untested), and then removed it as described in the second attached patch. If that code ever turns out to be useful someone can revert the second patch and give my attempt a whirl. As I understand it, the original bug was fixed last year; this email is merely about trying to make the fix easier to maintain. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-Narrow-DARWIN_OS_CASE_SENSITIVE_FIXME-to-1-choice.patch --] [-- Type: text/x-patch; name="0001-Narrow-DARWIN_OS_CASE_SENSITIVE_FIXME-to-1-choice.patch", Size: 5240 bytes --] From 075bd64609446e741a6efbcd6cd6e232db8d1df6 Mon Sep 17 00:00:00 2001 From: Paul Eggert <eggert@cs.ucla.edu> Date: Sat, 20 May 2017 22:51:32 -0700 Subject: [PATCH 1/2] Narrow DARWIN_OS_CASE_SENSITIVE_FIXME to 1 choice * etc/PROBLEMS: Document this (Bug#24441). * src/fileio.c (file_name_case_insensitive_p): Prefer pathconf with _PC_CASE_SENSITIVE, if it works, to DARWIN_OS_CASE_SENSITIVE_FIXME code. Support just one method for DARWIN_OS_CASE_SENSITIVE_FIXME, which matches the Apple documentation more precisely. --- etc/PROBLEMS | 5 ++--- src/fileio.c | 68 ++++++++++++++++++++---------------------------------------- 2 files changed, 24 insertions(+), 49 deletions(-) diff --git a/etc/PROBLEMS b/etc/PROBLEMS index e415887..ff88aa3 100644 --- a/etc/PROBLEMS +++ b/etc/PROBLEMS @@ -2486,9 +2486,8 @@ If you do, please send it to bug-gnu-emacs@gnu.org so we can list it here. The implementation of that function on Mac OS X uses pathconf with the _PC_CASE_SENSITIVE flag. There have been reports that this use of pathconf does not work reliably. If you have a problem, please -recompile Emacs with -D DARWIN_OS_CASE_SENSITIVE_FIXME=1 or --D DARWIN_OS_CASE_SENSITIVE_FIXME=2, and file a bug report saying -whether this fixed your problem. +recompile Emacs with -D DARWIN_OS_CASE_SENSITIVE_FIXME, and file a bug +report saying whether this fixed your problem. * Build-time problems diff --git a/src/fileio.c b/src/fileio.c index e5e3505..17659b6 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -2256,65 +2256,41 @@ static bool file_name_case_insensitive_p (const char *filename) { /* Use pathconf with _PC_CASE_INSENSITIVE or _PC_CASE_SENSITIVE if - those flags are available. As of this writing (2016-11-14), + those flags are available. As of this writing (2017-05-20), Cygwin is the only platform known to support the former (starting - with Cygwin-2.6.1), and Mac OS X is the only platform known to - support the latter. - - There have been reports that pathconf with _PC_CASE_SENSITIVE - does not work reliably on Mac OS X. If you have a problem, - please recompile Emacs with -D DARWIN_OS_CASE_SENSITIVE_FIXME=1 or - -D DARWIN_OS_CASE_SENSITIVE_FIXME=2, and file a bug report saying - whether this fixed your problem. */ + with Cygwin-2.6.1), and macOS is the only platform known to + support the latter. */ #ifdef _PC_CASE_INSENSITIVE int res = pathconf (filename, _PC_CASE_INSENSITIVE); if (res >= 0) return res > 0; -#elif defined _PC_CASE_SENSITIVE && !defined DARWIN_OS_CASE_SENSITIVE_FIXME +#elif defined _PC_CASE_SENSITIVE int res = pathconf (filename, _PC_CASE_SENSITIVE); if (res >= 0) return res == 0; #endif -#ifdef DARWIN_OS -# ifndef DARWIN_OS_CASE_SENSITIVE_FIXME - int DARWIN_OS_CASE_SENSITIVE_FIXME = 0; -# endif + /* There have been reports that pathconf with _PC_CASE_SENSITIVE + does not work reliably on Mac OS X. If you have a problem, + please recompile Emacs with -D DARWIN_OS_CASE_SENSITIVE_FIXME=1 or + -D DARWIN_OS_CASE_SENSITIVE_FIXME=2, and file a bug report saying + whether this fixed your problem. */ - if (DARWIN_OS_CASE_SENSITIVE_FIXME == 1) - { - /* This is based on developer.apple.com's getattrlist man page. */ - struct attrlist alist = {.volattr = ATTR_VOL_CAPABILITIES}; - vol_capabilities_attr_t vcaps; - if (getattrlist (filename, &alist, &vcaps, sizeof vcaps, 0) == 0) - { - if (vcaps.valid[VOL_CAPABILITIES_FORMAT] & VOL_CAP_FMT_CASE_SENSITIVE) - return ! (vcaps.capabilities[VOL_CAPABILITIES_FORMAT] - & VOL_CAP_FMT_CASE_SENSITIVE); - } - } -# if DARWIN_OS_CASE_SENSITIVE_FIXME == 2 - { - /* The following is based on - http://lists.apple.com/archives/darwin-dev/2007/Apr/msg00010.html. - It is normally not even compiled, since it runs afoul of - static checking. See: - http://lists.gnu.org/archive/html/emacs-devel/2017-05/msg00495.html - */ - struct attrlist alist; - unsigned char buffer[sizeof (vol_capabilities_attr_t) + sizeof (size_t)]; - - memset (&alist, 0, sizeof (alist)); - alist.volattr = ATTR_VOL_CAPABILITIES; - if (getattrlist (filename, &alist, buffer, sizeof (buffer), 0) - || !(alist.volattr & ATTR_VOL_CAPABILITIES)) - return 0; - vol_capabilities_attr_t *vcaps = buffer; - return !(vcaps->capabilities[0] & VOL_CAP_FMT_CASE_SENSITIVE); - } +#ifdef DARWIN_OS_CASE_SENSITIVE_FIXME +# ifdef VOL_CAP_FMT_CASE_SENSITIVE + { + struct attrlist alist = {.bitmapcount = ATTR_BIT_MAP_COUNT, + .volattr = ATTR_VOL_INFO | ATTR_VOL_CAPABILITIES}; + struct { uint32_t len; vol_capabilities_attr_t caps; } vcaps + __attribute__ ((aligned (4), packed)); + int i = VOL_CAPABILITIES_FORMAT; + if (getattrlist (filename, &alist, &vcaps, sizeof vcaps, 0) == 0 + && (vcaps.caps.valid[i] & VOL_CAP_FMT_CASE_SENSITIVE)) + return ! (vcaps.caps.capabilities[i] & VOL_CAP_FMT_CASE_SENSITIVE); + } # endif -#endif /* DARWIN_OS */ +#endif #if defined CYGWIN || defined DOS_NT return true; -- 2.7.4 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #3: 0002-Remove-DARWIN_OS_CASE_SENSITIVE_FIXME-code.patch --] [-- Type: text/x-patch; name="0002-Remove-DARWIN_OS_CASE_SENSITIVE_FIXME-code.patch", Size: 2542 bytes --] From b35293dfd0e9dd95a88ac01051655d0d2d105992 Mon Sep 17 00:00:00 2001 From: Paul Eggert <eggert@cs.ucla.edu> Date: Sat, 20 May 2017 22:55:17 -0700 Subject: [PATCH 2/2] Remove DARWIN_OS_CASE_SENSITIVE_FIXME code It does not appear to be needed (Bug#24441). * etc/PROBLEMS: Remove DARWIN_OS_CASE_SENSITIVE_FIXME stuff. * src/fileio.c (file_name_case_insensitive_p): Remove DARWIN_OS_CASE_SENSITIVE_FIXME code. --- etc/PROBLEMS | 10 ---------- src/fileio.c | 21 --------------------- 2 files changed, 31 deletions(-) diff --git a/etc/PROBLEMS b/etc/PROBLEMS index ff88aa3..593eb6b 100644 --- a/etc/PROBLEMS +++ b/etc/PROBLEMS @@ -2479,16 +2479,6 @@ please call support for your X-server and see if you can get a fix. If you do, please send it to bug-gnu-emacs@gnu.org so we can list it here. -* Runtime problems specific to Mac OS X - -** On Mac OS X, file-name-case-insensitive-p may be unreliable - -The implementation of that function on Mac OS X uses pathconf with the -_PC_CASE_SENSITIVE flag. There have been reports that this use of -pathconf does not work reliably. If you have a problem, please -recompile Emacs with -D DARWIN_OS_CASE_SENSITIVE_FIXME, and file a bug -report saying whether this fixed your problem. - * Build-time problems ** Configuration diff --git a/src/fileio.c b/src/fileio.c index 17659b6..c21056e 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -2271,27 +2271,6 @@ file_name_case_insensitive_p (const char *filename) return res == 0; #endif - /* There have been reports that pathconf with _PC_CASE_SENSITIVE - does not work reliably on Mac OS X. If you have a problem, - please recompile Emacs with -D DARWIN_OS_CASE_SENSITIVE_FIXME=1 or - -D DARWIN_OS_CASE_SENSITIVE_FIXME=2, and file a bug report saying - whether this fixed your problem. */ - -#ifdef DARWIN_OS_CASE_SENSITIVE_FIXME -# ifdef VOL_CAP_FMT_CASE_SENSITIVE - { - struct attrlist alist = {.bitmapcount = ATTR_BIT_MAP_COUNT, - .volattr = ATTR_VOL_INFO | ATTR_VOL_CAPABILITIES}; - struct { uint32_t len; vol_capabilities_attr_t caps; } vcaps - __attribute__ ((aligned (4), packed)); - int i = VOL_CAPABILITIES_FORMAT; - if (getattrlist (filename, &alist, &vcaps, sizeof vcaps, 0) == 0 - && (vcaps.caps.valid[i] & VOL_CAP_FMT_CASE_SENSITIVE)) - return ! (vcaps.caps.capabilities[i] & VOL_CAP_FMT_CASE_SENSITIVE); - } -# endif -#endif - #if defined CYGWIN || defined DOS_NT return true; #else -- 2.7.4 ^ permalink raw reply related [flat|nested] 23+ messages in thread
[parent not found: <<m2poo5u9c9.fsf@bradyt.com>]
[parent not found: <<mvmeg4la4w6.fsf@hawking.suse.de>]
[parent not found: <<3c49fbe5-9ae0-4ae2-8fa0-3c44fa85c981@default>]
[parent not found: <<83d1k56wwt.fsf@gnu.org>]
* bug#24441: 24.5; rename directory in dired to change case [not found] ` <<83d1k56wwt.fsf@gnu.org> @ 2016-09-15 14:57 ` Drew Adams 2016-09-15 15:20 ` Eli Zaretskii 0 siblings, 1 reply; 23+ messages in thread From: Drew Adams @ 2016-09-15 14:57 UTC (permalink / raw) To: Eli Zaretskii, Drew Adams; +Cc: 24441, schwab, brady >>>> If I have a directory `a', and try to rename it `A' in dired, it errors. >>>> `(file-error Renaming Invalid argument /tmp/a /tmp/A/a)'. >>> >>> That's because your filesystem is case-insensitve, thus /tmp/A already >>> exists. > > > > FWIW, MS Windows is case-insensitive, but it nevertheless shows > > files and directories using both uppercase and lowercase letters. > > And it lets you rename "aa" to "AA", "Aa", etc. The fact that > > the file already exists does not prevent you from renaming it > > to use different letter case. > > That's because we have special code for that, which is only compiled > in the Windows build. OK. And good. My point was that it is not necessarily the case that, for Emacs, _just because_ a filesystem is case-insensitive, you cannot rename a file to the same name but with a different letter case. It is also the case that, for MS Windows at least, you can do such renaming outside Emacs (with Windows Explorer, for instance). Some other OS might not allow for such renaming. But for at least some OSes such renaming is possible, including for Emacs. ^ permalink raw reply [flat|nested] 23+ messages in thread
* bug#24441: 24.5; rename directory in dired to change case 2016-09-15 14:57 ` Drew Adams @ 2016-09-15 15:20 ` Eli Zaretskii 2016-09-15 16:03 ` Ken Brown 0 siblings, 1 reply; 23+ messages in thread From: Eli Zaretskii @ 2016-09-15 15:20 UTC (permalink / raw) To: Drew Adams; +Cc: 24441, schwab, brady > Date: Thu, 15 Sep 2016 07:57:40 -0700 (PDT) > From: Drew Adams <drew.adams@oracle.com> > Cc: schwab@suse.de, brady@bradyt.com, 24441@debbugs.gnu.org > > My point was that it is not necessarily the case that, for Emacs, > _just because_ a filesystem is case-insensitive, you cannot > rename a file to the same name but with a different letter case. See the bug I pointed to, where John explained that OS X filesystems can be either case-sensitive or case-insensitive. Unlike on Windows, Emacs cannot assume file names are always case-insensitive, so a run-time test is needed, and someone needs to write the code to do it. ^ permalink raw reply [flat|nested] 23+ messages in thread
* bug#24441: 24.5; rename directory in dired to change case 2016-09-15 15:20 ` Eli Zaretskii @ 2016-09-15 16:03 ` Ken Brown 2016-09-15 16:36 ` Eli Zaretskii 0 siblings, 1 reply; 23+ messages in thread From: Ken Brown @ 2016-09-15 16:03 UTC (permalink / raw) To: Eli Zaretskii, Drew Adams; +Cc: 24441, schwab, brady On 9/15/2016 11:20 AM, Eli Zaretskii wrote: >> Date: Thu, 15 Sep 2016 07:57:40 -0700 (PDT) >> From: Drew Adams <drew.adams@oracle.com> >> Cc: schwab@suse.de, brady@bradyt.com, 24441@debbugs.gnu.org >> >> My point was that it is not necessarily the case that, for Emacs, >> _just because_ a filesystem is case-insensitive, you cannot >> rename a file to the same name but with a different letter case. > > See the bug I pointed to, where John explained that OS X filesystems > can be either case-sensitive or case-insensitive. FWIW, this is also true on Cygwin: https://cygwin.com/cygwin-ug-net/using-specialnames.html#pathnames-casesensitive Ken ^ permalink raw reply [flat|nested] 23+ messages in thread
* bug#24441: 24.5; rename directory in dired to change case 2016-09-15 16:03 ` Ken Brown @ 2016-09-15 16:36 ` Eli Zaretskii 2016-11-10 22:25 ` Ken Brown 0 siblings, 1 reply; 23+ messages in thread From: Eli Zaretskii @ 2016-09-15 16:36 UTC (permalink / raw) To: Ken Brown; +Cc: 24441, schwab, brady > Cc: 24441@debbugs.gnu.org, schwab@suse.de, brady@bradyt.com > From: Ken Brown <kbrown@cornell.edu> > Date: Thu, 15 Sep 2016 12:03:08 -0400 > > > See the bug I pointed to, where John explained that OS X filesystems > > can be either case-sensitive or case-insensitive. > > FWIW, this is also true on Cygwin: > > > https://cygwin.com/cygwin-ug-net/using-specialnames.html#pathnames-casesensitive I was under the impression that most or all Cygwin users do use case-sensitive file names. Otherwise, quite a few packages that come from Posix platforms will not work or mysteriously fail. But if that's not the reality, then yes, a patch to add a run-time test for Cygwin will also be welcome. ^ permalink raw reply [flat|nested] 23+ messages in thread
* bug#24441: 24.5; rename directory in dired to change case 2016-09-15 16:36 ` Eli Zaretskii @ 2016-11-10 22:25 ` Ken Brown 2016-11-11 1:42 ` Ken Brown 0 siblings, 1 reply; 23+ messages in thread From: Ken Brown @ 2016-11-10 22:25 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 24441, schwab, brady [-- Attachment #1: Type: text/plain, Size: 981 bytes --] On 9/15/2016 12:36 PM, Eli Zaretskii wrote: >> Cc: 24441@debbugs.gnu.org, schwab@suse.de, brady@bradyt.com >> From: Ken Brown <kbrown@cornell.edu> >> Date: Thu, 15 Sep 2016 12:03:08 -0400 >> >>> See the bug I pointed to, where John explained that OS X filesystems >>> can be either case-sensitive or case-insensitive. >> >> FWIW, this is also true on Cygwin: >> >> >> https://cygwin.com/cygwin-ug-net/using-specialnames.html#pathnames-casesensitive > > I was under the impression that most or all Cygwin users do use > case-sensitive file names. I don't know for sure, but I would guess the opposite, simply because using case-sensitivity requires reading the documentation and changing a registry entry. > But if that's not the reality, then yes, a patch to add a run-time > test for Cygwin will also be welcome. 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. Ken [-- Attachment #2: 0001-Check-case-sensitivity-when-renaming-files.patch --] [-- Type: text/plain, Size: 6724 bytes --] From 56a3c8cfe5d1d0e5ade985db0d570b502ffe8bce Mon Sep 17 00:00:00 2001 From: Ken Brown <kbrown@cornell.edu> Date: Sat, 22 Oct 2016 19:10:18 -0400 Subject: [PATCH] Check case-sensitivity when renaming files * src/fileio.c [DOS_NT || CYGWIN || DARWIN_OS] (file_name_case_insensitive_p, Ffile_name_case_insensitive_p): New functions. (Frename_file): Allow renames that simply change case when the FILE argument is on a case-insensitive filesystem. (Bug#24441) * lisp/dired-aux.el (dired-do-create-files): Use 'file-name-case-insensitive-p' instead of 'system-type' to check for case-insensitivity. (Bug#24441) --- lisp/dired-aux.el | 15 ++++++----- src/fileio.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 75 insertions(+), 15 deletions(-) diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index d25352e..7f0ab78 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -1799,13 +1799,16 @@ dired-do-create-files (concat (if dired-one-file op1 operation) " %s to: ") target-dir op-symbol arg rfn-list default)))) (into-dir (cond ((null how-to) - ;; Allow DOS/Windows users to change the letter - ;; case of a directory. If we don't test these - ;; conditions up front, file-directory-p below - ;; will return t because the filesystem is - ;; case-insensitive, and Emacs will try to move + ;; Allow users to change the letter case of + ;; a directory on a case-insensitive + ;; filesystem. If we don't test these + ;; conditions up front, file-directory-p + ;; below will return t on a case-insensitive + ;; filesystem, and Emacs will try to move ;; foo -> foo/foo, which fails. - (if (and (memq system-type '(ms-dos windows-nt cygwin)) + (if (and (fboundp 'file-name-case-insensitive-p) + (file-name-case-insensitive-p + (expand-file-name (car fn-list))) (eq op-symbol 'move) dired-one-file (string= (downcase diff --git a/src/fileio.c b/src/fileio.c index 6026d8e..a5a6547 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -25,6 +25,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <sys/stat.h> #include <unistd.h> +#ifdef DARWIN_OS +#include <sys/attr.h> +#endif + #ifdef HAVE_PWD_H #include <pwd.h> #endif @@ -2231,6 +2235,50 @@ internal_delete_file (Lisp_Object filename) return NILP (tem); } \f +/* Filesystems are always case-insensitive on MS-Windows and MS-DOS. + They may or may not be case-insensitive on Cygwin and OS X, so we + need a runtime test, if possible. If a test is not available, + assume case-insensitivity on Cygwin and case-sensitivity on OS X. */ +#if defined DOS_NT || defined CYGWIN || defined DARWIN_OS +static bool +file_name_case_insensitive_p (const char *filename) +{ +# ifdef DOS_NT + return 1; +# elif defined CYGWIN +/* As of Cygwin-2.6.1, pathconf supports _PC_CASE_INSENSITIVE. */ +# ifdef _PC_CASE_INSENSITIVE + return pathconf (filename, _PC_CASE_INSENSITIVE) > 0; +# else + return 1; +# endif +# else /* DARWIN_OS */ + /* The following is based on + http://lists.apple.com/archives/darwin-dev/2007/Apr/msg00010.html. */ + struct attrlist alist; + unsigned char buffer[sizeof (vol_capabilities_attr_t) + sizeof (size_t)]; + + memset (&alist, 0, sizeof (alist)); + alist.volattr = ATTR_VOL_CAPABILITIES; + if (getattrlist (filename, &alist, buffer, sizeof (buffer), 0) + || !(alist.volattr & ATTR_VOL_CAPABILITIES)) + return 0; + vol_capabilities_attr_t *vcaps = buffer; + return !(vcaps->capabilities[0] & VOL_CAP_FMT_CASE_SENSITIVE); +# endif /* DARWIN_OS */ +} + +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; +} +#endif /* DOS_NT or CYGWIN or DARWIN_OS */ + 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,10 +2298,12 @@ 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)))) +#if defined DOS_NT || defined CYGWIN || defined DARWIN_OS + /* 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)))) #endif ) { @@ -2276,11 +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)))) +#if defined DOS_NT || defined CYGWIN || defined DARWIN_OS + /* 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)) + || NILP (Fstring_equal (Fdowncase (file), Fdowncase (newname)))) #endif if (NILP (ok_if_already_exists) || INTEGERP (ok_if_already_exists)) @@ -5836,6 +5887,9 @@ syms_of_fileio (void) DEFSYM (Qmake_directory_internal, "make-directory-internal"); DEFSYM (Qmake_directory, "make-directory"); DEFSYM (Qdelete_file, "delete-file"); +#if defined DOS_NT || defined CYGWIN || defined DARWIN_OS + DEFSYM (Qfile_name_case_insensitive_p, "file-name-case-insensitive-p"); +#endif DEFSYM (Qrename_file, "rename-file"); DEFSYM (Qadd_name_to_file, "add-name-to-file"); DEFSYM (Qmake_symbolic_link, "make-symbolic-link"); @@ -6093,6 +6147,9 @@ This includes interactive calls to `delete-file' and defsubr (&Smake_directory_internal); defsubr (&Sdelete_directory_internal); defsubr (&Sdelete_file); +#if defined DOS_NT || defined CYGWIN || defined DARWIN_OS + defsubr (&Sfile_name_case_insensitive_p); +#endif defsubr (&Srename_file); defsubr (&Sadd_name_to_file); defsubr (&Smake_symbolic_link); -- 2.8.3 ^ permalink raw reply related [flat|nested] 23+ messages in thread
* bug#24441: 24.5; rename directory in dired to change case 2016-11-10 22:25 ` Ken Brown @ 2016-11-11 1:42 ` Ken Brown 2016-11-11 8:27 ` Eli Zaretskii 0 siblings, 1 reply; 23+ messages in thread From: Ken Brown @ 2016-11-11 1:42 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 24441, schwab, brady [-- Attachment #1: Type: text/plain, Size: 233 bytes --] 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. Ken [-- Attachment #2: 0001-Check-case-sensitivity-when-renaming-files.patch --] [-- Type: text/plain, Size: 6809 bytes --] From 1ea6720e9d2e34c7ae3632068dde4af13718517b Mon Sep 17 00:00:00 2001 From: Ken Brown <kbrown@cornell.edu> Date: Sat, 22 Oct 2016 19:10:18 -0400 Subject: [PATCH] Check case-sensitivity when renaming files * src/fileio.c (file_name_case_insensitive_p) (Ffile_name_case_insensitive_p): New functions. (Frename_file): Allow renames that simply change case when the FILE argument is on a case-insensitive filesystem. (Bug#24441) * lisp/dired-aux.el (dired-do-create-files): Use 'file-name-case-insensitive-p' instead of 'system-type' to check for case-insensitivity. (Bug#24441) --- lisp/dired-aux.el | 14 +++++----- src/fileio.c | 78 +++++++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 72 insertions(+), 20 deletions(-) diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index d25352e..a94c90b 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -1799,13 +1799,15 @@ dired-do-create-files (concat (if dired-one-file op1 operation) " %s to: ") target-dir op-symbol arg rfn-list default)))) (into-dir (cond ((null how-to) - ;; Allow DOS/Windows users to change the letter - ;; case of a directory. If we don't test these - ;; conditions up front, file-directory-p below - ;; will return t because the filesystem is - ;; case-insensitive, and Emacs will try to move + ;; Allow users to change the letter case of + ;; a directory on a case-insensitive + ;; filesystem. If we don't test these + ;; conditions up front, file-directory-p + ;; below will return t on a case-insensitive + ;; filesystem, and Emacs will try to move ;; foo -> foo/foo, which fails. - (if (and (memq system-type '(ms-dos windows-nt cygwin)) + (if (and (file-name-case-insensitive-p + (expand-file-name (car fn-list))) (eq op-symbol 'move) dired-one-file (string= (downcase diff --git a/src/fileio.c b/src/fileio.c index 6026d8e..aa09feb 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -25,6 +25,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <sys/stat.h> #include <unistd.h> +#ifdef DARWIN_OS +#include <sys/attr.h> +#endif + #ifdef HAVE_PWD_H #include <pwd.h> #endif @@ -2231,6 +2235,53 @@ internal_delete_file (Lisp_Object filename) return NILP (tem); } \f +/* 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) +{ +#ifdef DOS_NT + return 1; +#elif defined CYGWIN +/* As of Cygwin-2.6.1, pathconf supports _PC_CASE_INSENSITIVE. */ +# ifdef _PC_CASE_INSENSITIVE + return pathconf (filename, _PC_CASE_INSENSITIVE) > 0; +# else + return 1; +# endif +#elif defined DARWIN_OS + /* The following is based on + http://lists.apple.com/archives/darwin-dev/2007/Apr/msg00010.html. */ + struct attrlist alist; + unsigned char buffer[sizeof (vol_capabilities_attr_t) + sizeof (size_t)]; + + memset (&alist, 0, sizeof (alist)); + alist.volattr = ATTR_VOL_CAPABILITIES; + if (getattrlist (filename, &alist, buffer, sizeof (buffer), 0) + || !(alist.volattr & ATTR_VOL_CAPABILITIES)) + return 0; + vol_capabilities_attr_t *vcaps = buffer; + return !(vcaps->capabilities[0] & VOL_CAP_FMT_CASE_SENSITIVE); +#else + return 0; +#endif +} + +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; +} + 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))))) { Lisp_Object fname = (NILP (Ffile_directory_p (file)) ? file : Fdirectory_file_name (file)); @@ -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)) + || NILP (Fstring_equal (Fdowncase (file), Fdowncase (newname)))) + && ((NILP (ok_if_already_exists) || INTEGERP (ok_if_already_exists)))) barf_or_query_if_file_exists (newname, false, "rename to it", INTEGERP (ok_if_already_exists), false); if (rename (SSDATA (encoded_file), SSDATA (encoded_newname)) < 0) @@ -5836,6 +5884,7 @@ syms_of_fileio (void) DEFSYM (Qmake_directory_internal, "make-directory-internal"); DEFSYM (Qmake_directory, "make-directory"); DEFSYM (Qdelete_file, "delete-file"); + DEFSYM (Qfile_name_case_insensitive_p, "file-name-case-insensitive-p"); DEFSYM (Qrename_file, "rename-file"); DEFSYM (Qadd_name_to_file, "add-name-to-file"); DEFSYM (Qmake_symbolic_link, "make-symbolic-link"); @@ -6093,6 +6142,7 @@ This includes interactive calls to `delete-file' and defsubr (&Smake_directory_internal); defsubr (&Sdelete_directory_internal); defsubr (&Sdelete_file); + defsubr (&Sfile_name_case_insensitive_p); defsubr (&Srename_file); defsubr (&Sadd_name_to_file); defsubr (&Smake_symbolic_link); -- 2.8.3 ^ permalink raw reply related [flat|nested] 23+ messages in thread
* bug#24441: 24.5; rename directory in dired to change case 2016-11-11 1:42 ` Ken Brown @ 2016-11-11 8:27 ` Eli Zaretskii 2016-11-11 16:23 ` Michael Albinus 2016-11-11 21:42 ` Ken Brown 0 siblings, 2 replies; 23+ messages in thread From: Eli Zaretskii @ 2016-11-11 8:27 UTC (permalink / raw) To: Ken Brown, Michael Albinus; +Cc: 24441, schwab, brady > Cc: 24441@debbugs.gnu.org, schwab@suse.de, brady@bradyt.com > From: Ken Brown <kbrown@cornell.edu> > 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. ^ permalink raw reply [flat|nested] 23+ messages in thread
* bug#24441: 24.5; rename directory in dired to change case 2016-11-11 8:27 ` Eli Zaretskii @ 2016-11-11 16:23 ` Michael Albinus 2016-11-11 21:42 ` Ken Brown 1 sibling, 0 replies; 23+ messages in thread From: Michael Albinus @ 2016-11-11 16:23 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 24441, schwab, brady Eli Zaretskii <eliz@gnu.org> writes: Hi Eli, >> +/* 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 ;-). The same comment as for mounted fileystems is also valid for remote files. Remote smb files could be or could be not case sensitive. The same for remote files on Darwin macOS systems. I don't know whether this could be detected automatically. Furthermore, there are also other file name handlers in game. Think about ange-ftp (ftp connections), think about url-handler-mode (http connections and friends). One cannot know, whether the remote side is case sensitive, or not. In case it cannot be detected trustworthy, one could use default assumptions depending on what the remote side is running. And a user should be able to overwrite this assumption by setting a connection-local variable for a remote machine, like `case-insensitive-p'. Tramp and the orther file name handlers would take this instead of its own heuristic, if this variable exists. > Thanks again for working on this. Best regards, Michael. ^ permalink raw reply [flat|nested] 23+ messages in thread
* bug#24441: 24.5; rename directory in dired to change case 2016-11-11 8:27 ` Eli Zaretskii 2016-11-11 16:23 ` Michael Albinus @ 2016-11-11 21:42 ` Ken Brown 2016-11-12 7:29 ` Eli Zaretskii 1 sibling, 1 reply; 23+ messages in thread From: Ken Brown @ 2016-11-11 21:42 UTC (permalink / raw) To: Eli Zaretskii, Michael Albinus; +Cc: 24441, schwab, brady [-- Attachment #1: Type: text/plain, Size: 3864 bytes --] On 11/11/2016 3:27 AM, Eli Zaretskii wrote: > 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.) Fixed. > 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 ;-). I don't have an immediate idea, but I added a "FIXME" comment and will think about it. >> +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. Fixed. >> 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. Actually, the handlers haven't been called yet at this point in the code, so I left this one alone. >> @@ -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. Fixed. > Finally, please provide a NEWS entry for the new primitive and its > documentation in the ELisp manual. Done, but I'm not sure I found the best place for it in the manual. Thanks for the review. Revised patch attached. Ken [-- Attachment #2: 0001-Check-case-sensitivity-when-renaming-files.patch --] [-- Type: text/plain, Size: 9023 bytes --] From 209e47df634bcbc7e4239b9c7f7b62f17419edbf Mon Sep 17 00:00:00 2001 From: Ken Brown <kbrown@cornell.edu> Date: Sat, 22 Oct 2016 19:10:18 -0400 Subject: [PATCH] Check case-sensitivity when renaming files * src/fileio.c (file_name_case_insensitive_p) (Ffile_name_case_insensitive_p): New functions. (Frename_file): Allow renames that simply change case when the FILE argument is on a case-insensitive filesystem. (Bug#24441) * lisp/dired-aux.el (dired-do-create-files): Use 'file-name-case-insensitive-p' instead of 'system-type' to check for case-insensitivity. (Bug#24441) * doc/lispref/files.texi (File Attributes): Document 'file-name-case-insensitive-p'. --- doc/lispref/files.texi | 14 ++++++++ etc/NEWS | 4 +++ lisp/dired-aux.el | 13 +++---- src/fileio.c | 97 ++++++++++++++++++++++++++++++++++++++++++-------- 4 files changed, 108 insertions(+), 20 deletions(-) diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi index 9af5ce9..037f84f 100644 --- a/doc/lispref/files.texi +++ b/doc/lispref/files.texi @@ -1369,6 +1369,20 @@ File Attributes @end example @end defun +@defun file-name-case-insensitive-p filename +This function returns @code{t} if file @var{filename} is on a +case-insensitive filesystem. This is always the case on MS-DOS and +MS-Windows. On Cygwin and Mac OS X, filesystems may or may not be +case-insensitive, and the function tries to determine case-sensitivity +by a runtime test. If the test is inconclusive, the function returns +@code{t} on Cygwin and @code{nil} on Mac OS X. + +This function always returns @code{nil} on platforms other than +MS-DOS, MS-Windows, Cygwin, and Mac OS X. It does not currently +detect case-insensitivity of mounted filesystems, such as Samba shares +or NFS-mounted Windows volumes. +@end defun + @node Extended Attributes @subsection Extended File Attributes @cindex extended file attributes diff --git a/etc/NEWS b/etc/NEWS index 14450a6..4aea604 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -61,6 +61,10 @@ affected by this, as SGI stopped supporting IRIX in December 2013. \f * Changes in Emacs 26.1 ++++ +** The new function 'file-name-case-insensitive-p' tests whether a +given file is on a case-insensitive filesystem. + --- The group 'wp', whose label was "text", is now deprecated. Use the new group 'text', which inherits from 'wp', instead. diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index d25352e..64ae4a9 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -1799,13 +1799,14 @@ dired-do-create-files (concat (if dired-one-file op1 operation) " %s to: ") target-dir op-symbol arg rfn-list default)))) (into-dir (cond ((null how-to) - ;; Allow DOS/Windows users to change the letter - ;; case of a directory. If we don't test these - ;; conditions up front, file-directory-p below - ;; will return t because the filesystem is - ;; case-insensitive, and Emacs will try to move + ;; Allow users to change the letter case of + ;; a directory on a case-insensitive + ;; filesystem. If we don't test these + ;; conditions up front, file-directory-p + ;; below will return t on a case-insensitive + ;; filesystem, and Emacs will try to move ;; foo -> foo/foo, which fails. - (if (and (memq system-type '(ms-dos windows-nt cygwin)) + (if (and (file-name-case-insensitive-p (car fn-list)) (eq op-symbol 'move) dired-one-file (string= (downcase diff --git a/src/fileio.c b/src/fileio.c index 6026d8e..c26be31 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -25,6 +25,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <sys/stat.h> #include <unistd.h> +#ifdef DARWIN_OS +#include <sys/attr.h> +#endif + #ifdef HAVE_PWD_H #include <pwd.h> #endif @@ -2231,6 +2235,72 @@ internal_delete_file (Lisp_Object filename) return NILP (tem); } \f +/* Filesystems are case-sensitive on all supported systems except + MS-Windows, MS-DOS, Cygwin, and Mac 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 Mac OS X. + + FIXME: Mounted filesystems on Posix hosts, like Samba shares or + NFS-mounted Windows volumes, might be case-insensitive. Can we + detect this? */ + +static bool +file_name_case_insensitive_p (const char *filename) +{ +#ifdef DOS_NT + return 1; +#elif defined CYGWIN +/* As of Cygwin-2.6.1, pathconf supports _PC_CASE_INSENSITIVE. */ +# ifdef _PC_CASE_INSENSITIVE + int res = pathconf (filename, _PC_CASE_INSENSITIVE); + if (res < 0) + return 1; + return res > 0; +# else + return 1; +# endif +#elif defined DARWIN_OS + /* The following is based on + http://lists.apple.com/archives/darwin-dev/2007/Apr/msg00010.html. */ + struct attrlist alist; + unsigned char buffer[sizeof (vol_capabilities_attr_t) + sizeof (size_t)]; + + memset (&alist, 0, sizeof (alist)); + alist.volattr = ATTR_VOL_CAPABILITIES; + if (getattrlist (filename, &alist, buffer, sizeof (buffer), 0) + || !(alist.volattr & ATTR_VOL_CAPABILITIES)) + return 0; + vol_capabilities_attr_t *vcaps = buffer; + return !(vcaps->capabilities[0] & VOL_CAP_FMT_CASE_SENSITIVE); +#else + return 0; +#endif +} + +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) +{ + Lisp_Object handler; + + CHECK_STRING (filename); + filename = Fexpand_file_name (filename, Qnil); + + /* If the file name has special constructs in it, + call the corresponding file handler. */ + handler = Ffind_file_name_handler (filename, Qfile_name_case_insensitive_p); + if (!NILP (handler)) + return call2 (handler, Qfile_name_case_insensitive_p, filename); + + filename = ENCODE_FILE (filename); + return file_name_case_insensitive_p (SSDATA (filename)) ? Qt : Qnil; +} + 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 +2320,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))))) { Lisp_Object fname = (NILP (Ffile_directory_p (file)) ? file : Fdirectory_file_name (file)); @@ -2276,14 +2345,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 ((!(file_name_case_insensitive_p (SSDATA (encoded_file))) + || NILP (Fstring_equal (Fdowncase (file), Fdowncase (newname)))) + && ((NILP (ok_if_already_exists) || INTEGERP (ok_if_already_exists)))) barf_or_query_if_file_exists (newname, false, "rename to it", INTEGERP (ok_if_already_exists), false); if (rename (SSDATA (encoded_file), SSDATA (encoded_newname)) < 0) @@ -5836,6 +5903,7 @@ syms_of_fileio (void) DEFSYM (Qmake_directory_internal, "make-directory-internal"); DEFSYM (Qmake_directory, "make-directory"); DEFSYM (Qdelete_file, "delete-file"); + DEFSYM (Qfile_name_case_insensitive_p, "file-name-case-insensitive-p"); DEFSYM (Qrename_file, "rename-file"); DEFSYM (Qadd_name_to_file, "add-name-to-file"); DEFSYM (Qmake_symbolic_link, "make-symbolic-link"); @@ -6093,6 +6161,7 @@ This includes interactive calls to `delete-file' and defsubr (&Smake_directory_internal); defsubr (&Sdelete_directory_internal); defsubr (&Sdelete_file); + defsubr (&Sfile_name_case_insensitive_p); defsubr (&Srename_file); defsubr (&Sadd_name_to_file); defsubr (&Smake_symbolic_link); -- 2.8.3 ^ permalink raw reply related [flat|nested] 23+ messages in thread
* bug#24441: 24.5; rename directory in dired to change case 2016-11-11 21:42 ` Ken Brown @ 2016-11-12 7:29 ` Eli Zaretskii 2016-11-13 13:14 ` Ken Brown 0 siblings, 1 reply; 23+ messages in thread From: Eli Zaretskii @ 2016-11-12 7:29 UTC (permalink / raw) To: Ken Brown; +Cc: 24441, schwab, michael.albinus, brady > Cc: 24441@debbugs.gnu.org, schwab@suse.de, brady@bradyt.com > From: Ken Brown <kbrown@cornell.edu> > Date: Fri, 11 Nov 2016 16:42:13 -0500 > > > Finally, please provide a NEWS entry for the new primitive and its > > documentation in the ELisp manual. > > Done, but I'm not sure I found the best place for it in the manual. The text is OK, but I think a better place is in the node "Truenames", as that's where we document file-equal-p. To put your description in a proper context, perhaps precede it with a sentence such as "Sometimes file names or their parts need to be compared as strings, in which case it's important to know whether the underlying filesystem is case-insensitive." > Thanks for the review. Revised patch attached. LGTM, thanks. ^ permalink raw reply [flat|nested] 23+ messages in thread
* bug#24441: 24.5; rename directory in dired to change case 2016-11-12 7:29 ` Eli Zaretskii @ 2016-11-13 13:14 ` Ken Brown 2016-11-15 19:58 ` Michael Albinus 0 siblings, 1 reply; 23+ messages in thread From: Ken Brown @ 2016-11-13 13:14 UTC (permalink / raw) To: Eli Zaretskii Cc: 24441, schwab, Keith David Bershatsky, michael.albinus, brady unarchive 22300 merge 24441 22300 thanks On 11/12/2016 2:29 AM, Eli Zaretskii wrote: >> Cc: 24441@debbugs.gnu.org, schwab@suse.de, brady@bradyt.com >> From: Ken Brown <kbrown@cornell.edu> >> Date: Fri, 11 Nov 2016 16:42:13 -0500 >> Thanks for the review. Revised patch attached. > > LGTM, thanks. I've pushed it to master. I'll leave the bug open until someone confirms that this works on OS X. Ken ^ permalink raw reply [flat|nested] 23+ messages in thread
* bug#24441: 24.5; rename directory in dired to change case 2016-11-13 13:14 ` Ken Brown @ 2016-11-15 19:58 ` Michael Albinus 0 siblings, 0 replies; 23+ messages in thread From: Michael Albinus @ 2016-11-15 19:58 UTC (permalink / raw) To: Ken Brown; +Cc: 24441, schwab, Keith David Bershatsky, brady Ken Brown <kbrown@cornell.edu> writes: > I've pushed it to master. I'll leave the bug open until someone > confirms that this works on OS X. I've committed a patch to Tramp, implementing a handler. For the smb method, it always returns t; for all other methods a runtime test is performed (and the result is cached). Implementing a connection-local variable in order to let the user configure this is still open; will do next days. > Ken Best regards, Michael. ^ permalink raw reply [flat|nested] 23+ messages in thread
end of thread, other threads:[~2017-05-21 6:17 UTC | newest] Thread overview: 23+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-09-15 3:32 bug#24441: 24.5; rename directory in dired to change case Brady Trainor 2016-09-15 9:05 ` Tino Calancha 2016-09-15 9:28 ` Andreas Schwab 2016-09-15 13:43 ` Drew Adams 2016-09-15 14:49 ` Eli Zaretskii 2016-09-15 14:31 ` Eli Zaretskii 2016-11-14 20:33 ` Paul Eggert 2016-11-15 19:59 ` Ken Brown 2016-11-15 20:30 ` Eli Zaretskii 2016-11-30 22:22 ` Ken Brown 2017-05-21 6:17 ` Paul Eggert [not found] <<m2poo5u9c9.fsf@bradyt.com> [not found] ` <<mvmeg4la4w6.fsf@hawking.suse.de> [not found] ` <<3c49fbe5-9ae0-4ae2-8fa0-3c44fa85c981@default> [not found] ` <<83d1k56wwt.fsf@gnu.org> 2016-09-15 14:57 ` Drew Adams 2016-09-15 15:20 ` Eli Zaretskii 2016-09-15 16:03 ` Ken Brown 2016-09-15 16:36 ` Eli Zaretskii 2016-11-10 22:25 ` Ken Brown 2016-11-11 1:42 ` Ken Brown 2016-11-11 8:27 ` Eli Zaretskii 2016-11-11 16:23 ` Michael Albinus 2016-11-11 21:42 ` Ken Brown 2016-11-12 7:29 ` Eli Zaretskii 2016-11-13 13:14 ` Ken Brown 2016-11-15 19:58 ` Michael Albinus
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).