Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for tab-line. #6

Merged
merged 1 commit into from Feb 27, 2024
Merged

Conversation

lucasgruss
Copy link
Sponsor

@lucasgruss lucasgruss commented Feb 25, 2024

Hello protesilaos,
spacious-padding does not support the tab-line yet. Here is a very quick implementation of the feature. A new entry :tab-line-width to the spacious-padding-widths is added and the relevant changes to the source are made.

What did you have in mind for the support of the tab-line ? Would you prefer the tab-line to inherit from the :tab-width instead of introducing a new configuration variable ?

Best regards.

@protesilaos protesilaos merged commit 7e3552f into protesilaos:main Feb 27, 2024
@protesilaos
Copy link
Owner

Merged. Thank you!

@protesilaos
Copy link
Owner

By the way, should we use :tab-line-width or re-use :tab-width? If we want to keep them separate, then :tab-width should become :tab-bar-width.

I am inclined to use the same for everything, as we may have more "tab" interfaces in the future.

@lucasgruss
Copy link
Sponsor Author

Thank you for merging !
I agree that if the options are to be kept separate, :tab-width should become :tab-bar-width. I would advocate to keep them separate to allow a more granular control of the UI elements. This is consistent with the options for the left and right fringes, which are controlled by different variables instead of e.g. a single :fringe-width option.

Another possiblity could be to allow :tab-bar-width, :tab-line-width as well as :tab-width, such that the latter option is equivalent to setting each tab set individually. The same idea could be extended to the fringes. If new UI elements are added to spacious padding, that could limit the number of variables that need to be set by users, though they could still have granular control if they want. Although, I do not think that the current number of configuration options warrants such a mechanism yet.

we may have more "tab" interfaces in the future

This is making me curious, is it an hypothetical consideration (maybe a discussion in emacs-devel that I missed of future plans for additional tab interfaces?) or is it related to supporting third-party tabs packages ?

@protesilaos
Copy link
Owner

Another possiblity could be to allow :tab-bar-width, :tab-line-width as well as :tab-width, such that the latter option is equivalent to setting each tab set individually. The same idea could be extended to the fringes. If new UI elements are added to spacious padding, that could limit the number of variables that need to be set by users, though they could still have granular control if they want. Although, I do not think that the current number of configuration options warrants such a mechanism yet.

Great! Let's do this!

we may have more "tab" interfaces in the future

This is making me curious, is it an hypothetical consideration (maybe a discussion in emacs-devel that I missed of future plans for additional tab interfaces?) or is it related to supporting third-party tabs packages ?

Just a hypothesis. I don't think it is likely, though it puts us in the right frame of mind.

@protesilaos
Copy link
Owner

Just to note that I am working on it.

@protesilaos
Copy link
Owner

Didn't do much testing, but it seems to work. Any thoughts?

 spacious-padding.el | 60 +++++++++++++++++++++++++++++++++++++----------------
 1 file changed, 42 insertions(+), 18 deletions(-)

diff --git a/spacious-padding.el b/spacious-padding.el
index d605c73..712e6ec 100644
--- a/spacious-padding.el
+++ b/spacious-padding.el
@@ -58,11 +58,9 @@ (defcustom spacious-padding-widths
      :header-line-width 4
      :mode-line-width 6
      :tab-width 4
-     :tab-line-width 4
      :right-divider-width 30
      :scroll-bar-width 8
-     :left-fringe-width 8
-     :right-fringe-width 8)
+     :fringe-width 8)
   "Set the pixel width of individual User Interface elements.
 This is a plist of the form (:key1 value1 :key2 value2).  The
 value is always a natural number.  Keys are keywords among the
