]> git.eshelyaron.com Git - emacs.git/commitdiff
dired-listing-switches handles connection-local values if exist
authorMichael Albinus <michael.albinus@gmx.de>
Sun, 10 Dec 2023 11:26:38 +0000 (12:26 +0100)
committerMichael Albinus <michael.albinus@gmx.de>
Sun, 10 Dec 2023 11:26:38 +0000 (12:26 +0100)
* doc/emacs/dired.texi (Dired Enter):
* doc/misc/tramp.texi (Frequently Asked Questions):
* etc/NEWS: 'dired-listing-switches' handles connection-local
values if exist.

* doc/lispref/variables.texi (Applying Connection Local Variables):
Fix decription of connection-local-default-application.

* lisp/dired.el (dired-listing-switches): Adapt docstring.
(dired-internal-noselect, dired-mode):
* lisp/dired-x.el (dired-virtual):
* lisp/files.el (recover-file, recover-session):
* lisp/net/ange-ftp.el (ange-ftp-get-files): Use connection-local
value of `dired-listing-switches'.

* lisp/files-x.el (connection-local-value): Adapt docstring.

* lisp/man.el (Man-shell-file-name): Use `connection-local-value'.

doc/emacs/dired.texi
doc/lispref/variables.texi
doc/misc/tramp.texi
etc/NEWS
lisp/dired-x.el
lisp/dired.el
lisp/files-x.el
lisp/files.el
lisp/man.el
lisp/net/ange-ftp.el

index 87124e962cac225050d4527f5cac58d00092ea0b..6089cfe833da0cf64f3cf6485c64b04c57405760 100644 (file)
@@ -142,6 +142,10 @@ characters well.  If you have many such files, you may consider adding
 special characters and allow Dired to handle them better.  (You can
 also use the @kbd{C-u C-x d} command to add @samp{-b} temporarily.)
 
+@code{dired-listing-switches} can be declared as connection-local
+variable to adjust it to match what a remote system expects
+(@pxref{Connection Variables}).
+
 @vindex dired-switches-in-mode-line
   Dired displays in the mode line an indication of what were the
 switches used to invoke @command{ls}.  By default, Dired will try to
index bf5fbe844079bfab513fd9443814b2da75eedb98..36468bddffa5157b246caf1320757ead1e584f39 100644 (file)
@@ -2487,9 +2487,10 @@ are unwound.  Example:
 
 @defvar connection-local-default-application
 The default application, a symbol, to be applied in
-@code{with-connection-local-variables}.  It defaults to @code{tramp},
-but you can let-bind it to change the application temporarily
-(@pxref{Local Variables}).
+@code{with-connection-local-variables} and
+@code{connection-local-value}.  It defaults to @code{tramp}, but you
+can let-bind it to change the application temporarily (@pxref{Local
+Variables}).
 
 This variable must not be changed globally.
 @end defvar
@@ -2547,7 +2548,10 @@ This variable must not be changed globally.
 
 @defmac connection-local-value symbol &optional application
 This macro returns the connection-local value of @var{symbol} for
-@var{application}.  If @var{symbol} does not have a connection-local
+@var{application}.  If @var{application} is @code{nil}, the value of
+@code{connection-local-default-application} is used.
+
+If @var{symbol} does not have a connection-local
 binding, the value is the default binding of the variable.
 @end defmac
 
index 5f79c195e426c211d854bc57defaccb96e4a3a96..7a95a6dbc9800b2692ff7c1b0dd3744f9226a995 100644 (file)
@@ -5322,17 +5322,39 @@ customization is explained in user option
 @item
 Remote host does not understand default options for directory listing
 
-Emacs computes the @command{dired} options based on the local host but
-if the remote host cannot understand the same @command{ls} command,
-then set them with a hook as follows:
+@vindex dired-listing-switches
+Emacs computes the @command{dired} options based on the local host.
+Since @w{Emacs 30}, these options can be set connection-local.
+@ifinfo
+@xref{Connection Variables, , , emacs}.
+@end ifinfo
+
+@lisp
+@group
+(connection-local-set-profile-variables
+  'my-dired-profile
+  '((dired-listing-switches . "-ahl")))
+@end group
+
+@group
+(connection-local-set-profiles
+ '(:application tramp :machine "remotehost")
+ 'my-dired-profile)
+@end group
+@end lisp
+
+@vindex dired-actual-switches
+In older Emacsen, you can set the @command{dired} options with a hook
+as follows:
 
 @lisp
 @group
 (add-hook
  'dired-before-readin-hook
  (lambda ()
-   (when (file-remote-p default-directory)
-     (setq dired-actual-switches "-al"))))
+   (when (string-equal
+           (file-remote-p default-directory 'host) "remotehost")
+     (setq dired-actual-switches "-ahl"))))
 @end group
 @end lisp
 
index 60391cfb22e7d37007aee3f70c3107e69e193b34..fbfe1084b8f8e8961fefb42a0794ad12bfcf393c 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -517,6 +517,10 @@ marked or clicked on files according to the OS conventions.  For
 example, on systems supporting XDG, this runs 'xdg-open' on the
 files.
 
++++
+*** 'dired-listing-switches' handles connection-local values if exist.
+This allows to customize different switches for different remote machines.
+
 ** Ediff
 
 ---
index 04b3c783084f1acf7f1b4beffd190374cd2b6b9e..e094c0b4ca792d19c7d0f2c3df2c6dcbf452af1c 100644 (file)
@@ -613,7 +613,8 @@ you can relist single subdirs using \\[dired-do-redisplay]."
       (insert "  "
              (directory-file-name (file-name-directory default-directory))
              ":\n"))
-  (dired-mode dirname (or switches dired-listing-switches))
+  (dired-mode
+   dirname (or switches (connection-local-value dired-listing-switches)))
   (setq mode-name "Virtual Dired"
         revert-buffer-function 'dired-virtual-revert
         dired-subdir-alist nil)
index 36ca54efc378069239ac4d4367710c6100e7c75a..33e38ed2c1c341e37315706d14f6b61da8ea6a91 100644 (file)
@@ -75,7 +75,9 @@ each option.
 
 On systems such as MS-DOS and MS-Windows, which use `ls' emulation in Lisp,
 some of the `ls' switches are not supported; see the doc string of
-`insert-directory' in `ls-lisp.el' for more details."
+`insert-directory' in `ls-lisp.el' for more details.
+
+For remote Dired buffers, this option supports connection-local values."
   :type 'string
   :group 'dired)
 
@@ -1383,7 +1385,8 @@ The return value is the target column for the file names."
                ;; is passed in directory name syntax
                ;; if it was the name of a directory at all.
                (file-name-directory dirname)))
