unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Philip Kaludercic <philipk@posteo.net>
To: 57102@debbugs.gnu.org
Subject: bug#57102: 29.0.50; Peculiar file-name-split edge case
Date: Wed, 10 Aug 2022 08:24:52 +0000	[thread overview]
Message-ID: <87a68cwlnv.fsf@posteo.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 992 bytes --]


I am not sure if this is intentional, but the new `file-name-split'
is a bit unintuitive in this edge-case:

   (file-name-split "/")        → ("" "" "")

while

   (file-name-split "/a")       → ("" "a")
   (file-name-split "a/")       → ("a" "")
   (file-name-split "a/b")      → ("a" "b")

another few peculiar cases might be

   (file-name-split "//")       → ("/" "" "")
   (file-name-split "///")      → ("" "" "")
   (file-name-split "////")     → ("" "" "")

as I'd expect '/' (in the first case) to never be part of a file name
(at least on a *nix system).

This all appears to happen only if there is no actual file name to be
found:

   (file-name-split "a/")       → ("a" "")
   (file-name-split "a//")      → ("a" "")
   (file-name-split "a///")     → ("a" "")

One simple solution might just be to remove all empty strings from the
return value of `file-name-split', as to my knowledge empty file names
are now allowed (?):


[-- Attachment #2: Type: text/plain, Size: 417 bytes --]

diff --git a/lisp/files.el b/lisp/files.el
index 65f9039b33..c5817be8da 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -5170,7 +5170,7 @@ file-name-split
                   (substring dir 0 -1))
                 components)
           (setq filename nil))))
