[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#38354: 27.0.50; Implement display action display-buffer-in-tab
From: |
Juri Linkov |
Subject: |
bug#38354: 27.0.50; Implement display action display-buffer-in-tab |
Date: |
Tue, 03 Dec 2019 01:43:02 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) |
> With "moving" I really meant "copying" or "cloning" with the
> additional possibility of deleting the original. So there should be
> only one question: Can we simply make a copy of a tab using its window
> state (window configurations can't be used because we cannot clone
> windows). If not, what is the problem?
Implemented in the patch below that deletes the window-configuration
from the copied tab, but leaves its window-state.
>> An additional question to consider is how to interactively select
>> an another frame: by frame name, or using other-frame with a numeric
>> prefix argument?
>
> How is this question related to tabs?
Easier to implement than to explain :) The same patch uses its ARG
the same way as it's used in 'other-frame' to find ARGth frame
where to copy the tab.
>> (push '("test1" .
>> (display-buffer-reuse-window
>> (reusable-frames . visible)
>> (use-tabs . t)))
>> display-buffer-alist)
>
> There is one thing I apparently do not understand yet: When you enable
> 'tab-bar-mode' it is global
Do you think we should have 'global-tab-bar-mode' for all frames,
and 'tab-bar-mode' to enable/disable the tab-bar in every frame
separately?
> - that is any window ever shown on any frame is also in at least one
> of that frame's tabs. Is that right? So what would 'use-tabs' mean
> here when every window is in a tab already?
These windows in tabs are in window-configurations and window-states.
Now I installed tab-bar-get-buffer-tab that can be used
in display-buffer-reuse-window to search the buffer
in window-states of tabs when use-tabs is non-nil.
>>> By default, a new tab starts with the current buffer that was current
>>> before calling the command that adds a new tab.
>>>
>>> That's confusing, at least.
>>
>> Maybe this is better?
>>
>> By default, a new tab starts with the buffer that was current
>> before calling the command that adds a new tab.
>
> The current buffer is IMHO a much too obscure object to consider here.
> Don't you mean the buffer of the selected window?
The manual refers to the default value of tab-bar-new-tab-choice
with its docstring:
If t, start a new tab with the current buffer, i.e. the buffer
that was current before calling the command that adds a new tab
(this is the same what `make-frame' does by default).
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index a36be13e37..340f012247 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -645,6 +645,33 @@ tab-bar-move-tab
(to-index (mod (+ from-index arg) (length tabs))))
(tab-bar-move-tab-to (1+ to-index) (1+ from-index))))
+(defun tab-bar-move-tab-to-frame (arg &optional from-frame from-index to-frame
to-index)
+ "Move tab from FROM-INDEX position to new position at TO-INDEX.
+FROM-INDEX defaults to the current tab index.
+FROM-INDEX and TO-INDEX count from 1.
+FROM-FRAME specifies the source frame and defaults to the selected frame.
+TO-FRAME specifies the target frame and defaults the next frame.
+Interactively, ARG selects the ARGth different frame to move to."
+ (interactive "P")
+ (unless from-frame
+ (setq from-frame (selected-frame)))
+ (unless to-frame
+ (dotimes (_ (prefix-numeric-value arg))
+ (setq to-frame (next-frame to-frame))))
+ (unless (eq from-frame to-frame)
+ (let* ((from-tabs (with-selected-frame from-frame
+ (funcall tab-bar-tabs-function)))
+ (from-index (or from-index (1+ (tab-bar--current-tab-index
from-tabs))))
+ (from-tab (nth (1- from-index) from-tabs))
+ (to-tabs (with-selected-frame to-frame
+ (funcall tab-bar-tabs-function)))
+ (to-index (max 0 (min (1- (or to-index 1)) (1- (length to-tabs))))))
+ (setq from-tabs (delq from-tab from-tabs))
+ (cl-pushnew (assq-delete-all 'wc from-tab) (nthcdr to-index to-tabs))
+ (set-frame-parameter from-frame 'tabs from-tabs)
+ (set-frame-parameter to-frame 'tabs to-tabs)
+ (force-mode-line-update t))))
+
(defcustom tab-bar-new-tab-to 'right
"Defines where to create a new tab.
- bug#38354: 27.0.50; Implement display action display-buffer-in-tab, Juri Linkov, 2019/12/01
- bug#38354: 27.0.50; Implement display action display-buffer-in-tab, martin rudalics, 2019/12/02
- bug#38354: 27.0.50; Implement display action display-buffer-in-tab,
Juri Linkov <=
- bug#38354: 27.0.50; Implement display action display-buffer-in-tab, martin rudalics, 2019/12/03
- bug#38354: 27.0.50; Implement display action display-buffer-in-tab, Juri Linkov, 2019/12/03
- bug#38354: 27.0.50; Implement display action display-buffer-in-tab, martin rudalics, 2019/12/04
- bug#38354: 27.0.50; Implement display action display-buffer-in-tab, Juri Linkov, 2019/12/04
- bug#38354: 27.0.50; Implement display action display-buffer-in-tab, martin rudalics, 2019/12/05
- bug#38354: 27.0.50; Implement display action display-buffer-in-tab, Juri Linkov, 2019/12/05
- bug#38354: 27.0.50; Implement display action display-buffer-in-tab, martin rudalics, 2019/12/06