[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 1d5028ad041: dired-listing-switches handles connection-local valu
From: |
Michael Albinus |
Subject: |
master 1d5028ad041: dired-listing-switches handles connection-local values if exist |
Date: |
Sun, 10 Dec 2023 06:26:52 -0500 (EST) |
branch: master
commit 1d5028ad0414cad458aac1102d3612e4956068c5
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>
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'.
---
doc/emacs/dired.texi | 4 ++++
doc/lispref/variables.texi | 12 ++++++++----
doc/misc/tramp.texi | 32 +++++++++++++++++++++++++++-----
etc/NEWS | 4 ++++
lisp/dired-x.el | 3 ++-
lisp/dired.el | 10 +++++++---
lisp/files-x.el | 6 ++++--
lisp/files.el | 4 ++--
lisp/man.el | 2 +-
lisp/net/ange-ftp.el | 3 ++-
10 files changed, 61 insertions(+), 19 deletions(-)
diff --git a/doc/emacs/dired.texi b/doc/emacs/dired.texi
index 87124e962ca..6089cfe833d 100644
--- a/doc/emacs/dired.texi
+++ b/doc/emacs/dired.texi
@@ -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
diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi
index bf5fbe84407..36468bddffa 100644
--- a/doc/lispref/variables.texi
+++ b/doc/lispref/variables.texi
@@ -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
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index 5f79c195e42..7a95a6dbc98 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -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
diff --git a/etc/NEWS b/etc/NEWS
index 60391cfb22e..fbfe1084b8f 100644
--- 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
---
diff --git a/lisp/dired-x.el b/lisp/dired-x.el
index 04b3c783084..e094c0b4ca7 100644
--- a/lisp/dired-x.el
+++ b/lisp/dired-x.el
@@ -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)
diff --git a/lisp/dired.el b/lisp/dired.el
index 36ca54efc37..33e38ed2c1c 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -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)
diff --git a/lisp/files-x.el b/lisp/files-x.el
index b2a9cf9bc5e..467981f3f8f 100644
--- a/lisp/files-x.el
+++ b/lisp/files-x.el
@@ -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)
diff --git a/lisp/files.el b/lisp/files.el
index 1cdcec23b11..f87e7807301 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -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
diff --git a/lisp/man.el b/lisp/man.el
index 3efa29d7aad..1a5512c74f4 100644
--- a/lisp/man.el
+++ b/lisp/man.el
@@ -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 ()
diff --git a/lisp/net/ange-ftp.el b/lisp/net/ange-ftp.el
index 3d64b7976b3..4e4db34a78d 100644
--- a/lisp/net/ange-ftp.el
+++ b/lisp/net/ange-ftp.el
@@ -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)))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 1d5028ad041: dired-listing-switches handles connection-local values if exist,
Michael Albinus <=