Commit 1d5028ad authored by Michael Albinus's avatar Michael Albinus
Browse files

dired-listing-switches handles connection-local values if exist

* 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'.
parent 213d30b3
Pipeline #27448 failed with stages
in 266 minutes and 52 seconds
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
---
......
......@@ -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)
......
......@@ -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)
......
......@@ -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)
......
......@@ -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
......
......@@ -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 ()
......
......@@ -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)))))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment