deb0ch / emacs-winum

Window numbers for Emacs - Navigate windows and frames using numbers
143 stars 13 forks source link

winum to display window numbers in mode-line #13

Open olegbc1 opened 6 years ago

olegbc1 commented 6 years ago

I use winum to switch between windows in emacs, however I am struggling to display window number in my mode-line, preferably in [#] format (i.e. [1] [2] [3] ...).

What variable can I use to append window number to my mode-line-format list? Please see below an example of my mode-line configuration.

(setq-default mode-line-format (list
    " "
    '(:eval (if (vc-backend buffer-file-name)
                (list
                 (propertize octicon-octoface 'face 'octicons-modeline)
                 (propertize " "              'face 'mode-line))))
   mode-line-mule-info
   'mode-line-modified
   "-  "
   'mode-line-buffer-identification
   "  (%l, %c)  "
   'mode-line-modes
   " -- "
   `(vc-mode vc-mode)
))
deb0ch commented 6 years ago

Maybe the customize variables winum-auto-setup-mode-line and winum-mode-line-position are what you are looking for ?

See https://github.com/deb0ch/emacs-winum/blob/master/winum.el#L134 or the winum group in customize for documentation

hello-code commented 6 years ago

Add winum-format customize variable Format string for displaying the window number in the mode-line. Default to ” %n ” to get a space on each side of the window number.

That sounds exciting!

deb0ch commented 6 years ago

Hi again,

after such a long time I realised that I was completely beside the point 😅

What we push automatically in the mode-line is '(:eval (winum-get-number-string)) so just inserting that in your mode-line-format would work for you.

If you want something more custom you can use

'(:eval (format "[%s]" (winum-get-number-string)))`

I am about to push the feature @hello-code mentionned, soon there will be a winum-mode-line-format variable that is literally the format string supplied to the format function in my second snippet.