1

I would like to move the time and date displayed in the tab-bar a couple of characters to the left, so that the time is not completely on the edge of the screen. Here is the relevant code :

(setq tab-bar-format '(tab-bar-format-history
               tab-bar-format-tabs
               tab-bar-separator
               tab-bar-format-align-right
               tab-bar-format-global))

As recommended in the manual, I use tab-bar-format-align-right but I do not know enough elisp to change its behavior to achieve the desired output.

Update:

I use the following code to configure the time and date :

(use-package time
  :commands world-clock
  :config
  (setq display-time-format "%d-%m-%Y %H:%M")
  (setq display-time-interval 60)
  (setq display-time-mail-directory nil)
  (setq display-time-default-load-average nil)
  :hook (after-init . display-time-mode))

However changing the display-time-format variable to be (setq display-time-format "%d-%m-%Y %H:%M ") does not produce the desired output.

Screenshot

Emperor_Udan
  • 121
  • 4

3 Answers3

1

I have found the solution to my problem. I have redefined tab-bar-format-align-right and subtracted a few pixels, like @link0ff suggested. I have replaced :align-to (- right ,hpos) with :align-to (- right ,hpos 3). Below is the full code:

(eval-after-load "tab-bar"
(defun tab-bar-format-align-right ()
  "Align the rest of tab bar items to the right."
  (let* ((rest (cdr (memq 'tab-bar-format-align-right tab-bar-format)))
         (rest (tab-bar-format-list rest))
         (rest (mapconcat (lambda (item) (nth 2 item)) rest ""))
         (hpos (length rest))
         (str (propertize " " 'display `(space :align-to (- right ,hpos 3)))))
    `((align-right menu-item ,str ignore)))))

Here is a picture of the result: Screenshot result

Emperor_Udan
  • 121
  • 4
0

The easiest way is to customize the variable display-time-format. This is the format string used to display the time in either the tab-bar or the modeline, whichever you have configured. The default is just "%H:%M", so that it shows the hour and minutes. If you change it to "%H:%M " then the spaces after it will push it away from the edge of the frame.

db48x
  • 15,741
  • 1
  • 19
  • 23
  • Thank you for your answer, but I had already tried that before asking the question and it does not work. I have updated the OP accordingly. – Emperor_Udan Jun 10 '22 at 07:41
  • Have you tried other space characters such as `NO-BREAK SPACE`? If this doesn't work, then you need to modify `tab-bar-format-align-right` and subtract more pixels as much as you need. – link0ff Jun 10 '22 at 08:53
  • I have tried using non-breakable spaces and it worked but this also required to set `nobreak-char-display` to nil, which I did not like. – Emperor_Udan Jun 10 '22 at 09:21
0

I realized now there is a much simpler way to pad with whitespace on the right edge. You can just add more separators to the end. For example:

(setq tab-bar-format
      '(tab-bar-format-history
        tab-bar-format-tabs
        tab-bar-separator
        tab-bar-format-align-right
        tab-bar-format-global
        tab-bar-separator
        tab-bar-separator
        tab-bar-separator
        ))
link0ff
  • 1,081
  • 5
  • 14
  • That is a good solution, but it does not work for me since I do not want any separators between tabs so I have `(setq tab-bar-separator "")` in my configuration. – Emperor_Udan Jun 10 '22 at 18:09