diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi index c8b21e701c7..4865ee17518 100644 --- a/doc/emacs/misc.texi +++ b/doc/emacs/misc.texi @@ -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 diff --git a/etc/NEWS b/etc/NEWS index e7e4910ba1b..7c6367257b9 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -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'. diff --git a/lisp/ffap.el b/lisp/ffap.el index 3e65c687af6..a1d80f545c2 100644 --- a/lisp/ffap.el +++ b/lisp/ffap.el @@ -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." diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index e4b3c8cf197..9c6b9cbc048 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -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)