Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
This commit is contained in:
commit
52e49a5616
6 changed files with 84 additions and 25 deletions
|
@ -463,10 +463,11 @@ navigate the buffer but forbids changing it; @xref{View Mode}.
|
|||
@item @@
|
||||
@kindex @@ @r{(Dired)}
|
||||
@findex tramp-dired-find-file-with-sudo
|
||||
Open the file described on the current line, with root permissions
|
||||
(@code{tramp-dired-find-file-with-sudo}). Calling it with the @kbd{C-u}
|
||||
prefix argument asks for another Tramp method interactively but
|
||||
@option{sudo}. @xref{Ad-hoc multi-hops, Tramp,, tramp, The Tramp Manual}.
|
||||
Open the file described on the current line, with superuser, or root,
|
||||
permissions (@code{tramp-dired-find-file-with-sudo}). If called with a
|
||||
@kbd{C-u} prefix argument, it prompts for another Tramp method to use
|
||||
other than the default, @option{sudo}. @xref{Ad-hoc multi-hops, Tramp,,
|
||||
tramp, The Tramp Manual}.
|
||||
|
||||
@item ^
|
||||
@kindex ^ @r{(Dired)}
|
||||
|
|
|
@ -1174,14 +1174,16 @@ the major mode actually turned on as result of reverting a buffer
|
|||
depends on mode remapping, and could be different from the original mode
|
||||
if you customized @code{major-mode-remap-alist} in-between.
|
||||
|
||||
@cindex reverting with superuser permissions
|
||||
@cindex reverting with root permissions
|
||||
@findex tramp-revert-buffer-with-sudo
|
||||
@kindex C-x x @@
|
||||
A variant of reverting a buffer is visiting it by the
|
||||
@code{tramp-revert-buffer-with-sudo} (@kbd{C-x x @@}) command. It
|
||||
reopens the file or Dired buffer with root permissions. With a prefix
|
||||
argument of @kbd{C-u}, you could change the default Tramp method
|
||||
(@option{sudo}). @xref{Ad-hoc multi-hops, Tramp,, tramp, The Tramp Manual}.
|
||||
The @kbd{C-x x @@} keystroke is bound to the
|
||||
@code{tramp-revert-buffer-with-sudo} command. This visits the file
|
||||
again, but with superuser, or root, permissions. If called with a
|
||||
@kbd{C-u} prefix argument, it prompts for another Tramp method to use
|
||||
other than the default, @option{sudo}. @xref{Ad-hoc multi-hops, Tramp,,
|
||||
tramp, The Tramp Manual}.
|
||||
|
||||
@node Auto Revert
|
||||
@section Auto Revert: Keeping buffers automatically up-to-date
|
||||
|
|
|
@ -3935,9 +3935,8 @@ method. The commands @code{tramp-revert-buffer-with-sudo} (@kbd{C-x x
|
|||
|
||||
@kindex C-x x @@
|
||||
@deffn Command tramp-revert-buffer-with-sudo
|
||||
This command shows the current buffer with @option{sudo} permissions.
|
||||
The buffer must either visit a file, or a directory
|
||||
(@code{dired-mode}).
|
||||
This command visits the current buffer with @option{sudo} permissions.
|
||||
The buffer must either visit a file, or a directory in @code{dired-mode}.
|
||||
@end deffn
|
||||
|
||||
@kindex @@ @r{(in dired})
|
||||
|
|
8
etc/NEWS
8
etc/NEWS
|
@ -1084,12 +1084,12 @@ cherry pick via 'tramp-cleanup-connection' or clear them all via
|
|||
+++
|
||||
*** New command 'tramp-dired-find-file-with-sudo'.
|
||||
This command, bound to '@' in Dired, visits the file or directory on the
|
||||
recent Dired line with root permissions.
|
||||
recent Dired line with superuser, or root, permissions.
|
||||
|
||||
+++
|
||||
*** Command 'tramp-revert-buffer-with-sudo' is bound to 'C-x x @' now.
|
||||
Called with the prefix argument 'C-u', the used Tramp method is asked
|
||||
interactively. This happens also for 'tramp-dired-find-file-with-sudo'.
|
||||
*** 'C-x x @' is now bound to 'tramp-revert-buffer-with-sudo'.
|
||||
You can use 'C-u C-x x @' to select a Tramp method other than the
|
||||
default, 'sudo'.
|
||||
|
||||
+++
|
||||
*** Connection method "kubernetes" supports now optional namespace.
|
||||
|
|
|
@ -683,10 +683,21 @@ An alternative method could be chosen with `tramp-file-name-with-method'."
|
|||
(make-tramp-file-name
|
||||
:method tramp-file-name-with-method :localname filename))))
|
||||
|
||||
;; FIXME: We would like to rename this for Emacs 31.1 to a name that
|
||||
;; does not encode the default method. It is intended as a generic
|
||||
;; privilege-elevation command. Some ideas from bug#76974:
|
||||
;; `tramp-revert-buffer-obtain-root',
|
||||
;; `tramp-revert-buffer-as-superuser'.
|
||||
|
||||
;;;###autoload
|
||||
(defun tramp-revert-buffer-with-sudo ()
|
||||
"Revert current buffer to visit with \"sudo\" permissions.
|
||||
An alternative method could be chosen with `tramp-file-name-with-method'.
|
||||
"Visit the current file again with superuser, or root, permissions.
|
||||
|
||||
By default this is done using the \"sudo\" Tramp method.
|
||||
You can customize `tramp-file-name-with-method' to change this.
|
||||
|
||||
Interactively, with a prefix argument, prompt for a different method.
|
||||
|
||||
If the buffer visits a file, the file is replaced.
|
||||
If the buffer runs `dired', the buffer is reverted."
|
||||
(interactive)
|
||||
|
@ -717,11 +728,16 @@ They are completed by `M-x TAB' only in Dired buffers."
|
|||
(with-current-buffer buffer
|
||||
(tramp-dired-buffer-p)))
|
||||
|
||||
;; FIXME: See FIXME above about renaming this before Emacs 31.1.
|
||||
|
||||
;;;###autoload
|
||||
(defun tramp-dired-find-file-with-sudo ()
|
||||
"In Dired, visit the file or directory named on this line.
|
||||
This is performed with \"sudo\" permissions."
|
||||
;; (declare (completion tramp-dired-buffer-command-completion-p))
|
||||
"Visit the file or directory named on this line as the superuser.
|
||||
|
||||
By default this is done using the \"sudo\" Tramp method.
|
||||
YOu can customize `tramp-file-name-with-method' to change this.
|
||||
|
||||
Interactively, with a prefix argument, prompt for a different method."
|
||||
(interactive)
|
||||
(with-tramp-file-name-with-method
|
||||
(find-file (tramp-file-name-with-sudo (dired-get-file-for-visit)))))
|
||||
|
|
|
@ -383,6 +383,43 @@
|
|||
;; Finally, the `so-long-predicate' user option enables the automated behavior
|
||||
;; to be determined by a custom function, if greater control is needed.
|
||||
|
||||
;; * Non-file buffers
|
||||
;; ------------------
|
||||
;; As noted in the introduction, `global-so-long-mode' only affects buffers
|
||||
;; visiting files, and only at the point in time that they are visited. The
|
||||
;; library does not automatically detect if long lines are inserted into an
|
||||
;; existing buffer, which means that non-file buffers are not processed at all
|
||||
;; by the global mode (although the `so-long' command can be invoked manually).
|
||||
;; To handle such buffers additional glue code will be required, and that code
|
||||
;; should likely be specific to the particular use-case to avoid unintended
|
||||
;; behaviours.
|
||||
;;
|
||||
;; An example to handle `compilation-mode' (and derivative) buffers follows:
|
||||
;;
|
||||
;; ;; Trigger `so-long-minor-mode' for long compile output.
|
||||
;; (with-eval-after-load 'compile
|
||||
;; (require 'so-long))
|
||||
;;
|
||||
;; (add-hook 'compilation-mode-hook 'my-so-long-compilation-mode)
|
||||
;;
|
||||
;; (defun my-so-long-compilation-mode ()
|
||||
;; "Add `my-so-long-compilation-filter' to local `compilation-filter-hook'."
|
||||
;; (add-hook 'compilation-filter-hook
|
||||
;; 'my-so-long-compilation-filter nil :local))
|
||||
;;
|
||||
;; (defun my-so-long-compilation-filter ()
|
||||
;; "Maybe call `so-long-minor-mode' during `compilation-filter-hook'."
|
||||
;; (let ((start (save-excursion (goto-char compilation-filter-start)
|
||||
;; (line-beginning-position))))
|
||||
;; (when (> (- (point) start) so-long-threshold)
|
||||
;; (save-restriction
|
||||
;; (narrow-to-region start (point))
|
||||
;; (when (let (so-long-max-lines so-long-skip-leading-comments)
|
||||
;; (funcall so-long-predicate))
|
||||
;; (so-long-minor-mode 1)
|
||||
;; (remove-hook 'compilation-filter-hook
|
||||
;; 'my-so-long-compilation-filter :local))))))
|
||||
|
||||
;; * Implementation notes
|
||||
;; ----------------------
|
||||
;; This library advises `set-auto-mode' (in order to react after Emacs has
|
||||
|
@ -1517,14 +1554,14 @@ The variables are set in accordance with what was remembered in `so-long'."
|
|||
(kill-local-variable variable))))
|
||||
|
||||
(defun so-long-mode-maintain-preserved-variables ()
|
||||
"Set any \"preserved\" variables.
|
||||
"Set variables listed in `so-long-mode-preserved-variables'.
|
||||
|
||||
The variables are set in accordance with what was remembered in `so-long'."
|
||||
(dolist (var (so-long-original 'so-long-mode-preserved-variables))
|
||||
(so-long-restore-variable var)))
|
||||
|
||||
(defun so-long-mode-maintain-preserved-minor-modes ()
|
||||
"Enable or disable \"preserved\" minor modes.
|
||||
"Enable or disable modes listed in `so-long-mode-preserved-minor-modes'.
|
||||
|
||||
The modes are set in accordance with what was remembered in `so-long'."
|
||||
(dolist (mode (so-long-original 'so-long-mode-preserved-minor-modes))
|
||||
|
@ -1716,7 +1753,8 @@ major mode is a member (or derivative of a member) of `so-long-target-modes'.
|
|||
(not so-long--inhibited)
|
||||
(not so-long--calling)
|
||||
(or (eq so-long-target-modes t)
|
||||
(derived-mode-p so-long-target-modes))
|
||||
;; Maintain `derived-mode-p' compatibility with Emacs < 30.
|
||||
(apply #'derived-mode-p so-long-target-modes))
|
||||
(setq so-long-detected-p (funcall so-long-predicate))
|
||||
;; `so-long' should be called; but only if and when the buffer is
|
||||
;; displayed in a window. Long lines in invisible buffers are generally
|
||||
|
@ -2028,7 +2066,10 @@ If it appears in `%s', you should remove it."
|
|||
;; Update to version 1.0 from earlier versions:
|
||||
(when (version< so-long-version "1.0")
|
||||
(remove-hook 'change-major-mode-hook 'so-long-change-major-mode)
|
||||
(require 'advice) ;; It should already be loaded, but just in case.
|
||||
(require 'advice)
|
||||
;; `ad-find-advice' is a macro in Emacs 26 and earlier.
|
||||
(eval-when-compile (when (< emacs-major-version 27)
|
||||
(require 'advice)))
|
||||
(declare-function ad-find-advice "advice")
|
||||
(declare-function ad-remove-advice "advice")
|
||||
(declare-function ad-activate "advice")
|
||||
|
|
Loading…
Add table
Reference in a new issue