(tramp-get-remote-null-device v))))
(save-restriction
- (let ((beg (point)))
+ (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
(with-current-buffer (tramp-get-buffer v)
(buffer-string)))
- ;; Check for "--dired" output.
+ ;; 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))
(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
(tmp-name2 (tramp--test-make-temp-name 'local quoted))
(files (delq nil files))
(process-environment process-environment)
- (sorted-files (sort (copy-sequence files) #'string-lessp)))
+ (sorted-files (sort (copy-sequence files) #'string-lessp))
+ buffer)
(unwind-protect
(progn
(make-directory tmp-name1)
tmp-name2 nil directory-files-no-dot-files-regexp))
sorted-files))
+ ;; Check, that `insert-directory' works properly.
+ (with-current-buffer
+ (setq buffer (dired-noselect tmp-name1 "--dired -al"))
+ (goto-char (point-min))
+ (while (not (eobp))
+ (when-let ((name (dired-get-filename 'localp 'no-error)))
+ (unless
+ (string-match-p name directory-files-no-dot-files-regexp)
+ (should (member name files))))
+ (forward-line 1)))
+ (kill-buffer buffer)
+
;; `substitute-in-file-name' could return different
;; values. For `adb', there could be strange file
;; permissions preventing overwriting a file. We don't
(regexp-quote (getenv envvar))))))))))
;; Cleanup.
+ (ignore-errors (kill-buffer buffer))
(ignore-errors (delete-directory tmp-name1 'recursive))
(ignore-errors (delete-directory tmp-name2 'recursive))))))