Subject: Patch: Add function ffap-other-tab

From: [email-masked]
Date: Tue, 19 May 2020 21:43:13 +0000

Hello,

Attached is a patch to add a function to open files at point in another tab. It is basically the same as the function ffap-other-window.

Please use it.

Thank you.

---
 lisp/ffap.el | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/lisp/ffap.el b/lisp/ffap.el
index d656b37372..ceba9d2622 100644
--- a/lisp/ffap.el
+++ b/lisp/ffap.el
@@ -54,6 +54,8 @@
 ;; C-x 5 r		ffap-read-only-other-frame
 ;; C-x 5 d		ffap-dired-other-frame
 ;;
+;; C-x t f		ffap-other-tab
+;;
 ;; S-mouse-3     ffap-at-mouse
 ;; C-S-mouse-3   ffap-menu
 ;;
@@ -1758,6 +1760,14 @@ ffap-other-frame
       (set-window-dedicated-p win wdp))
     value))

+(defun ffap-other-tab (filename)
+  "Like `ffap', but put buffer in another tab.
+Only intended for interactive use."
+  (interactive (list (ffap-prompter nil " other tab")))
+  (pcase (save-window-excursion (find-file-at-point filename))
+    ((or (and (pred bufferp) b) `(,(and (pred bufferp) b) . ,_))
+     (switch-to-buffer-other-tab b))))
+
 (defun ffap--toggle-read-only (buffer-or-list)
   (dolist (buffer (if (listp buffer-or-list)
 		      buffer-or-list
@@ -2013,6 +2023,7 @@ ffap-bindings

      (global-set-key [remap find-file-other-window] 'ffap-other-window)
      (global-set-key [remap find-file-other-frame] 'ffap-other-frame)
+     (global-set-key [remap find-file-other-tab] 'ffap-other-tab)
      (global-set-key [remap find-file-read-only-other-window] 'ffap-read-only-other-window)
      (global-set-key [remap find-file-read-only-other-frame] 'ffap-read-only-other-frame)

--
2.25.1