all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: 51648@debbugs.gnu.org
Subject: bug#51648: 28.0.60; `tab-bar-close-button' and `tab-bar-new-button' should be documented in the manual
Date: Sun, 23 Oct 2022 21:11:43 +0300	[thread overview]
Message-ID: <86fsfe73tc.fsf@mail.linkov.net> (raw)
In-Reply-To: <86a670ac4g.fsf@mail.linkov.net> (Juri Linkov's message of "Thu,  15 Sep 2022 19:20:39 +0300")

[-- Attachment #1: Type: text/plain, Size: 360 bytes --]

> Fortunately, now we have customizable icons.  So I tried to do this
> with a patch like below, but compilation failed with this error
> because tab-bar.el is pre-loaded:
>
>   Loading tab-bar (native compiled elisp)...
>   Error: void-function (icons--register)
>   (require cl-print) while preparing to dump
>

OTOH, the following patch works pretty well:


[-- Attachment #2: tab-bar-icons.patch --]
[-- Type: text/x-diff, Size: 4631 bytes --]

diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index abefd996a8a..777837f4db7 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -155,25 +155,34 @@ tab-bar--undefine-keys
 
 (defun tab-bar--load-buttons ()
   "Load the icons for the tab buttons."
-  (when (and tab-bar-new-button
-             (not (get-text-property 0 'display tab-bar-new-button)))
-    ;; This file is pre-loaded so only here we can use the right data-directory:
-    (add-text-properties 0 (length tab-bar-new-button)
-                         `(display (image :type xpm
-                                          :file "tabs/new.xpm"
-                                          :margin ,tab-bar-button-margin
-                                          :ascent center))
-                         tab-bar-new-button))
+  (require 'icons)
 
-  (when (and tab-bar-close-button
-             (not (get-text-property 0 'display tab-bar-close-button)))
-    ;; This file is pre-loaded so only here we can use the right data-directory:
-    (add-text-properties 0 (length tab-bar-close-button)
-                         `(display (image :type xpm
-                                          :file "tabs/close.xpm"
-                                          :margin ,tab-bar-button-margin
-                                          :ascent center))
-                         tab-bar-close-button)))
+  (unless (iconp 'tab-bar-new)
+    (define-icon tab-bar-new nil
+      `((image "tabs/new.xpm"
+               :margin ,tab-bar-button-margin
+               :ascent center)
+        ;; (emoji "➕")
+        ;; (symbol "+")
+        (text " + "))
+      "Icon for creating a new tab."
+      :version "29.1"
+      :help-echo "New tab"))
+  (setq tab-bar-new-button (icon-string 'tab-bar-new))
+
+  (unless (iconp 'tab-bar-close)
+    (define-icon tab-bar-close nil
+      `((image "tabs/close.xpm"
+               :margin ,tab-bar-button-margin
+               :ascent center)
+        ;; (emoji " ❌")
+        ;; (symbol "ⓧ")
+        (text " x"))
+      "Icon for closing the clicked tab."
+      :version "29.1"
+      :help-echo "Click to close tab"))
+  (setq tab-bar-close-button (propertize (icon-string 'tab-bar-close)
+                                         'close-tab t)))
 
 (defun tab-bar--tab-bar-lines-for-frame (frame)
   "Determine and return the value of `tab-bar-lines' for FRAME.
@@ -1916,22 +1933,27 @@ tab-bar-history-mode
   :global t :group 'tab-bar
   (if tab-bar-history-mode
       (progn
-        (when (and tab-bar-mode (not (get-text-property 0 'display tab-bar-back-button)))
-          ;; This file is pre-loaded so only here we can use the right data-directory:
-          (add-text-properties 0 (length tab-bar-back-button)
-                               `(display (image :type xpm
-                                                :file "tabs/left-arrow.xpm"
-                                                :margin ,tab-bar-button-margin
-                                                :ascent center))
-                               tab-bar-back-button))
-        (when (and tab-bar-mode (not (get-text-property 0 'display tab-bar-forward-button)))
-          ;; This file is pre-loaded so only here we can use the right data-directory:
-          (add-text-properties 0 (length tab-bar-forward-button)
-                               `(display (image :type xpm
-                                                :file "tabs/right-arrow.xpm"
-                                                :margin ,tab-bar-button-margin
-                                                :ascent center))
-                               tab-bar-forward-button))
+        (require 'icons)
+
+        (unless (iconp 'tab-bar-back)
+          (define-icon tab-bar-back nil
+            `((image "tabs/left-arrow.xpm"
+                     :margin ,tab-bar-button-margin
+                     :ascent center)
+              (text " < "))
+            "Icon for going back in tab history."
+            :version "29.1"))
+        (setq tab-bar-back-button (icon-string 'tab-bar-back))
+
+        (unless (iconp 'tab-bar-forward)
+          (define-icon tab-bar-forward nil
+            `((image "tabs/right-arrow.xpm"
+                     :margin ,tab-bar-button-margin
+                     :ascent center)
+              (text " > "))
+            "Icon for going forward in tab history."
+            :version "29.1"))
+        (setq tab-bar-forward-button (icon-string 'tab-bar-forward))
 
         (add-hook 'pre-command-hook 'tab-bar--history-pre-change)
         (add-hook 'window-configuration-change-hook 'tab-bar--history-change))

  reply	other threads:[~2022-10-23 18:11 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <878ry0y884.fsf.ref@yahoo.com>
2021-11-07  3:07 ` bug#51648: 28.0.60; `tab-bar-close-button' and `tab-bar-new-button' should be documented in the manual Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-07  7:12   ` Eli Zaretskii
2021-11-07  7:23     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-07  7:40       ` Eli Zaretskii
2021-11-07  8:05         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-07 17:37         ` Juri Linkov
2021-11-07 18:25           ` Eli Zaretskii
2021-11-07 18:31             ` Juri Linkov
2021-11-07 18:41               ` Eli Zaretskii
2021-11-07 20:00                 ` Juri Linkov
2021-11-08  0:32                   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-08  9:02                     ` Juri Linkov
2022-09-15 16:20                       ` Juri Linkov
2022-10-23 18:11                         ` Juri Linkov [this message]
2021-11-08 17:46                     ` Juri Linkov
2022-01-27 18:45                 ` Juri Linkov

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=86fsfe73tc.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=51648@debbugs.gnu.org \
    /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.