@@ -76,13 +74,23 @@ (defcustom spacious-padding-widths
   windows.  If the value is less than 1, the border is not hidden
   when `spacious-padding-mode' is enabled.
 
-- `left-fringe-width' and `right-fringe-wdith' refer to the
-  fringes on each side of the window (the area where line
+- `:fringe-width' applies to the fringes on either side of the
+  window.  The more specific keys `:left-fringe-width' and
+  `Lright-fringe-wdith' can be used for finer control.  If those
+  are not specified (or set to a nil value), they fall back to
+  `:fringe-width'.  (The fringes are the window sides where line
   wrapping and other indicators are displayed).
 
-- `:tab-width' concerns the padding around buttons of the tab-bar.
+- `:tab-width' concerns the padding around buttons of all tabbed
+  interfaces (`tab-bar-mode', `tab-line-mode').
 
-- `:tab-line-width' concerns the padding around buttons of the tab-line. 
+- `:tab-bar-width' concerns the padding around buttons of the
+  `tab-bar-mode'.  If not specified (or set to nil) it uses the
+  value of `:tab-width'.
+
+- `:tab-line-width' concerns the padding around buttons of the
+  tab-line.  If not specified (or set to nil) it uses the value
+  of `:tab-width'.
 
 - `:header-line-width', `mode-line-width', `scroll-bar-width'
   point to the header-line, mode-line, and scroll-bar,
@@ -92,9 +100,11 @@ (defcustom spacious-padding-widths
   :type '(plist
           :key-type (choice (const :internal-border-width)
                             (const :right-divider-width)
+                            (const :fringe-width)
                             (const :left-fringe-width)
                             (const :right-fringe-width)
                             (const :tab-width)
+                            (const :tab-bar-width)
                             (const :tab-line-width)
                             (const :header-line-width)
                             (const :mode-line-width)
@@ -179,7 +189,7 @@ (defvar spacious-padding--header-line-faces
   '(header-line header-line-highlight)
   "Header line faces relevant to `spacious-padding-mode'.")
 
-(defvar spacious-padding--tab-faces
+(defvar spacious-padding--tab-bar-faces
   '(tab-bar tab-bar-tab tab-bar-tab-inactive)
   "Tab faces relevant to `spacious-padding-mode'.")
 
@@ -187,10 +197,14 @@ (defvar spacious-padding--tab-line-faces
   '(tab-line tab-line-tab tab-line-tab-inactive)
   "Tab faces relevant to `spacious-padding-mode'.")
 
-(defun spacious-padding--get-box-width (key)
+(defun spacious-padding--get-box-width (key &optional no-fallback)
   "Get width for :box of face represented by KEY in `spacious-padding-widths'.
-Return 4 if KEY does not have a value."
-  (or (plist-get spacious-padding-widths key) 4))
+Return 4 if KEY does not have a value.  If optional NO-FALLBACK
+is non-nil, do not return a fallback value: just nil."
+  (cond
+   ((plist-get spacious-padding-widths key))
+   (no-fallback nil)
+   (t 4)))
 
 (defun spacious-padding--get-face-width (face)
   "Return width of FACE from `spacious-padding-widths'."
@@ -199,10 +213,12 @@ (defun spacious-padding--get-face-width (face)
     (spacious-padding--get-box-width :mode-line-width))
    ((memq face spacious-padding--header-line-faces)
     (spacious-padding--get-box-width :header-line-width))
-   ((memq face spacious-padding--tab-faces)
-    (spacious-padding--get-box-width :tab-width))
+   ((memq face spacious-padding--tab-bar-faces)
+    (or (spacious-padding--get-box-width :tab-bar-width :fall-back-to-tab-width)
+        (spacious-padding--get-box-width :tab-width)))
    ((memq face spacious-padding--tab-line-faces)
-    (spacious-padding--get-box-width :tab-line-width))
+    (or (spacious-padding--get-box-width :tab-line-width :fall-back-to-tab-width)
+        (spacious-padding--get-box-width :tab-width)))
    (t (error "`%s' is not relevant to `spacious-padding-mode'" face))))
 
 (defun spacious-padding--get-face-overline-color (face fallback subtle-key)
@@ -294,6 +310,9 @@ (defvar spacious-padding--internal-border-width nil
 (defvar spacious-padding--right-divider-width nil
   "Default value of frame parameter `right-divider-width'.")
 
+(defvar spacious-padding--fringe-width nil
+  "Default value of frame parameters `left-fringe' and `right-fringe'.")
+
 (defvar spacious-padding--left-fringe-width nil
   "Default value of frame parameter `left-fringe'.")
 
@@ -311,6 +330,8 @@ (defun spacious-padding--store-default-parameters ()
   (unless spacious-padding--right-divider-width
     (setq spacious-padding--right-divider-width
           (frame-parameter nil 'right-divider-width)))
+  (unless spacious-padding--fringe-width
+    (setq spacious-padding--fringe-width 8)) ; 8 is the default per `fringe-mode'
   (unless spacious-padding--left-fringe-width
     (setq spacious-padding--left-fringe-width
           (frame-parameter nil 'left-fringe-width)))
@@ -336,8 +357,9 @@ (defmacro spacious-padding--define-get-frame-param (parameter fallback)
 
 (spacious-padding--define-get-frame-param "internal-border-width" 0)
 (spacious-padding--define-get-frame-param "right-divider-width" 1)
-(spacious-padding--define-get-frame-param "left-fringe-width" 8)
-(spacious-padding--define-get-frame-param "right-fringe-width" 8)
+(spacious-padding--define-get-frame-param "fringe-width" 8)
+(spacious-padding--define-get-frame-param "left-fringe-width" nil)
+(spacious-padding--define-get-frame-param "right-fringe-width" nil)
 (spacious-padding--define-get-frame-param "scroll-bar-width" 16)
 
 (defun spacious-padding-modify-frame-parameters (reset)
@@ -347,8 +369,10 @@ (defun spacious-padding-modify-frame-parameters (reset)
   (modify-all-frames-parameters
    `((internal-border-width . ,(spacious-padding--get-internal-border-width reset))
      (right-divider-width . ,(spacious-padding--get-right-divider-width reset))
-     (left-fringe . ,(spacious-padding--get-left-fringe-width reset))
-     (right-fringe . ,(spacious-padding--get-right-fringe-width reset))
+     (left-fringe . ,(or (spacious-padding--get-left-fringe-width reset)
+                         (spacious-padding--get-fringe-width reset)))
+     (right-fringe . ,(or (spacious-padding--get-right-fringe-width reset)
+                          (spacious-padding--get-fringe-width reset)))
      (scroll-bar-width  . ,(spacious-padding--get-scroll-bar-width reset)))))
 
 (defun spacious-padding--enable-mode ()

@lucasgruss
Copy link
Sponsor Author

I just tested it and it works like a charm ! Thank you for implementing it.
There is just a small typo, here is the diff.

 spacious-padding.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/spacious-padding.el b/spacious-padding.el
index 712e6ec..059cd27 100644
--- a/spacious-padding.el
+++ b/spacious-padding.el
@@ -76,7 +76,7 @@ following:
 
 - `:fringe-width' applies to the fringes on either side of the
   window.  The more specific keys `:left-fringe-width' and
-  `Lright-fringe-wdith' can be used for finer control.  If those
+  `:right-fringe-width' can be used for finer control.  If those
   are not specified (or set to a nil value), they fall back to
   `:fringe-width'.  (The fringes are the window sides where line
   wrapping and other indicators are displayed).

protesilaos added a commit that referenced this pull request Feb 28, 2024
This adds initial support for 'tab-line-mode' faces. It was done in
pull request 6: <#6>

The change is within the ~15 line limit. Lucas does not need to assign
copyright to the Free Software Foundation.
protesilaos added a commit that referenced this pull request Feb 28, 2024
…ally granular

Thanks to Lucas Gruss for suggesting this arrangement. We discussed
this as a follow-up to Lucas' contribution in commit 1bbc076. The
discussion took place in the context of pull request 6:
<#6>.
@protesilaos
Copy link
Owner

Done. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants