Add new tab command `C-x t C-r'

* doc/emacs/misc.texi (FFAP): Document new commands (bug#43503).

* lisp/ffap.el (ffap-read-only-other-tab): New command.

* lisp/tab-bar.el (find-file-read-only-other-tab): New command and
keystroke.
This commit is contained in:
Earl 2020-09-20 11:36:52 +02:00 committed by Lars Ingebrigtsen
parent a68a0e69da
commit 676398dd7d
4 changed files with 31 additions and 0 deletions

View file

@ -3028,6 +3028,11 @@ point (@code{dired-at-point}).
@code{find-file-read-only-other-frame}.
@item C-x 5 d @var{directory} @key{RET}
@code{ffap-dired-other-frame}, analogous to @code{dired-other-frame}.
@kindex C-x t C-f @r{(FFAP)}
@item C-x t C-f @var{filename} @key{return}
@code{ffap-other-tab}, analogous to @code{find-file-other-tab}.
@item C-x t C-r @var{filename} @key{return}
@code{ffap-read-only-other-tab}, analogous to @code{find-file-read-only-other-tab}.
@item M-x ffap-next
Search buffer for next file name or URL, then find that file or URL.
@item S-mouse-3

View file

@ -239,6 +239,9 @@ of the next command to be displayed in a new frame.
It's bound to the command 'other-tab-prefix' that requests the buffer
of the next command to be displayed in a new tab.
+++
*** New command 'C-x t C-r' to open file read-only in other tab.
*** The tab bar is frame-local when 'tab-bar-show' is a number.
Show/hide the tab bar independently for each frame, according to the
value of 'tab-bar-show'.

View file

@ -1926,6 +1926,14 @@ Only intended for interactive use."
(ffap--toggle-read-only value)
value))
(defun ffap-read-only-other-tab (filename)
"Like `ffap', but put buffer in another tab and mark as read-only.
Only intended for interactive use."
(interactive (list (ffap-prompter nil " read only other tab")))
(let ((value (window-buffer (ffap-other-tab filename))))
(ffap--toggle-read-only value)
value))
(defun ffap-alternate-file (filename)
"Like `ffap' and `find-alternate-file'.
Only intended for interactive use."

View file

@ -1566,6 +1566,20 @@ Like \\[find-file-other-frame] (which see), but creates a new tab."
value)
(switch-to-buffer-other-tab value))))
(defun find-file-read-only-other-tab (filename &optional wildcards)
"Edit file FILENAME, in another tab, but don't allow changes.
Like \\[find-file-other-frame] (which see), but creates a new tab.
Like \\[find-file-other-tab], but marks buffer as read-only.
Use \\[read-only-mode] to permit editing."
(interactive
(find-file-read-args "Find file read-only in other tab: "
(confirm-nonexistent-file-or-buffer)))
(find-file--read-only (lambda (filename wildcards)
(window-buffer
(find-file-other-tab filename wildcards)))
filename wildcards))
(defun other-tab-prefix ()
"Display the buffer of the next command in a new tab.
The next buffer is the buffer displayed by the next command invoked
@ -1595,6 +1609,7 @@ When `switch-to-buffer-obey-display-actions' is non-nil,
(define-key tab-prefix-map "b" 'switch-to-buffer-other-tab)
(define-key tab-prefix-map "f" 'find-file-other-tab)
(define-key tab-prefix-map "\C-f" 'find-file-other-tab)
(define-key tab-prefix-map "\C-r" 'find-file-read-only-other-tab)
(define-key tab-prefix-map "t" 'other-tab-prefix)