From 7384a329d2582e28e28eb8f8e568f7688dceea38 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Sat, 4 Dec 2021 18:43:45 +0100 Subject: [PATCH] Further changes on directory summary line in Tramp * lisp/net/tramp-gvfs.el (tramp-gvfs-handle-file-system-info): Do not assume 0 in case of missing information. * lisp/net/tramp-sh.el (tramp-sh-handle-insert-directory): * lisp/net/tramp-smb.el (tramp-smb-handle-insert-directory): Revert previous change, it doesn't fly. --- lisp/net/tramp-gvfs.el | 10 +++++----- lisp/net/tramp-sh.el | 23 ++++++++++++----------- lisp/net/tramp-smb.el | 14 ++++++-------- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index ab71c9cd13f..22e31428a76 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el @@ -1521,11 +1521,11 @@ If FILE-SYSTEM is non-nil, return file system attributes." (size (cdr (assoc "filesystem::size" attr))) (used (cdr (assoc "filesystem::used" attr))) (free (cdr (assoc "filesystem::free" attr)))) - (when (or size used free) - (list (string-to-number (or size "0")) - (string-to-number (or free "0")) - (- (string-to-number (or size "0")) - (string-to-number (or used "0")))))))) + (when (or size free) + (list (and size (string-to-number size)) + (and free (string-to-number free)) + (and size used + (- (string-to-number size) (string-to-number used)))))))) (defun tramp-gvfs-handle-make-directory (dir &optional parents) "Like `make-directory' for Tramp files." diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 780c3b39413..8d106591af3 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -2678,17 +2678,15 @@ The method used must be an out-of-band method." (point-min) 'noerror) (replace-match (file-relative-name filename) t)) - ;; Try to insert the amount of free space. This is moved to - ;; `dired-insert-directory' in Emacs 29.1. - (unless (boundp 'dired-free-space) - (goto-char (point-min)) - ;; First find the line to put it on. - (when (re-search-forward "^\\([[:space:]]*total\\)" nil t) - (when-let ((available (get-free-disk-space "."))) - ;; Replace "total" with "total used", to avoid confusion. - (replace-match "\\1 used in directory") - (end-of-line) - (insert " available " available))))) + ;; Try to insert the amount of free space. + (goto-char (point-min)) + ;; First find the line to put it on. + (when (re-search-forward "^\\([[:space:]]*total\\)" nil t) + (when-let ((available (get-free-disk-space "."))) + ;; Replace "total" with "total used", to avoid confusion. + (replace-match "\\1 used in directory") + (end-of-line) + (insert " available " available)))) (prog1 (goto-char end-marker) (set-marker beg-marker nil) @@ -6024,5 +6022,8 @@ function cell is returned to be applied on a buffer." ;; be to stipulate, as a directory or connection-local variable, an ;; additional rc file on the remote machine that is sourced every ;; time Tramp connects. +;; +;; * Support hostname canonicalization in ~/.ssh/config. +;; ;;; tramp-sh.el ends here diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index 0a7d1efc8b8..24119539db0 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el @@ -1120,14 +1120,12 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." (setcar x (concat (car x) "*")))))) entries)) - ;; Insert size information. This is moved to - ;; `dired-insert-directory' in Emacs 29.1. - (unless (boundp 'dired-free-space) - (when full-directory-p - (insert - (if avail - (format "total used in directory %s available %s\n" used avail) - (format "total %s\n" used))))) + ;; Insert size information. + (when full-directory-p + (insert + (if avail + (format "total used in directory %s available %s\n" used avail) + (format "total %s\n" used)))) ;; Print entries. (mapc -- 2.39.2