activities.el icon indicating copy to clipboard operation
activities.el copied to clipboard

Activities tabs should resize according to `tab-bar-auto-width`

Open josephmturner opened this issue 1 year ago • 9 comments

Activities tabs are not resized even when the tab-bar-auto-width option is non-nil.

;; Create a bunch of activities, see the tab bar wrap 
(progn
  (setopt tab-bar-auto-width t)
  (activities-tabs-mode 1)
  (dotimes (i 10)
    (activities-new (format "test-long-name-%s" i))))

;; Clean up
(progn
  (dotimes (i 10)
    (let* ((name (format "test-long-name-%s" i))
           (activity (map-elt activities-activities name)))
      (ignore-errors
        (when (activities-activity-active-p activity)
          (activities-close activity)))
      (setf activities-activities (map-delete activities-activities name)))))

Internally, the tab-bar-auto-width function determines that a tab should be resized if its face is one of tab-bar-auto-width-faces. However, activities-tabs--tab-bar-tab-face-function (say that even once fast... 😉) sets the activities tab face to (:inherit (activities-tabs ,face)), so the activities tabs are never resized.

josephmturner avatar Apr 13 '24 05:04 josephmturner

A couple of quick notes from our discussion:

  1. Maybe we can use a zero-width space, i.e. only apply the activities face to everything after a zero-width space, leaving the face of the first character as tab-bar-auto-width expects.
  2. Beyond that, we might want to propose a patch for Emacs 30 to make this more flexible.

alphapapa avatar Apr 14 '24 01:04 alphapapa

  1. Maybe we can use a zero-width space, i.e. only apply the activities face to everything after a zero-width space, leaving the face of the first character as tab-bar-auto-width expects.

I think this solution is not currently possible since tab-bar-tab-face-function defines a face which is applied to the whole tab name string. I don't know of a way to apply different faces to parts of the string.

josephmturner avatar Apr 14 '24 04:04 josephmturner

FYI, I use this styling with my modus-theme set up:

(set-face-attribute 'activities-tabs nil :inherit 'tab-bar-tab
                    :box '(:line-width (-1 . -1) :color "white" :style nil))

Which adds a nice white box around tabs that are registered as activities tabs. I'd prefer to keep that kind of styling so perhaps @josephmturner could try this out with the proposed change?

shipmints avatar Jun 20 '24 21:06 shipmints

@shipmints Please consider upstreaming your face changes to https://github.com/protesilaos/modus-themes other modus-themes users can benefit too!

perhaps @josephmturner could try this out with the proposed change?

What proposed change?

josephmturner avatar Jun 21 '24 03:06 josephmturner

I'm suggesting testing this proposed change https://github.com/alphapapa/activities.el/pull/79/files to the code base (as yet unmerged/unaccepted)

with this styling

(set-face-attribute 'activities-tabs nil :inherit 'tab-bar-tab
                    :box '(:line-width (-1 . -1) :color "white" :style nil))

shipmints avatar Jun 21 '24 12:06 shipmints

That change comments out the reference to the 'activities-tabs face, so the set-face-attribute form you posted has no effect.

josephmturner avatar Jun 21 '24 19:06 josephmturner

I'd prefer that it has an effect. Do you have an alternative recommendation for how one would otherwise face an activities controlled tab?

shipmints avatar Jun 21 '24 19:06 shipmints

Like @alphapapa suggested

2. Beyond that, we might want to propose a patch for Emacs 30 to make this more flexible.

josephmturner avatar Jun 21 '24 19:06 josephmturner

@shipmints @alphapapa please see the patch I just submitted as issue #71883.

josephmturner avatar Jul 01 '24 21:07 josephmturner

@shipmints @alphapapa the patch was merged with additional backwards-compatibility changes added by Juri. When you get a chance, please see if auto-width tabs work as expected on the Emacs master branch. Closing now since this issue should now be fixed in Emacs.

josephmturner avatar Aug 20 '24 07:08 josephmturner