-      (or switches (setq switches dired-listing-switches))
+      (or switches
+          (setq switches (connection-local-value dired-listing-switches)))
       (if mode (funcall mode)
         (dired-mode dir-or-list switches))
       ;; default-directory and dired-actual-switches are set now
@@ -2714,7 +2717,8 @@ Keybindings:
        (expand-file-name (if (listp dired-directory)
                              (car dired-directory)
                            dired-directory)))
-  (setq-local dired-actual-switches (or switches dired-listing-switches))
+  (setq-local dired-actual-switches
+              (or switches (connection-local-value dired-listing-switches)))
   (setq-local font-lock-defaults
               '(dired-font-lock-keywords t nil nil beginning-of-line))
   (setq-local desktop-save-buffer 'dired-desktop-buffer-misc-data)
index b2a9cf9bc5e682700ab7ddf841a37e455adbd8d8..467981f3f8f3e386eaf317e14d8ca68fbf483616 100644 (file)
@@ -928,8 +928,10 @@ earlier in the `setq-connection-local'.  The return value of the
 ;;;###autoload
 (defmacro connection-local-value (variable &optional application)
   "Return connection-local VARIABLE for APPLICATION in `default-directory'.
-If VARIABLE does not have a connection-local binding, the value
-is the default binding of the variable."
+If APPLICATION is nil, the value of
+`connection-local-default-application' is used.
+If VARIABLE does not have a connection-local binding, the return
+value is the default binding of the variable."
   (unless (symbolp variable)
     (signal 'wrong-type-argument (list 'symbolp variable)))
   `(let (connection-local-variables-alist file-local-variables-alist)
index 1cdcec23b1198a75e3ce5549a878e003d57c8397..f87e7807301a071f3e8257d40a81f22610483e6f 100644 (file)
@@ -7087,7 +7087,7 @@ auto-save file, if that is more recent than the visited file."
                    (when (window-live-p window)
                      (quit-restore-window window 'kill)))))
            (with-current-buffer standard-output
-             (let ((switches dired-listing-switches))
+             (let ((switches (connection-local-value dired-listing-switches)))
                (if (file-symlink-p file)
                    (setq switches (concat switches " -L")))
                ;; Use insert-directory-safely, not insert-directory,
@@ -7139,7 +7139,7 @@ Then you'll be asked about a number of files to recover."
         ;; hook.
         (dired-mode-hook (delete 'dired-omit-mode dired-mode-hook)))
     (dired (concat auto-save-list-file-prefix "*")
-          (concat dired-listing-switches " -t")))
+          (concat (connection-local-value dired-listing-switches) " -t")))
   (use-local-map (nconc (make-sparse-keymap) (current-local-map)))
   (define-key (current-local-map) "\C-c\C-c" 'recover-session-finish)
   (save-excursion
index 3efa29d7aadcc979cb553729a753624eafa141d3..1a5512c74f47053c1ae91e08d71b154be281e3e0 100644 (file)
@@ -579,7 +579,7 @@ Otherwise, the value is whatever the function
 (defun Man-shell-file-name ()
   "Return a proper shell file name, respecting remote directories."
   (or ; This works also in the local case.
-      (with-connection-local-variables shell-file-name)
+      (connection-local-value shell-file-name)
       "/bin/sh"))
 
 (defun Man-header-file-path ()
index 3d64b7976b3df4410f8210fa2d3e80e4aa6accca..4e4db34a78db8a516aa3d30c2e19ddd2cba9fd8c 100644 (file)
@@ -2850,7 +2850,8 @@ NO-ERROR, if a listing for DIRECTORY cannot be obtained."
                                   (ange-ftp-switches-ok dired-actual-switches))
                              (and (boundp 'dired-listing-switches)
                                   (ange-ftp-switches-ok
-                                   dired-listing-switches))
+                                   (connection-local-value
+                                     dired-listing-switches)))
                              "-al")
                          t no-error)
             (gethash directory ange-ftp-files-hashtable)))))