all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Why does dired go through extra efforts to avoid unibyte names
@ 2017-12-29 14:34 Stefan Monnier
  2017-12-29 19:17 ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2017-12-29 14:34 UTC (permalink / raw)
  To: Kenichi Handa; +Cc: emacs-devel

I bumped into the following code in dired-get-filename:

	  ;; The above `read' will return a unibyte string if FILE
	  ;; contains eight-bit-control/graphic characters.
	  (if (and enable-multibyte-characters
		   (not (multibyte-string-p file)))
	      (setq file (string-to-multibyte file)))

and I'm wondering why we don't want a unibyte string here.
`vc-region-history` told me this comes from the commit appended below,
which seems to indicate that we're worried about a subsequent encoding,
but AFAIK unibyte file names are not (re)encoded, and passing them
through string-to-multibyte would actually make things worse in this
respect (since it might cause the kind of (re)encoding this is
supposedly trying to avoid).

What am I missing?


        Stefan


commit 038b550196d92b9844a4efecf1c2ded0f920e957
Author: Kenichi Handa <handa@m17n.org>
Date:   Wed Mar 19 11:58:25 2003 +0000

    * dired.el (dired-get-filename): Pay attention to the case that
    `read' returns a unibyte string.  Don't encode the file name by
    buffer-file-coding-system.

diff --git a/lisp/dired.el b/lisp/dired.el
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -1455,11 +1455,16 @@
 	  ;; Using read to unquote is much faster than substituting
 	  ;; \007 (4 chars) -> ^G  (1 char) etc. in a lisp loop.
 	  (setq file
 		(read
 		 (concat "\""
 			 ;; Some ls -b don't escape quotes, argh!
 			 ;; This is not needed for GNU ls, though.
 			 (or (dired-string-replace-match
 			      "\\([^\\]\\|\\`\\)\"" file "\\1\\\\\"" nil t)
 			     file)
-			 "\"")))))
+			 "\"")))
+	  ;; The above `read' will return a unibyte string if FILE
+	  ;; contains eight-bit-control/graphic characters.
+	  (if (and enable-multibyte-characters
+		   (not (multibyte-string-p file)))
+	      (setq file (string-to-multibyte file)))))




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-01-05 18:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-29 14:34 Why does dired go through extra efforts to avoid unibyte names Stefan Monnier
2017-12-29 19:17 ` Eli Zaretskii
2018-01-03  4:14   ` Stefan Monnier
2018-01-03 15:10     ` Eli Zaretskii
2018-01-03 20:09       ` Stefan Monnier
2018-01-05  9:10         ` Eli Zaretskii
2018-01-05 16:12           ` Stefan Monnier
2018-01-05 18:14             ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.