[email protected] writes:
Hi Justus,
> In a tramp dired buffer, filenames containing multibyte characters are
> not detected correctly; this also affects filenames below in the listing
> even if they do not contain any multibyte characters themselves.
>
> * Cause:
>
> The directory listing is retrieved in properly-decoded form, while the
> filename location indices produced by --dired count bytes, not chars.
> This causes a misalignment that accumulates through the entire directory
> listing.
Thanks for your analysis. Could you, pls, check whether the appended
patch fixes the problem for you?
Best regards, Michael.
*** /tmp/ediff6YFuhU 2021-01-03 20:05:37.494401938 +0100
--- /home/albinus/src/tramp/lisp/tramp-sh.el 2021-01-03 20:00:33.533762951 +0100
***************
*** 2672,2678 ****
(tramp-get-remote-null-device v))))
(save-restriction
! (let ((beg (point)))
(narrow-to-region (point) (point))
;; We cannot use `insert-buffer-substring' because the Tramp
;; buffer changes its contents before insertion due to calling
--- 2672,2679 ----
(tramp-get-remote-null-device v))))
(save-restriction
! (let ((beg (point))
! (emc enable-multibyte-characters))
(narrow-to-region (point) (point))
;; We cannot use `insert-buffer-substring' because the Tramp
;; buffer changes its contents before insertion due to calling
***************
*** 2681,2687 ****
(with-current-buffer (tramp-get-buffer v)
(buffer-string)))
! ;; Check for "--dired" output.
(forward-line -2)
(when (looking-at-p "//SUBDIRED//")
(forward-line -1))
--- 2682,2690 ----
(with-current-buffer (tramp-get-buffer v)
(buffer-string)))
! ;; Check for "--dired" output. We must enable unibyte
! ;; strings, because the "--dired" output counts in bytes.
! (set-buffer-multibyte nil)
(forward-line -2)
(when (looking-at-p "//SUBDIRED//")
(forward-line -1))
***************
*** 2701,2706 ****
--- 2704,2711 ----
(while (looking-at "//")
(forward-line 1)
(delete-region (match-beginning 0) (point)))
+ ;; Reset multibyte if needed.
+ (set-buffer-multibyte emc)
;; Some busyboxes are reluctant to discard colors.
(unless