emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 676398d: Add new tab command `C-x t C-r'


From: Lars Ingebrigtsen
Subject: master 676398d: Add new tab command `C-x t C-r'
Date: Sun, 20 Sep 2020 05:37:01 -0400 (EDT)

branch: master
commit 676398dd7df0a2a2cfc105ee4d46e6c817e6cd9d
Author: Earl <ej32u@protonmail.com>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    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.
---
 doc/emacs/misc.texi |  5 +++++
 etc/NEWS            |  3 +++
 lisp/ffap.el        |  8 ++++++++
 lisp/tab-bar.el     | 15 +++++++++++++++
 4 files changed, 31 insertions(+)

diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi
index c8b21e7..4865ee1 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 e7e4910..7c63672 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 3e65c68..a1d80f5 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 e4b3c8c..9c6b9cb 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)
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]