-    components))
+    (delq "" components)))
 
 (defun file-parent-directory (filename)
   "Return the directory name of the parent directory of FILENAME.

[-- Attachment #3: Type: text/plain, Size: 7794 bytes --]


That should take care of all the inconsistencies I see here, and it
would also preserve the usual intuition that "path///to//file"
designates the same path as "path/to/file".

In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.34, cairo version 1.17.6)
 of 2022-08-01 built on rhea
Repository revision: 47f1cae83c269ea43d6b208e055ce536c017856f
Repository branch: feature/package+vc
System Description: Fedora Linux 36 (Workstation Edition)

Configured using:
 'configure --with-pgtk --with-native-compilation --with-imagemagick'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ IMAGEMAGICK
JPEG JSON LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY
INOTIFY PDUMPER PGTK PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS XIM GTK3 ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: ELisp/l

Minor modes in effect:
  bug-reference-prog-mode: t
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  auto-revert-mode: t
  shell-dirtrack-mode: t
  outline-minor-mode: t
  flymake-mode: t
  flyspell-mode: t
  repeat-mode: t
  diff-hl-flydiff-mode: t
  diff-hl-mode: t
  winner-mode: t
  windmove-mode: t
  corfu-history-mode: t
  corfu-mode: t
  vertico-multiform-mode: t
  vertico-mode: t
  electric-pair-mode: t
  recentf-mode: t
  save-place-mode: t
  savehist-mode: t
  xterm-mouse-mode: t
  pixel-scroll-precision-mode: t
  pixel-scroll-mode: t
  display-time-mode: t
  display-battery-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tab-bar-mode: t
  file-name-shadow-mode: t
  context-menu-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  line-number-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  auto-save-visited-mode: t

Load-path shadows:
/home/philip/.config/emacs/elpa/transient-0.3.7/transient hides /home/philip/Source/emacs/lisp/transient
~/.config/emacs/site-lisp/autoload hides /home/philip/Source/emacs/lisp/emacs-lisp/autoload
/home/philip/Source/emacs/lisp/ps-def hides /home/philip/Source/emacs/lisp/obsolete/ps-def

Features:
(shadow emacsbug flymake-cc cc-mode cc-fonts cc-guess cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs ert loadhist mode-local
help-at-pt emacs-news-mode magit-extras dictionary dictionary-connection
qp timezone flow-fill mailalias smtpmail autocrypt-message ecomplete
ietf-drums-date sort smiley gnus-cite mail-extr textsec uni-scripts
idna-mapping ucs-normalize uni-confusable textsec-check gnus-bcklg
nnfolder modus-vivendi-theme ibuffer ibuffer-loaddefs compat-27
compat-26 compat-25 compat-24 cus-start hyperspec vertico-buffer
make-mode locate doctor files-x shell-command+ cl-print edebug debug
backtrace consult-vertico consult-icomplete consult compat-28
magit-bookmark bookmark macrostep compat-macs avy gnus-async gnus-ml
disp-table autocrypt-gnus autocrypt utf-7 nndraft nnmh epa-file
gnus-agent gnus-srvr gnus-score score-mode nnvirtual gnus-msg nntp
gnus-cache whitespace shortdoc pulse color bug-reference grep xref
copyright time-stamp face-remap magit-submodule magit-obsolete
magit-blame magit-stash magit-reflog magit-bisect magit-push magit-pull
magit-fetch magit-clone magit-remote magit-commit magit-sequence
magit-notes magit-worktree magit-tag magit-merge magit-branch
magit-reset magit-files magit-refs magit-status magit magit-repos
magit-apply magit-wip magit-log which-func imenu magit-diff smerge-mode
git-commit log-edit add-log magit-core magit-autorevert autorevert
magit-margin magit-transient magit-process with-editor shell server
magit-mode transient edmacro kmacro magit-git magit-section magit-utils
crm dash dired-aux gnus-dired vc-hg vc-git vc-bzr vc-src vc-sccs vc-svn
vc-cvs vc-rcs sh-script smie executable vc-backup log-view pcvs-util
buffer-env compat org-element avl-tree generator ol-eww eww xdg
url-queue mm-url ol-rmail ol-mhe ol-irc ol-info ol-gnus nnselect
gnus-art mm-uu mml2015 mm-view mml-smime smime dig gnus-sum shr
pixel-fill kinsoku url-file url-dired svg dom gnus-group gnus-undo
gnus-start gnus-dbus gnus-cloud nnimap nnmail mail-source utf7 netrc
nnoo parse-time gnus-spec gnus-int gnus-range gnus-win ol-docview
doc-view filenotify jka-compr image-mode exif ol-bibtex ol-bbdb ol-w3m
ol-doi org-link-doi org ob ob-tangle ob-ref ob-lob ob-table ob-exp
org-macro org-footnote org-src ob-comint org-pcomplete pcomplete
org-list org-faces org-entities org-version ob-emacs-lisp ob-core
ob-eval org-table oc-basic bibtex iso8601 ol org-keys oc org-compat
advice org-macs org-loaddefs find-func cal-menu calendar cal-loaddefs
char-fold misearch multi-isearch mm-archive message yank-media rfc822
mml mml-sec epa mailabbrev gmm-utils mailheader mm-decode mm-bodies
mm-encode mule-util gnutls network-stream url-cache url-http url-auth
mail-parse rfc2231 url-gw nsm puny display-line-numbers finder-inf
vertico-directory orderless vertico-flat noutline outline checkdoc
flymake-proc flymake thingatpt flyspell ispell comp comp-cstr warnings
auth-source-pass repeat project dired-x sendmail rfc2047 rfc2045
ietf-drums gnus nnheader gnus-util time-date mail-utils range mm-util
mail-prsvr diff-hl-flydiff diff diff-hl vc-dir ewoc vc dired
dired-loaddefs vc-dispatcher diff-mode hippie-exp winner windmove
corfu-history corfu vertico-multiform vertico elec-pair recentf
tree-widget saveplace savehist xt-mouse modus-operandi-theme
modus-themes cus-edit pp icons wid-edit format-spec pixel-scroll
cua-base icomplete time battery dbus xml cus-load setup site-lisp
compile text-property-search comint ansi-color easy-mmode autoload
loaddefs-gen lisp-mnt coterm-autoloads embark-autoloads magit-autoloads
vertico-autoloads buffer-env-autoloads geiser-chibi-autoloads
consult-autoloads compat-autoloads crdt-autoloads corfu-autoloads
slime-autoloads geiser-impl help-fns radix-tree geiser-custom
geiser-base ring transient-autoloads info tex-site package let-alist
derived rx pcase cl-extra help-mode browse-url url url-proxy url-privacy
url-expand url-methods url-history url-cookie generate-lisp-file
url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq
eieio eieio-core cl-macs password-cache json map byte-opt gv bytecomp
byte-compile cconv url-vars epg rfc6068 epg-config subr-x cl-loaddefs
cl-lib rmc iso-transl tooltip eldoc paren electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode mwheel term/pgtk-win pgtk-win
term/common-win pgtk-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer nadvice seq simple cl-generic indonesian philippine
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs faces cus-face macroexp files window
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget keymap hashtable-print-readable backquote threads dbusbind
inotify dynamic-setting system-font-setting font-render-setting cairo
gtk pgtk multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 1305290 153382)
 (symbols 48 47185 40)
 (strings 32 229531 23057)
 (string-bytes 1 7942713)
 (vectors 16 115746)
 (vector-slots 8 2759557 273441)
 (floats 8 843 1462)
 (intervals 56 52420 4538)
 (buffers 992 64))

             reply	other threads:[~2022-08-10  8:24 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-10  8:24 Philip Kaludercic [this message]
2022-08-12 15:35 ` bug#57102: 29.0.50; Peculiar file-name-split edge case Lars Ingebrigtsen
2022-08-12 15:56   ` Philip Kaludercic
2022-08-12 15:59     ` Lars Ingebrigtsen
2022-08-12 16:29       ` Philip Kaludercic
2022-08-13 11:44         ` Lars Ingebrigtsen
2022-08-13 13:24           ` Philip Kaludercic
2022-08-15  5:54             ` Lars Ingebrigtsen
2022-08-15 11:28               ` Lars Ingebrigtsen
2022-08-15 15:57                 ` Philip Kaludercic
2022-08-15 11:35               ` Eli Zaretskii
2022-08-17 10:55                 ` Lars Ingebrigtsen
2022-08-13 18:06           ` Augusto Stoffel
2022-08-14  6:24             ` Philip Kaludercic
2022-08-13 17:08 ` Mattias Engdegård
2022-09-25 12:06   ` Stefan Kangas
2022-09-26 10:41     ` Lars Ingebrigtsen
2022-09-26 11:14       ` Stefan Kangas
2022-09-26 11:59         ` Lars Ingebrigtsen
2022-09-26 12:07         ` Mattias Engdegård
2022-09-26 12:27           ` Gregory Heytings
2022-09-29  3:02             ` Richard Stallman
2022-09-29  6:20               ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a68cwlnv.fsf@posteo.net \
    --to=philipk@posteo.net \
    --cc=57102@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).