bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#41691: [PATCH] Add bookmark-jump-other-tab


From: Juri Linkov
Subject: bug#41691: [PATCH] Add bookmark-jump-other-tab
Date: Thu, 11 Jun 2020 00:50:21 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

>> Then after typing 'C-x t t' as a prefix key sequence,
>> the next command will display its buffer in a new tab:

Now here is a patch for doing the same for a new window with
'C-x 4 4', and a new frame with 'C-x 5 5':

diff --git a/lisp/window.el b/lisp/window.el
index b6f44341e8..c3d1a775b7 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -4005,6 +4005,22 @@ other-window
        ;; Always return nil.
        nil))))
 
+(defun other-window-prefix ()
+  "Display the buffer of the next command in a new window.
+The next buffer is the buffer displayed by the next command invoked
+immediately after this command (ignoring reading from the minibuffer).
+Creates a new window before displaying the buffer, or switches to the window
+that already contains that buffer.
+When `switch-to-buffer-obey-display-actions' is non-nil,
+`switch-to-buffer' commands are also supported."
+  (interactive)
+  (display-buffer-override-next-command
+   (lambda (buffer alist)
+     (cons (display-buffer-pop-up-window
+            buffer (append alist '((inhibit-same-window . t))))
+           'window)))
+  (message "Display next command buffer in a new window..."))
+
 ;; This should probably return non-nil when the selected window is part
 ;; of an atomic window whose root is the frame's root window.
 (defun one-window-p (&optional nomini all-frames)
@@ -10131,5 +10147,6 @@ ctl-x-map
 (define-key ctl-x-map "-" 'shrink-window-if-larger-than-buffer)
 (define-key ctl-x-map "+" 'balance-windows)
 (define-key ctl-x-4-map "0" 'kill-buffer-and-window)
+(define-key ctl-x-4-map "4" 'other-window-prefix)
 
 ;;; window.el ends here
diff --git a/lisp/frame.el b/lisp/frame.el
index 6c2f774709..25634fb445 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -1070,6 +1070,23 @@ other-frame
       (setq arg (1+ arg)))
     (select-frame-set-input-focus frame)))
 
+(defun other-frame-prefix ()
+  "Display the buffer of the next command in a new frame.
+The next buffer is the buffer displayed by the next command invoked
+immediately after this command (ignoring reading from the minibuffer).
+Creates a new frame before displaying the buffer, or switches to the frame
+that already contains that buffer.
+When `switch-to-buffer-obey-display-actions' is non-nil,
+`switch-to-buffer' commands are also supported."
+  (interactive)
+  (display-buffer-override-next-command
+   (lambda (buffer alist)
+     (cons (display-buffer-pop-up-frame
+            buffer (append alist '((reusable-frames . 0)
+                                   (inhibit-same-window . t))))
+           'frame)))
+  (message "Display next command buffer in a new frame..."))
+
 (defun iconify-or-deiconify-frame ()
   "Iconify the selected frame, or deiconify if it's currently an icon."
   (interactive)
@@ -2697,6 +2714,7 @@ ctl-x-5-map
 (define-key ctl-x-5-map "1" 'delete-other-frames)
 (define-key ctl-x-5-map "0" 'delete-frame)
 (define-key ctl-x-5-map "o" 'other-frame)
+(define-key ctl-x-5-map "5" 'other-frame-prefix)
 (define-key global-map [f11] 'toggle-frame-fullscreen)
 (define-key global-map [(meta f10)] 'toggle-frame-maximized)
 (define-key esc-map    [f10]        'toggle-frame-maximized)

reply via email to

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