diff options
| -rw-r--r-- | doc/emacs/dired.texi | 8 | ||||
| -rw-r--r-- | doc/emacs/files.texi | 9 | ||||
| -rw-r--r-- | doc/misc/tramp.texi | 24 | ||||
| -rw-r--r-- | etc/NEWS | 76 | ||||
| -rw-r--r-- | lisp/bindings.el | 3 | ||||
| -rw-r--r-- | lisp/dired.el | 1 | ||||
| -rw-r--r-- | lisp/net/tramp-cmds.el | 55 |
7 files changed, 119 insertions, 57 deletions
diff --git a/doc/emacs/dired.texi b/doc/emacs/dired.texi index 07142e71713..f52b001c121 100644 --- a/doc/emacs/dired.texi +++ b/doc/emacs/dired.texi | |||
| @@ -460,6 +460,14 @@ View the file described on the current line, with View mode | |||
| 460 | (@code{dired-view-file}). View mode provides convenient commands to | 460 | (@code{dired-view-file}). View mode provides convenient commands to |
| 461 | navigate the buffer but forbids changing it; @xref{View Mode}. | 461 | navigate the buffer but forbids changing it; @xref{View Mode}. |
| 462 | 462 | ||
| 463 | @item @@ | ||
| 464 | @kindex @@ @r{(Dired)} | ||
| 465 | @findex tramp-dired-find-file-with-sudo | ||
| 466 | Open the file described on the current line, with root permissions | ||
| 467 | (@code{tramp-dired-find-file-with-sudo}). Calling it with the @kbd{C-u} | ||
| 468 | prefix argument asks for another Tramp method interactively but | ||
| 469 | @option{sudo}. @xref{Ad-hoc multi-hops, Tramp,, tramp, The Tramp Manual}. | ||
| 470 | |||
| 463 | @item ^ | 471 | @item ^ |
| 464 | @kindex ^ @r{(Dired)} | 472 | @kindex ^ @r{(Dired)} |
| 465 | @findex dired-up-directory | 473 | @findex dired-up-directory |
diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi index d11d7767353..9b2ce5c5ee2 100644 --- a/doc/emacs/files.texi +++ b/doc/emacs/files.texi | |||
| @@ -1174,6 +1174,15 @@ the major mode actually turned on as result of reverting a buffer | |||
| 1174 | depends on mode remapping, and could be different from the original mode | 1174 | depends on mode remapping, and could be different from the original mode |
| 1175 | if you customized @code{major-mode-remap-alist} in-between. | 1175 | if you customized @code{major-mode-remap-alist} in-between. |
| 1176 | 1176 | ||
| 1177 | @cindex reverting with root permissions | ||
| 1178 | @findex tramp-revert-buffer-with-sudo | ||
| 1179 | @kindex C-x x @@ | ||
| 1180 | A variant of reverting a buffer is visiting it by the | ||
| 1181 | @code{tramp-revert-buffer-with-sudo} (@kbd{C-x x @@}) command. It | ||
| 1182 | reopens the file or Dired buffer with root permissions. With a prefix | ||
| 1183 | argument of @kbd{C-u}, you could change the default Tramp method | ||
| 1184 | (@option{sudo}). @xref{Ad-hoc multi-hops, Tramp,, tramp, The Tramp Manual}. | ||
| 1185 | |||
| 1177 | @node Auto Revert | 1186 | @node Auto Revert |
| 1178 | @section Auto Revert: Keeping buffers automatically up-to-date | 1187 | @section Auto Revert: Keeping buffers automatically up-to-date |
| 1179 | @cindex Global Auto Revert mode | 1188 | @cindex Global Auto Revert mode |
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi index 81feb56ec31..6e66de552de 100644 --- a/doc/misc/tramp.texi +++ b/doc/misc/tramp.texi | |||
| @@ -3928,23 +3928,31 @@ containers on the remote host. | |||
| 3928 | 3928 | ||
| 3929 | A common use case for ad-hoc specifications is to visit a file or a | 3929 | A common use case for ad-hoc specifications is to visit a file or a |
| 3930 | directory with proper permissions, for example with the @option{sudo} | 3930 | directory with proper permissions, for example with the @option{sudo} |
| 3931 | method. The command @code{tramp-revert-buffer-with-sudo} supports | 3931 | method. The commands @code{tramp-revert-buffer-with-sudo} (@kbd{C-x x |
| 3932 | this. | 3932 | @@}), and @code{tramp-dired-find-file-with-sudo} (@kbd{@@} in |
| 3933 | @code{dired-mode}) support this. | ||
| 3933 | 3934 | ||
| 3935 | @kindex C-x x @@ | ||
| 3934 | @deffn Command tramp-revert-buffer-with-sudo | 3936 | @deffn Command tramp-revert-buffer-with-sudo |
| 3935 | This command shows the current buffer with @option{sudo} permissions. | 3937 | This command shows the current buffer with @option{sudo} permissions. |
| 3936 | The buffer must either visit a file, or a directory | 3938 | The buffer must either visit a file, or a directory |
| 3937 | (@code{dired-mode}). | 3939 | (@code{dired-mode}). |
| 3938 | @end deffn | 3940 | @end deffn |
| 3939 | 3941 | ||
| 3942 | @kindex @@ @r{(in dired}) | ||
| 3943 | @deffn Command tramp-dired-find-file-with-sudo | ||
| 3944 | In @code{dired-mode}, visit the file or directory named on this line. | ||
| 3945 | This is performed with @option{sudo} permissions. | ||
| 3946 | @end deffn | ||
| 3947 | |||
| 3940 | @defopt tramp-file-name-with-method | 3948 | @defopt tramp-file-name-with-method |
| 3941 | The method @code{tramp-revert-buffer-with-sudo} shows an alternate | 3949 | The method used in @code{tramp-revert-buffer-with-sudo} and |
| 3942 | buffer. It defaults to @option{sudo}, other valid methods are | 3950 | @code{tramp-dired-find-file-with-sudo}. It defaults to @option{sudo}, |
| 3943 | @option{su}, @option{doas}, @option{run0}, and @option{ksu}. | 3951 | other valid methods are @option{su}, @option{doas}, @option{run0}, and |
| 3952 | @option{ksu}. | ||
| 3944 | 3953 | ||
| 3945 | @lisp | 3954 | If a command is called with a prefix argument @kbd{C-u}, the option's |
| 3946 | (customize-set-variable 'tramp-file-name-with-method "doas") | 3955 | value is read interactively. |
| 3947 | @end lisp | ||
| 3948 | @end defopt | 3956 | @end defopt |
| 3949 | 3957 | ||
| 3950 | These methods apply the user @samp{root} as default. If another user | 3958 | These methods apply the user @samp{root} as default. If another user |
| @@ -285,7 +285,6 @@ return value windows whose buffers share their text with BUFFER-OR-NAME. | |||
| 285 | With such an entry, 'display-buffer-reuse-window' may also choose a | 285 | With such an entry, 'display-buffer-reuse-window' may also choose a |
| 286 | window whose buffer shares text with the buffer to display. | 286 | window whose buffer shares text with the buffer to display. |
| 287 | 287 | ||
| 288 | |||
| 289 | ** Frames | 288 | ** Frames |
| 290 | 289 | ||
| 291 | +++ | 290 | +++ |
| @@ -294,7 +293,7 @@ Calling this function before 'delete-frame' is useful to avoid that the | |||
| 294 | latter throws an error when the argument FRAME cannot be deleted. | 293 | latter throws an error when the argument FRAME cannot be deleted. |
| 295 | 294 | ||
| 296 | +++ | 295 | +++ |
| 297 | *** New value 'force' for option `frame-inhibit-implied-resize'. | 296 | *** New value 'force' for user option 'frame-inhibit-implied-resize'. |
| 298 | This will inhibit implied resizing while a new frame is made and can be | 297 | This will inhibit implied resizing while a new frame is made and can be |
| 299 | useful on tiling window managers where the initial frame size should be | 298 | useful on tiling window managers where the initial frame size should be |
| 300 | specified by external means. | 299 | specified by external means. |
| @@ -363,8 +362,6 @@ invoked standalone or from the 'project-switch-commands' dispatch menu. | |||
| 363 | This user option describes projects that should always be skipped by | 362 | This user option describes projects that should always be skipped by |
| 364 | 'project-remember-project'. | 363 | 'project-remember-project'. |
| 365 | 364 | ||
| 366 | *** | ||
| 367 | |||
| 368 | ** Registers | 365 | ** Registers |
| 369 | 366 | ||
| 370 | *** New functions 'buffer-to-register' and 'file-to-register'. | 367 | *** New functions 'buffer-to-register' and 'file-to-register'. |
| @@ -396,14 +393,14 @@ please contact us if you still need it for some reason. | |||
| 396 | 393 | ||
| 397 | --- | 394 | --- |
| 398 | ** Modified settings for an enabled theme now apply immediately. | 395 | ** Modified settings for an enabled theme now apply immediately. |
| 399 | Evaluating a custom-theme-set-faces or custom-theme-set-variables | 396 | Evaluating a 'custom-theme-set-faces' or 'custom-theme-set-variables' |
| 400 | call for an enabled theme causes the settings to apply immediately, | 397 | call for an enabled theme causes the settings to apply immediately, |
| 401 | without a need to re-load the theme. | 398 | without a need to re-load the theme. |
| 402 | 399 | ||
| 403 | --- | 400 | --- |
| 404 | ** 'describe-variable' now automatically says if 'setopt' is needed. | 401 | ** 'describe-variable' now automatically says if 'setopt' is needed. |
| 405 | If a user option has a defcustom :set function, users will normally need | 402 | If a user option has a defcustom ':set' function, users will normally |
| 406 | to set it with 'setopt' for it to take an effect. If the docstring | 403 | need to set it with 'setopt' for it to take an effect. If the docstring |
| 407 | doesn't already mention 'setopt', the 'describe-variable' command will | 404 | doesn't already mention 'setopt', the 'describe-variable' command will |
| 408 | now add a note about this automatically. | 405 | now add a note about this automatically. |
| 409 | 406 | ||
| @@ -545,6 +542,7 @@ default is nil, which retains the old format. | |||
| 545 | *** The terminal emulator now supports auto-margins control. | 542 | *** The terminal emulator now supports auto-margins control. |
| 546 | Term mode now handles DECAWM escape sequences that control whether text | 543 | Term mode now handles DECAWM escape sequences that control whether text |
| 547 | automatically wraps at the right margin: | 544 | automatically wraps at the right margin: |
| 545 | |||
| 548 | - \e[?7h enables auto-margins (default) | 546 | - \e[?7h enables auto-margins (default) |
| 549 | - \e[?7l disables auto-margins | 547 | - \e[?7l disables auto-margins |
| 550 | 548 | ||
| @@ -603,12 +601,13 @@ Emacs 25.1), and gnudoit (obsolete since Emacs 25.1). | |||
| 603 | *** Some cl-lib functions and macros are now built-in. | 601 | *** Some cl-lib functions and macros are now built-in. |
| 604 | These functions or macros have been added to Emacs Lisp, and the old | 602 | These functions or macros have been added to Emacs Lisp, and the old |
| 605 | names are now aliases for the built-in equivalents: | 603 | names are now aliases for the built-in equivalents: |
| 606 | - 'cl-incf' renamed to 'incf' | 604 | |
| 607 | - 'cl-decf' renamed to 'decf' | 605 | - 'cl-incf' renamed to 'incf' |
| 608 | - 'cl-oddp' renamed to 'oddp' | 606 | - 'cl-decf' renamed to 'decf' |
| 609 | - 'cl-evenp' renamed to 'evenp' | 607 | - 'cl-oddp' renamed to 'oddp' |
| 610 | - 'cl-plusp' renamed to 'plusp' | 608 | - 'cl-evenp' renamed to 'evenp' |
| 611 | - 'cl-minusp' renamed to 'minusp' | 609 | - 'cl-plusp' renamed to 'plusp' |
| 610 | - 'cl-minusp' renamed to 'minusp' | ||
| 612 | 611 | ||
| 613 | The old names are considered deprecated, and will be marked as obsolete | 612 | The old names are considered deprecated, and will be marked as obsolete |
| 614 | in some future release. | 613 | in some future release. |
| @@ -687,6 +686,7 @@ minibuffer use, they are now saved only once in the file specified by | |||
| 687 | 'savehist-file'. Previously, they were saved twice. | 686 | 'savehist-file'. Previously, they were saved twice. |
| 688 | 687 | ||
| 689 | ** Rectangle Mark | 688 | ** Rectangle Mark |
| 689 | |||
| 690 | --- | 690 | --- |
| 691 | *** New user option to control whether empty rectangle selections are shown. | 691 | *** New user option to control whether empty rectangle selections are shown. |
| 692 | The new user option 'rectangle-indicate-zero-width-rectangle' can be | 692 | The new user option 'rectangle-indicate-zero-width-rectangle' can be |
| @@ -740,9 +740,8 @@ It removes all the buttons in the specified region. | |||
| 740 | 740 | ||
| 741 | ** Shell | 741 | ** Shell |
| 742 | 742 | ||
| 743 | --- | 743 | +++ |
| 744 | *** Shell buffers now support bookmarks. | 744 | *** Shell buffers now support bookmarks. |
| 745 | |||
| 746 | You can now bookmark local and remote shell buffers using the bookmark | 745 | You can now bookmark local and remote shell buffers using the bookmark |
| 747 | menu 'bookmark-bmenu-list', or by using the command 'bookmark-set'. | 746 | menu 'bookmark-bmenu-list', or by using the command 'bookmark-set'. |
| 748 | Shell bookmarks can be loaded via the menu and by using the command | 747 | Shell bookmarks can be loaded via the menu and by using the command |
| @@ -1021,7 +1020,7 @@ positives. | |||
| 1021 | 1020 | ||
| 1022 | --- | 1021 | --- |
| 1023 | *** IELM input history is now saved also when the IELM process is killed. | 1022 | *** IELM input history is now saved also when the IELM process is killed. |
| 1024 | When you kill the IELM process with "C-c C-c", the input history is now | 1023 | When you kill the IELM process with 'C-c C-c', the input history is now |
| 1025 | saved to the file specified by 'ielm-history-file-name', just like when | 1024 | saved to the file specified by 'ielm-history-file-name', just like when |
| 1026 | you exit the Emacs session or kill the IELM buffer. | 1025 | you exit the Emacs session or kill the IELM buffer. |
| 1027 | 1026 | ||
| @@ -1077,6 +1076,16 @@ cherry pick via 'tramp-cleanup-connection' or clear them all via | |||
| 1077 | 'tramp-cleanup-all-connections'. | 1076 | 'tramp-cleanup-all-connections'. |
| 1078 | 1077 | ||
| 1079 | +++ | 1078 | +++ |
| 1079 | *** New command 'tramp-dired-find-file-with-sudo'. | ||
| 1080 | This command, bound to '@' in Dired, visits the file or directory on the | ||
| 1081 | recent Dired line with root permissions. | ||
| 1082 | |||
| 1083 | +++ | ||
| 1084 | *** Command 'tramp-revert-buffer-with-sudo' is bound to 'C-x x @' now. | ||
| 1085 | Called with the prefix argument 'C-u', the used Tramp method is asked | ||
| 1086 | interactively. This happens also for 'tramp-dired-find-file-with-sudo'. | ||
| 1087 | |||
| 1088 | +++ | ||
| 1080 | *** Connection method "kubernetes" supports now optional namespace. | 1089 | *** Connection method "kubernetes" supports now optional namespace. |
| 1081 | The host name for Kubernetes connections can be of kind | 1090 | The host name for Kubernetes connections can be of kind |
| 1082 | [CONTAINER.]POD[%NAMESPACE], in order to specify the namespace to be | 1091 | [CONTAINER.]POD[%NAMESPACE], in order to specify the namespace to be |
| @@ -1371,19 +1380,19 @@ the directory into which the repository was cloned. | |||
| 1371 | *** 'C-x v u' ('vc-revert') now works on directories listed in VC Directory. | 1380 | *** 'C-x v u' ('vc-revert') now works on directories listed in VC Directory. |
| 1372 | Reverting a directory means reverting changes to all files inside it. | 1381 | Reverting a directory means reverting changes to all files inside it. |
| 1373 | 1382 | ||
| 1374 | *** New function 'log-edit-done-strip-cvs-lines'. | 1383 | *** New command 'log-edit-done-strip-cvs-lines'. |
| 1375 | This function strips all lines beginning with "CVS:" from the buffer. | 1384 | This command strips all lines beginning with "CVS:" from the buffer. |
| 1376 | It is intended to be added to the 'log-edit-done-hook' so that | 1385 | It is intended to be added to the 'log-edit-done-hook' so that |
| 1377 | 'vc-cvs-checkin' behaves like invoking "cvs commit [files...]" from the | 1386 | 'vc-cvs-checkin' behaves like invoking 'cvs commit [files...]' from the |
| 1378 | command line. | 1387 | command line. |
| 1379 | 1388 | ||
| 1380 | ** Diff mode | 1389 | ** Diff mode |
| 1381 | 1390 | ||
| 1382 | +++ | 1391 | +++ |
| 1383 | *** diff-apply-buffer now considers the region and can reverse-apply. | 1392 | *** 'diff-apply-buffer' now considers the region and can reverse-apply. |
| 1384 | If the region is active, this command now applies all hunks that the | 1393 | If the region is active, this command now applies all hunks that the |
| 1385 | region overlaps; otherwise, it applies all hunks. | 1394 | region overlaps; otherwise, it applies all hunks. |
| 1386 | With a prefix arguments, it now reverse-applies the hunks. | 1395 | With a prefix argument, it now reverse-applies the hunks. |
| 1387 | This matches the existing prefix argument to 'diff-apply-hunk'. | 1396 | This matches the existing prefix argument to 'diff-apply-hunk'. |
| 1388 | 1397 | ||
| 1389 | ** Package | 1398 | ** Package |
| @@ -1448,13 +1457,13 @@ runs its body, and removes the current buffer from | |||
| 1448 | ** Strokes | 1457 | ** Strokes |
| 1449 | 1458 | ||
| 1450 | -- | 1459 | -- |
| 1451 | ** 'strokes-mode' no longer demands the presence of a mouse. | 1460 | *** 'strokes-mode' no longer demands the presence of a mouse. |
| 1452 | 'strokes-mode' now permits itself to be enabled if no mouse is | 1461 | 'strokes-mode' now permits itself to be enabled if no mouse is |
| 1453 | connected, to facilitate enabling 'strokes-mode' in sessions where the | 1462 | connected, to facilitate enabling 'strokes-mode' in sessions where the |
| 1454 | availability of a mouse device varies during execution (as is frequently | 1463 | availability of a mouse device varies during execution (as is frequently |
| 1455 | observed on Android). | 1464 | observed on Android). |
| 1456 | 1465 | ||
| 1457 | ** Yank media | 1466 | ** Yank Media |
| 1458 | 1467 | ||
| 1459 | +++ | 1468 | +++ |
| 1460 | *** 'yank-media' now auto-selects the most preferred MIME type. | 1469 | *** 'yank-media' now auto-selects the most preferred MIME type. |
| @@ -1472,7 +1481,7 @@ the 'remember-buffer'. This allows users to customize the major mode | |||
| 1472 | used to write notes. | 1481 | used to write notes. |
| 1473 | 1482 | ||
| 1474 | --- | 1483 | --- |
| 1475 | *** New handler that append remember data in directory. | 1484 | *** New handler that appends remember data in directory. |
| 1476 | The 'remember-append-in-data-directory' handler appends remember data in | 1485 | The 'remember-append-in-data-directory' handler appends remember data in |
| 1477 | a file, that file being choosen by the user through the minibuffer. | 1486 | a file, that file being choosen by the user through the minibuffer. |
| 1478 | 1487 | ||
| @@ -1593,28 +1602,28 @@ restore the old behavior, you can set 'eshell-pwd-convert-function' to | |||
| 1593 | 'identity'. | 1602 | 'identity'. |
| 1594 | 1603 | ||
| 1595 | --- | 1604 | --- |
| 1596 | ** The rx 'eval' form now uses the current elisp dialect for evaluation. | 1605 | ** The rx 'eval' form now uses the current Elisp dialect for evaluation. |
| 1597 | Previously, its argument was always evaluated using dynamic binding. | 1606 | Previously, its argument was always evaluated using dynamic binding. |
| 1598 | 1607 | ||
| 1599 | 1608 | ||
| 1600 | * Lisp Changes in Emacs 31.1 | 1609 | * Lisp Changes in Emacs 31.1 |
| 1601 | 1610 | ||
| 1602 | +++ | 1611 | +++ |
| 1603 | ** New macros 'static-when' and 'static-unless' implement conditional | 1612 | ** New macros 'static-when' and 'static-unless'. |
| 1604 | compilation like 'static-if'. | 1613 | Like 'static-if', these macros evaluate their condition at |
| 1605 | These macros evaluate their condition at macro-expansion time and are useful | 1614 | macro-expansion time and are useful for writing code that can work |
| 1606 | for writing code that can work across different Emacs versions. | 1615 | across different Emacs versions. |
| 1607 | 1616 | ||
| 1608 | --- | 1617 | --- |
| 1609 | ** You can change the default value of 'lexical-binding'. | 1618 | ** You can change the default value of 'lexical-binding'. |
| 1610 | While the default is still the use dynamic binding dialect of Elisp | 1619 | While the default is still the use of dynamic binding dialect of Elisp |
| 1611 | in those places that don't explicitly set 'lexical-binding' you can | 1620 | in those places that don't explicitly set 'lexical-binding' you can |
| 1612 | change it globally with: | 1621 | change it globally with: |
| 1613 | 1622 | ||
| 1614 | (set-default-toplevel-value 'lexical-binding t) | 1623 | (set-default-toplevel-value 'lexical-binding t) |
| 1615 | 1624 | ||
| 1616 | +++ | 1625 | +++ |
| 1617 | *** New macros 'incf' and 'decf'. | 1626 | ** New macros 'incf' and 'decf'. |
| 1618 | They increment or decrement the value stored in a variable (a symbol), | 1627 | They increment or decrement the value stored in a variable (a symbol), |
| 1619 | or in a generalized variable. | 1628 | or in a generalized variable. |
| 1620 | 1629 | ||
| @@ -1638,11 +1647,12 @@ This means that you can now call it with just one argument, like | |||
| 1638 | *** Some experimental ERT macros are now considered stable. | 1647 | *** Some experimental ERT macros are now considered stable. |
| 1639 | The following macros, previously only available in the experimental | 1648 | The following macros, previously only available in the experimental |
| 1640 | 'ert-x' module, are now considered stable and have been moved to 'ert': | 1649 | 'ert-x' module, are now considered stable and have been moved to 'ert': |
| 1650 | |||
| 1641 | - ert-with-test-buffer | 1651 | - ert-with-test-buffer |
| 1642 | - ert-with-buffer-selected | 1652 | - ert-with-buffer-selected |
| 1643 | - ert-with-buffer-renamed | 1653 | - ert-with-buffer-renamed |
| 1644 | 1654 | ||
| 1645 | See the ERT manual for more information. | 1655 | See "(ert) Helper Functions" node in the ERT manual for more information. |
| 1646 | 1656 | ||
| 1647 | ** Time & Date | 1657 | ** Time & Date |
| 1648 | 1658 | ||
| @@ -1852,7 +1862,7 @@ maps will not activate the repeat map in 'repeat-mode'. It will only | |||
| 1852 | continue the already activated repeating sequence. Also 'defvar-keymap' | 1862 | continue the already activated repeating sequence. Also 'defvar-keymap' |
| 1853 | supports a new keyword ':continue' with a list of commands that only | 1863 | supports a new keyword ':continue' with a list of commands that only |
| 1854 | continue the active repeating sequence, and the 'use-package' and | 1864 | continue the active repeating sequence, and the 'use-package' and |
| 1855 | 'bind-keys' macros supports a similar keyword ':continue-only'. | 1865 | 'bind-keys' macros support a similar keyword ':continue-only'. |
| 1856 | 1866 | ||
| 1857 | ** New function 'completion-table-with-metadata'. | 1867 | ** New function 'completion-table-with-metadata'. |
| 1858 | It offers a more concise way to create a completion table with metadata. | 1868 | It offers a more concise way to create a completion table with metadata. |
diff --git a/lisp/bindings.el b/lisp/bindings.el index f829c1bea26..a5737db840b 100644 --- a/lisp/bindings.el +++ b/lisp/bindings.el | |||
| @@ -1606,7 +1606,8 @@ if `inhibit-field-text-motion' is non-nil." | |||
| 1606 | "u" #'rename-uniquely | 1606 | "u" #'rename-uniquely |
| 1607 | "n" #'clone-buffer | 1607 | "n" #'clone-buffer |
| 1608 | "i" #'insert-buffer | 1608 | "i" #'insert-buffer |
| 1609 | "t" #'toggle-truncate-lines) | 1609 | "t" #'toggle-truncate-lines |
| 1610 | "@" #'tramp-revert-buffer-with-sudo) | ||
| 1610 | (define-key ctl-x-map "x" ctl-x-x-map) | 1611 | (define-key ctl-x-map "x" ctl-x-x-map) |
| 1611 | 1612 | ||
| 1612 | (define-key esc-map "\C-l" 'reposition-window) | 1613 | (define-key esc-map "\C-l" 'reposition-window) |
diff --git a/lisp/dired.el b/lisp/dired.el index 68e1da13171..b5bb658b503 100644 --- a/lisp/dired.el +++ b/lisp/dired.el | |||
| @@ -2416,6 +2416,7 @@ Do so according to the former subdir alist OLD-SUBDIR-ALIST." | |||
| 2416 | "x" #'dired-do-flagged-delete | 2416 | "x" #'dired-do-flagged-delete |
| 2417 | "y" #'dired-show-file-type | 2417 | "y" #'dired-show-file-type |
| 2418 | "+" #'dired-create-directory | 2418 | "+" #'dired-create-directory |
| 2419 | "@" #'tramp-dired-find-file-with-sudo | ||
| 2419 | ;; moving | 2420 | ;; moving |
| 2420 | "<" #'dired-prev-dirline | 2421 | "<" #'dired-prev-dirline |
| 2421 | ">" #'dired-next-dirline | 2422 | ">" #'dired-next-dirline |
diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el index cba300049ae..be122642b96 100644 --- a/lisp/net/tramp-cmds.el +++ b/lisp/net/tramp-cmds.el | |||
| @@ -32,6 +32,7 @@ | |||
| 32 | 32 | ||
| 33 | ;; Pacify byte-compiler. | 33 | ;; Pacify byte-compiler. |
| 34 | (declare-function dired-advertise "dired") | 34 | (declare-function dired-advertise "dired") |
| 35 | (declare-function dired-get-file-for-visit "dired") | ||
| 35 | (declare-function dired-unadvertise "dired") | 36 | (declare-function dired-unadvertise "dired") |
| 36 | (declare-function mml-mode "mml") | 37 | (declare-function mml-mode "mml") |
| 37 | (declare-function mml-insert-empty-tag "mml") | 38 | (declare-function mml-insert-empty-tag "mml") |
| @@ -637,6 +638,19 @@ For details, see `tramp-rename-files'." | |||
| 637 | (const "ksu")) | 638 | (const "ksu")) |
| 638 | :link '(tramp-info-link :tag "Tramp manual" tramp-file-name-with-method)) | 639 | :link '(tramp-info-link :tag "Tramp manual" tramp-file-name-with-method)) |
| 639 | 640 | ||
| 641 | (defmacro with-tramp-file-name-with-method (&rest body) | ||
| 642 | "Ask user for `tramp-file-name-with-method' if needed. | ||
| 643 | Run BODY." | ||
| 644 | (declare (indent 0) (debug t)) | ||
| 645 | `(let ((tramp-file-name-with-method | ||
| 646 | (if current-prefix-arg | ||
| 647 | (completing-read | ||
| 648 | "Tramp method: " | ||
| 649 | (mapcar #'cadr (cdr (get 'tramp-file-name-with-method 'custom-type))) | ||
| 650 | nil t tramp-file-name-with-method) | ||
| 651 | tramp-file-name-with-method))) | ||
| 652 | ,@body)) | ||
| 653 | |||
| 640 | (defun tramp-file-name-with-sudo (filename) | 654 | (defun tramp-file-name-with-sudo (filename) |
| 641 | "Convert FILENAME into a multi-hop file name with \"sudo\". | 655 | "Convert FILENAME into a multi-hop file name with \"sudo\". |
| 642 | An alternative method could be chosen with `tramp-file-name-with-method'." | 656 | An alternative method could be chosen with `tramp-file-name-with-method'." |
| @@ -669,27 +683,38 @@ An alternative method could be chosen with `tramp-file-name-with-method'." | |||
| 669 | (make-tramp-file-name | 683 | (make-tramp-file-name |
| 670 | :method tramp-file-name-with-method :localname filename)))) | 684 | :method tramp-file-name-with-method :localname filename)))) |
| 671 | 685 | ||
| 672 | ;;;###tramp-autoload | 686 | ;;;###autoload |
| 673 | (defun tramp-revert-buffer-with-sudo () | 687 | (defun tramp-revert-buffer-with-sudo () |
| 674 | "Revert current buffer to visit with \"sudo\" permissions. | 688 | "Revert current buffer to visit with \"sudo\" permissions. |
| 675 | An alternative method could be chosen with `tramp-file-name-with-method'. | 689 | An alternative method could be chosen with `tramp-file-name-with-method'. |
| 676 | If the buffer visits a file, the file is replaced. | 690 | If the buffer visits a file, the file is replaced. |
| 677 | If the buffer runs `dired', the buffer is reverted." | 691 | If the buffer runs `dired', the buffer is reverted." |
| 678 | (interactive) | 692 | (interactive) |
| 679 | (cond | 693 | (with-tramp-file-name-with-method |
| 680 | ((buffer-file-name) | 694 | (cond |
| 681 | (find-alternate-file (tramp-file-name-with-sudo (buffer-file-name)))) | 695 | ((buffer-file-name) |
| 682 | ((tramp-dired-buffer-p) | 696 | (let ((pos (point))) |
| 683 | (dired-unadvertise (expand-file-name default-directory)) | 697 | (find-alternate-file (tramp-file-name-with-sudo (buffer-file-name))) |
| 684 | (setq default-directory (tramp-file-name-with-sudo default-directory) | 698 | (goto-char pos))) |
| 685 | list-buffers-directory | 699 | ((tramp-dired-buffer-p) |
| 686 | (tramp-file-name-with-sudo list-buffers-directory)) | 700 | (dired-unadvertise (expand-file-name default-directory)) |
| 687 | (if (consp dired-directory) | 701 | (setq default-directory (tramp-file-name-with-sudo default-directory) |
| 688 | (setcar | 702 | list-buffers-directory |
| 689 | dired-directory (tramp-file-name-with-sudo (car dired-directory))) | 703 | (tramp-file-name-with-sudo list-buffers-directory)) |
| 690 | (setq dired-directory (tramp-file-name-with-sudo dired-directory))) | 704 | (if (consp dired-directory) |
| 691 | (dired-advertise) | 705 | (setcar |
| 692 | (revert-buffer)))) | 706 | dired-directory (tramp-file-name-with-sudo (car dired-directory))) |
| 707 | (setq dired-directory (tramp-file-name-with-sudo dired-directory))) | ||
| 708 | (dired-advertise) | ||
| 709 | (revert-buffer))))) | ||
| 710 | |||
| 711 | ;;;###autoload | ||
| 712 | (defun tramp-dired-find-file-with-sudo () | ||
| 713 | "In Dired, visit the file or directory named on this line. | ||
| 714 | This is performed with \"sudo\" permissions." | ||
| 715 | (interactive) | ||
| 716 | (with-tramp-file-name-with-method | ||
| 717 | (find-file (tramp-file-name-with-sudo (dired-get-file-for-visit))))) | ||
| 693 | 718 | ||
| 694 | ;;; Recompile on ELPA | 719 | ;;; Recompile on ELPA |
| 695 | 720 | ||