all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "R. Diez" <rdiezmail-emacs@yahoo.de>
To: Juri Linkov <juri@linkov.net>
Cc: Help Gnu Emacs mailing list <help-gnu-emacs@gnu.org>
Subject: Re: Help customising the behaviour of the new Tab Line mode
Date: Wed, 19 Aug 2020 09:16:32 +0200	[thread overview]
Message-ID: <95b14511-4025-1c46-1e60-f86e6c8dba97@yahoo.de> (raw)
In-Reply-To: <87r1s3h19h.fsf@mail.linkov.net>

> It should not be too hard to write another function for `tab-line-tabs-function'
> that will keep the manually sorted list of buffers, and a new command with a name
> `tab-line-move-tab' that will move the current tab in the internally maintained
> sorted buffer list used to display tabs on the tab-line.

OK, thanks for the hint.

Given my very limited Lisp, I may as well wait a few months in the hope that someone more adept has a go at it. O8-)

There probably are other things not directly related to Lisp. For example, how does the new routine learn that there is a new buffer and the 
tab bar needs to repaint? I already mentioned that a new compilation output buffer does not appear on the tab list, but more such things 
will undoubtedly come up. I haven't looked much, but I could not see any documentation in tab-line.el or elsewhere about how tabs work in 
such detail.

Yes, it would be nice to hide the tab for some buffers, but that would be the exception. It could also get tricky, because, if such a buffer 
is currently selected, it should then suddenly show up as a tab. Otherwise, it is confusing to be in no tab at the moment, if you are used 
to always being on a tab.

This is the related code I have been using for years with the old tabbar.el:

-------8<-------8<-------8<-------8<-------

; I find the default "grouping" behaviour annoying, so display all buffers in the same tab group.
(defun tabbar-buffer-all-in-one-group ()
   "Return the list of group names BUFFER belongs to. Return only one group for each buffer."
   (list "AllInOneGroup")
)
(setq tabbar-buffer-groups-function 'tabbar-buffer-all-in-one-group)

(setq *tabbar-ignore-buffers* '("*Messages*" "*Completions*" "*Ediff Registry*" "*Ibuffer*" "*etags-select*" "*xref*" "TAGS"))

(setq tabbar-buffer-list-function 'my-tabbar-buffer-list)

(defun my-tabbar-buffer-list ()
   (cl-remove-if
     (lambda (buffer)
       (and (not (eq (current-buffer) buffer)) ; Always include the current buffer.
            (or (string-starts-with (buffer-name buffer) " ")  ; Possible alternative: (char-equal ?\  (aref ((buffer-name buffer) b) 0))
                (loop for name in *tabbar-ignore-buffers*  ; Remove buffer name in this list.
                  thereis (string-equal (buffer-name buffer) name))
            )
       )
    )
    (buffer-list)
   )
)


(defun my-tabbar-move-tab-left nil ""
   (interactive)
   (let* (
       (tabset (tabbar-current-tabset my-tabbar-request-new-tabset))
       (selected-tab (tabbar-selected-tab tabset))
       (tabs-in-tabset (tabbar-tabs tabset))
       (pos-from-right (length (memq selected-tab tabs-in-tabset)))
       new-tablist)
     (when (tabbar-tab-next tabset selected-tab t)
       (setq new-tablist (append
           (butlast tabs-in-tabset (+ pos-from-right 1))
           (list selected-tab)
           (list (nth (- (length tabs-in-tabset) pos-from-right 1) tabs-in-tabset))
           (last tabs-in-tabset (- pos-from-right 1))))
       ; (setq tabbar-window-cache nil)  ; didn't help
       (set tabset new-tablist)
       (tabbar-set-template tabset nil)
       ; If the tab moves out of view, calling tabbar-click-on-tab did not help.
       ; I tried all combinations, before and after tabbar-display-update.
       ; (tabbar-click-on-tab selected-tab)
       (tabbar-display-update)))
)

(defun my-tabbar-move-tab-right nil ""
   (interactive)
   (let* (
       (tabset (tabbar-current-tabset my-tabbar-request-new-tabset))
       (selected-tab (tabbar-selected-tab tabset))
       (tabs-in-tabset (tabbar-tabs tabset))
       (pos-from-right (length (memq selected-tab tabs-in-tabset)))
       new-tablist)
     (when (tabbar-tab-next tabset selected-tab nil)
       (setq new-tablist (append
           (butlast tabs-in-tabset pos-from-right)
           (list (nth (- (length tabs-in-tabset) pos-from-right -1) tabs-in-tabset))
           (list selected-tab)
           (last tabs-in-tabset (- pos-from-right 2))))
       ; (setq tabbar-window-cache nil)  ; didn't help
       (set tabset new-tablist)
       (tabbar-set-template tabset nil)
       ; If the tab moves out of view, calling tabbar-click-on-tab did not help.
       ; I tried all combinations, before and after tabbar-display-update.
       ; (tabbar-click-on-tab selected-tab)
       (tabbar-display-update)))
)

-------8<-------8<-------8<-------8<-------

Half of the code is not actually mine, and the other half is very old and could probably be greatly improved.

tabbar.el is not very well documented, so the code above does not always work well in all scenarios, but my Emacs skills are too limited to 
fix it.


> Then the remaining question is where would you prefer a new buffer to appear?
> When you visit a new buffer, it should be added to such list of buffers.
> One possible place is to put the new buffer to the end of the list,
> but then wouldn't it too inconvenient for you to move its tab from the end
> of the list to a more appropriate place where you want it to be?

I'm actually OK with the end of the list. That is what Firefox and co do when you press Ctrl+T to create a new tab.

If you right-click on a link on Firefox, and choose "Open Link in New Tab", Firefox is kind of smart about where it places the new tab. The 
first one opens next to the current tab, to its right, but a second one from the same page opens further to the right, next to the first tab 
opened this way. That kind of behaviour would be nice for functions like 'ff-find-other-file'. But that would be comfort in the luxury 
class, reserved for expensive, top-of-the-line software like web browsers, and we don't want to spoil Emacs users, do we??? ;-)


By the way, I tried once package tabbar-ruler, which allows the user to reorder the tabs on the old tabbar.el by dragging them with the 
mouse. Unfortunately, I had to disable it because it had too many bugs. But is supporting mouse users morally acceptable in Emacs? 8-D

Regards,
   rdiez



  reply	other threads:[~2020-08-19  7:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <005b781b-a6e0-e1b8-bf2e-090c67de16ac.ref@yahoo.de>
2020-08-14 13:34 ` Help customising the behaviour of the new Tab Line mode R. Diez
2020-08-14 14:26   ` Robert Pluim
2020-08-14 19:37     ` R. Diez
2020-08-15 10:09   ` Michael Heerdegen
2020-08-16  1:27     ` Juri Linkov
2020-08-17  0:33   ` Juri Linkov
2020-08-18  6:12     ` R. Diez
2020-08-19  1:28       ` Juri Linkov
2020-08-19  7:16         ` R. Diez [this message]
2020-08-20  0:31           ` Juri Linkov
2020-08-20  4:11           ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=95b14511-4025-1c46-1e60-f86e6c8dba97@yahoo.de \
    --to=rdiezmail-emacs@yahoo.de \
    --cc=help-gnu-emacs@gnu.org \
    --cc=juri@linkov.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.