all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#43503: Patch: Improvements regarding commands like find-file-other-tab.
@ 2020-09-18 21:41 ej32u--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2020-09-19 14:34 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 5+ messages in thread
From: ej32u--- via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2020-09-18 21:41 UTC (permalink / raw)
  To: 43503

[-- Attachment #1: Type: text/plain, Size: 484 bytes --]

Hello.

This is what the patch does:

1. Document existing command `ffap-other-tab'.
2. Create `find-file-read-only-other-tab' and `ffap-read-only-other-tab'.
3. Bind "\C-r" to `find-file-read-only-other-tab', like how "\C-f" is
    bound to `find-file-other-tab'.
4. Document `ffap-read-only-other-tab' in misc.texi.

I don't really know the Texinfo format, so I just copied the mark-up used for 
other items.

Is there anything that should be changed?

Thank you.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Improvements-regarding-like-find-file-other-tab.patch --]
[-- Type: text/x-patch; name=0001-Improvements-regarding-like-find-file-other-tab.patch, Size: 3339 bytes --]

From cb079bfa57694d529bee0fac0a38c68600c33a8e Mon Sep 17 00:00:00 2001
From: Earl <>
Date: Wed, 16 Sep 2020 17:07:58 -0400
Subject: [PATCH] Improvements regarding like find-file-other-tab.

1. Document existing command `ffap-other-tab'.
2. Create find-file-read-only-other-tab and ffap-read-only-other-tab.
3. Bind "\C-r" to find-file-read-only-other-tab, like how "\C-f" is
   bound to find-file-other-tab.
4. Document ffap-read-only-other-tab in misc.texi.
---
 doc/emacs/misc.texi |  5 +++++
 lisp/ffap.el        |  8 ++++++++
 lisp/tab-bar.el     | 15 +++++++++++++++
 3 files changed, 28 insertions(+)

diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi
index c8b21e701c..4865ee1751 100644
--- a/doc/emacs/misc.texi
+++ b/doc/emacs/misc.texi
@@ -3028,6 +3028,11 @@ FFAP
 @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/lisp/ffap.el b/lisp/ffap.el
index 3e65c687af..29883693a7 100644
--- a/lisp/ffap.el
+++ b/lisp/ffap.el
@@ -1926,6 +1926,14 @@ ffap-read-only-other-frame
     (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 " 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 d8f932e7a4..840c67d5cc 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -1567,6 +1567,20 @@ find-file-other-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 C-x t C-f, but marks buffer as read-only.
+Use C-x C-q 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
@@ -1596,6 +1610,7 @@ tab-prefix-map
 (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)
 
 \f
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#43503: Patch: Improvements regarding commands like find-file-other-tab.
  2020-09-18 21:41 bug#43503: Patch: Improvements regarding commands like find-file-other-tab ej32u--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2020-09-19 14:34 ` Lars Ingebrigtsen
  2020-09-19 18:19   ` ej32u--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2020-09-19 14:34 UTC (permalink / raw)
  To: ej32u; +Cc: 43503

ej32u@protonmail.com writes:

> 1. Document existing command `ffap-other-tab'.
> 2. Create `find-file-read-only-other-tab' and `ffap-read-only-other-tab'.
> 3. Bind "\C-r" to `find-file-read-only-other-tab', like how "\C-f" is
>     bound to `find-file-other-tab'.
> 4. Document `ffap-read-only-other-tab' in misc.texi.
>
> I don't really know the Texinfo format, so I just copied the mark-up used for 
> other items.

Look OK to me.

> +(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 C-x t C-f, but marks buffer as read-only.
> +Use C-x C-q to permit editing."

This should probably refer to the functions, not the keystrokes?

But anyway -- I'm not really sure I understand the use case here -- is
opening files in read-only mode a thing that people do a lot?  I mean,
we have `C-x C-r', so adding tab-opening versions of that would be
logical, but...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#43503: Patch: Improvements regarding commands like find-file-other-tab.
  2020-09-19 14:34 ` Lars Ingebrigtsen
@ 2020-09-19 18:19   ` ej32u--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2020-09-20  9:30     ` Lars Ingebrigtsen
  2020-09-20  9:37     ` Lars Ingebrigtsen
  0 siblings, 2 replies; 5+ messages in thread
From: ej32u--- via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2020-09-19 18:19 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 43503

[-- Attachment #1: Type: text/plain, Size: 1084 bytes --]

On 9/19/20 10:34 AM, Lars Ingebrigtsen wrote:
>> +(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 C-x t C-f, but marks buffer as read-only.
>> +Use C-x C-q to permit editing."
> This should probably refer to the functions, not the keystrokes?
You are right. I fixed that.
> But anyway -- I'm not really sure I understand the use case here -- is
> opening files in read-only mode a thing that people do a lot?  I mean,
> we have `C-x C-r', so adding tab-opening versions of that would be
> logical, but...
>
> --
> (domestic pets only, the antidote for overdose, milk.)
>     bloggy blog: http://lars.ingebrigtsen.no

I do this only occasionally. I think having them is no different from having the 
`-other-frame' and `-other-window' versions of `find-file-read-only'.

I really only want the FFAP versions of these commands, but I think the other 
versions should exist for consistency.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Improvements-regarding-like-find-file-other-tab.patch --]
[-- Type: text/x-patch; name=0001-Improvements-regarding-like-find-file-other-tab.patch, Size: 3374 bytes --]

From a3d2b0fff752825d191e4e0908c6d872c9c2edbc Mon Sep 17 00:00:00 2001
From: Earl <>
Date: Wed, 16 Sep 2020 17:07:58 -0400
Subject: [PATCH] Improvements regarding like find-file-other-tab.

1. Document existing command `ffap-other-tab'.
2. Create find-file-read-only-other-tab and ffap-read-only-other-tab.
3. Bind "\C-r" to find-file-read-only-other-tab, like how "\C-f" is
   bound to find-file-other-tab.
4. Document ffap-read-only-other-tab in misc.texi.
---
 doc/emacs/misc.texi |  5 +++++
 lisp/ffap.el        |  8 ++++++++
 lisp/tab-bar.el     | 15 +++++++++++++++
 3 files changed, 28 insertions(+)

diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi
index c8b21e701c..4865ee1751 100644
--- a/doc/emacs/misc.texi
+++ b/doc/emacs/misc.texi
@@ -3028,6 +3028,11 @@ FFAP
 @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/lisp/ffap.el b/lisp/ffap.el
index 3e65c687af..a1d80f545c 100644
--- a/lisp/ffap.el
+++ b/lisp/ffap.el
@@ -1926,6 +1926,14 @@ ffap-read-only-other-frame
     (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 d8f932e7a4..e9265c3a50 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -1567,6 +1567,20 @@ find-file-other-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
@@ -1596,6 +1610,7 @@ tab-prefix-map
 (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)
 
 \f
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#43503: Patch: Improvements regarding commands like find-file-other-tab.
  2020-09-19 18:19   ` ej32u--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2020-09-20  9:30     ` Lars Ingebrigtsen
  2020-09-20  9:37     ` Lars Ingebrigtsen
  1 sibling, 0 replies; 5+ messages in thread
From: Lars Ingebrigtsen @ 2020-09-20  9:30 UTC (permalink / raw)
  To: ej32u; +Cc: 43503

ej32u@protonmail.com writes:

> I do this only occasionally. I think having them is no different from
> having the
> `-other-frame' and `-other-window' versions of `find-file-read-only'.

Yeah, I guess consistency has a charm of it's own, and I guess there's
no other way to do this than add a bunch of tab-equivalent versions of
all these commands, annoyingly enough.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#43503: Patch: Improvements regarding commands like find-file-other-tab.
  2020-09-19 18:19   ` ej32u--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2020-09-20  9:30     ` Lars Ingebrigtsen
@ 2020-09-20  9:37     ` Lars Ingebrigtsen
  1 sibling, 0 replies; 5+ messages in thread
From: Lars Ingebrigtsen @ 2020-09-20  9:37 UTC (permalink / raw)
  To: ej32u; +Cc: 43503

I've now applied the patch to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no






^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-09-20  9:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-18 21:41 bug#43503: Patch: Improvements regarding commands like find-file-other-tab ej32u--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-09-19 14:34 ` Lars Ingebrigtsen
2020-09-19 18:19   ` ej32u--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-09-20  9:30     ` Lars Ingebrigtsen
2020-09-20  9:37     ` Lars Ingebrigtsen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.