]> git.eshelyaron.com Git - emacs.git/commitdiff
Add command ffap-other-tab (Bug#41410)
authorej32u@protonmail.com <ej32u@protonmail.com>
Tue, 19 May 2020 21:43:13 +0000 (21:43 +0000)
committerNoam Postavsky <npostavs@gmail.com>
Mon, 25 May 2020 00:45:05 +0000 (20:45 -0400)
* lisp/ffap.el (ffap-other-tab): New command, opens files at point in
another tab.
(ffap-bindings): Bind it to find-file-other-tab's binding.

lisp/ffap.el

index d656b3737296043328dbc82e9aa9ae5ed108891a..ceba9d2622340c7ea75ef33c09a782d892fdee26 100644 (file)
@@ -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 @@ Only intended for interactive use."
       (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 @@ This hook is intended to be put in `file-name-at-point-functions'."
 
      (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)