A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/deb0ch/emacs-winum below:

GitHub - deb0ch/emacs-winum: Window numbers for Emacs

Window numbers for Emacs !

Window numbers for Emacs: Navigate your windows and frames using numbers !

This package is an extended and actively maintained version of the window-numbering package by Nikolaj Schumacher, with some ideas and code taken from ace-window.

This version brings, among other things, support for number sets across multiple frames, giving the user a smoother experience of multi-screen Emacs.

Initial release: what’s changed since window-numbering

This package brings a lot of additions to the old window-numbering:

The recommended way of installing winum is from the Melpa package repository:

M-x package-install RET winum RET

You will find instructions to setup Melpa here if you don’t have it setup yet.

Once the package is installed, you need to load and activate winum-mode in your Emacs configuration:

(require 'winum)

(winum-mode)
cd /path/to/install/folder
git clone https://github.com/deb0ch/emacs-winum
(add-to-list 'load-path "/path/to/install/folder/emacs-winum/")

(require 'winum)

(winum-mode)
Key binding Description C-x w <n> select window <n>, where <n> ranges from 0 to 9. A negative argument deletes the window. C-x w ` select window by number. Number can be given as prefix arg or will be read from minibuffer.

The default prefix for key bindings is C-x w for compatibility with native Emacs bindings.

If you don’t like C-x w, you can set a prefix of your choosing using the function winum-set-keymap-prefix:

(winum-set-keymap-prefix (kbd "C-c"))

This function overrides the value of winum-keymap, so you should call it before customization of winum-keymap and/or after customization of winum-base-map. Its argument must be a key sequence, like the ones returned by kbd.

If you prefer no to use a prefix and have even shorter bindings, you can also override winum-keymap in the minor mode bindings table:

(setq winum-keymap
    (let ((map (make-sparse-keymap)))
      (define-key map (kbd "C-`") 'winum-select-window-by-number)
      (define-key map (kbd "C-²") 'winum-select-window-by-number)
      (define-key map (kbd "M-0") 'winum-select-window-0-or-10)
      (define-key map (kbd "M-1") 'winum-select-window-1)
      (define-key map (kbd "M-2") 'winum-select-window-2)
      (define-key map (kbd "M-3") 'winum-select-window-3)
      (define-key map (kbd "M-4") 'winum-select-window-4)
      (define-key map (kbd "M-5") 'winum-select-window-5)
      (define-key map (kbd "M-6") 'winum-select-window-6)
      (define-key map (kbd "M-7") 'winum-select-window-7)
      (define-key map (kbd "M-8") 'winum-select-window-8)
      map))

(require 'winum)

(winum-mode)

Note that it is important to set winum-keymap before the require.

You can also use the more conventional define-key on winum-keymap:

(define-key winum-keymap (kbd "C-x y o l o") 'winum-select-window-by-number)

NB: Both ` and ² are mapped to winum-select-window-by-number by default to handle both qwerty and azerty keyboard layouts. If you are using a different kind of layout, the recommended place to map it is the key beside 1.

Several options are available through Emacs’ Customize interface under convenience > winum:

Configuration file example

Here is an example that you could put in your .emacs, which includes all available winum options.

(setq winum-keymap
    (let ((map (make-sparse-keymap)))
      (define-key map (kbd "C-`") 'winum-select-window-by-number)
      (define-key map (kbd "C-²") 'winum-select-window-by-number)
      (define-key map (kbd "M-0") 'winum-select-window-0-or-10)
      (define-key map (kbd "M-1") 'winum-select-window-1)
      (define-key map (kbd "M-2") 'winum-select-window-2)
      (define-key map (kbd "M-3") 'winum-select-window-3)
      (define-key map (kbd "M-4") 'winum-select-window-4)
      (define-key map (kbd "M-5") 'winum-select-window-5)
      (define-key map (kbd "M-6") 'winum-select-window-6)
      (define-key map (kbd "M-7") 'winum-select-window-7)
      (define-key map (kbd "M-8") 'winum-select-window-8)
      map))

(require 'winum)

(defun winum-assign-9-to-calculator-8-to-flycheck-errors ()
  (cond
   ((equal (buffer-name) "*Calculator*") 9)
   ((equal (buffer-name) "*Flycheck errors*") 8)))

(defun winum-assign-0-to-neotree ()
  (when (string-match-p (buffer-name) ".*\\*NeoTree\\*.*") 10))

(add-to-list 'winum-assign-functions #'winum-assign-9-to-calculator-8-to-flycheck-errors)
(add-to-list 'winum-assign-functions #'winum-assign-0-to-neotree)

(set-face-attribute 'winum-face nil :weight 'bold)

(setq window-numbering-scope            'global
      winum-reverse-frame-list          nil
      winum-auto-assign-0-to-minibuffer t
      winum-assign-func                 'my-winum-assign-func
      winum-auto-setup-mode-line        t
      winum-format                      " %s "
      winum-mode-line-position          1
      winum-ignored-buffers             '(" *which-key*")
      winum-ignored-buffers-regexp      '(" \\*Treemacs-.*"))

(winum-mode)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4