Skip to content

emacsmirror/selected-window-accent-mode

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

selected-window-accent-mode

1 Summary

The Selected Window Accent Mode is an Emacs package designed to visually distinguish the currently selected window by applying a unique accent color to its fringes, mode line, header line, and margins.

img/selected-window-accent-mode-00.jpg

1.1 Alternative window highlighting packages

There exist a few emacs packages that perform window highlighting but that don’t quite provide the feature set of selected-window-accent.

selected-window-accent focusses more on clearly but non-intrusively highlighting the currently selected/focussed window by highlighting aspects of the window border without having to modify the appearance of non-selected windows, hence more akin to a tiling window manager.

1.1.1 dimmer

“This package provides a minor mode that indicates which buffer is currently active by dimming the faces in the other buffers.”

This is the closest in functionality to selected-window-accent, the difference being that dimmer dims non selected windows rather than accent the selected window.

dimmer can be used in conjunction and will complement selected-window-accent to further enhance the emphasizing of the selected window.

1.1.2 hiwin

“This package provides a minor-mode to change the background colour of the non active window.”

It uses overlays to highlight non active windows, so is similar to dimmer but is less subtle in its highlighting mechanism and hasn’t been updated in excess of 10 years.

1.1.3 color-theme-buffer-local

“This package lets you set a color-theme on a per-buffer basis.”

Unlike dimmer and hiwin this package isn’t related to the concept of a selected window but more of defining different themes for different windows to distinguish them.

1.1.4 solaire-mode

“This package is designed to visually distinguish “real” buffers (i.e. file-visiting code buffers where you do most of your work) from “unreal” buffers (like popups, sidebars, log buffers, terminals, etc) by giving the latter a slightly different – often darker – background”

Unlike dimmer and hiwin this package isn’t related to the concept of a selected window but more of distinguishing between collections of IDE like elements within emacs.

2 Quick Start (emacs 29)

Add the following to the emacs init for a tiling window manager feel (see image above):

(use-package selected-window-accent-mode
  :vc (:fetcher github :repo "captainflasmr/selected-window-accent-mode")
  :custom
  (selected-window-accent-fringe-thickness 10)
  (selected-window-accent-custom-color "#916941")
  (selected-window-accent-mode-style 'tiling))

(selected-window-accent-mode 1)

3 Installation

3.1 use-package (emacs 29)

Put the following into your emacs init file:

(use-package selected-window-accent-mode
  :vc (:fetcher github :repo "captainflasmr/selected-window-accent-mode"))

3.2 use-package (MELPA)

  • TODO (see roadmap below)

3.3 from source

Download the `.el` file and place it in your Emacs `load-path`.

Then either manually load it or add it to your configuration to be loaded at startup.

(require 'selected-window-accent-mode)

4 Usage

Interactively Toggle the mode on and off M-x selected-window-accent-mode

Interactively change the current style M-x switch-selected-window-accent-style which will present a completing-read selection in the minibuffer

The styles that are currently supported :

  • default
  • tiling
  • subtle

see roadmap below for a description.

Typically I have bound these two interactive functions to a new keymap where I keep all my emacs visual change functions.

(defvar my-win-keymap (make-sparse-keymap))
(global-set-key (kbd "M-o") my-win-keymap)
(define-key my-win-keymap (kbd "a") 'selected-window-accent-mode)
(define-key my-win-keymap (kbd "y") 'switch-selected-window-accent-style)

5 Examples

5.1 Example 1 - Default / custom color

img/selected-window-accent-mode-01.jpg

To enable the accent mode automatically upon starting Emacs, add the following line to your `.emacs` or `init.el` file:

(use-package selected-window-accent-mode
  :vc (:fetcher github :repo "captainflasmr/selected-window-accent-mode")
  :custom
  (selected-window-accent-fringe-thickness 20)
  (selected-window-accent-custom-color "goldenrod")
  (selected-window-accent-mode-style 'default))

(selected-window-accent-mode 1)

This will accent the modeline only for the selected window with the goldenrod color.

5.2 Example 2 - Tiling / custom color / custom fringe thickness

img/selected-window-accent-mode-02.jpg

(setq selected-window-accent-fringe-thickness 6)
(setq selected-window-accent-custom-color "#4179b2")
(setq selected-window-accent-mode-style 'tiling)

(selected-window-accent-mode 1)

This will accent the full outline of the window with the color #4179b2 more akin to a tiling window manager.

5.3 Example 3 - Tiling / theme highlight color

img/selected-window-accent-mode-03.jpg

(setq selected-window-accent-fringe-thickness 6)
(setq selected-window-accent-custom-color nil)
(setq selected-window-accent-mode-style 'tiling)

(selected-window-accent-mode 1)

This will accent the full outline of the window with the highlight color taken from the current theme.

5.4 Example 4 - Subtle / custom fringe thickness (thick)

img/selected-window-accent-mode-04.jpg

(setq selected-window-accent-fringe-thickness 20)
(setq selected-window-accent-custom-color nil)
(setq selected-window-accent-mode-style 'subtle)

(selected-window-accent-mode 1)

This will accent the modeline and just the left fringe and in this case be quite a pronounced thick accent.

6 Customization

These are the entries in the emacs help / documentation, at some stage I shall push-block these to the elisp file itsself to ensure consistency but for the moment I could need to source START END refactor my existing routine.

6.1 selected-window-accent-fringe-thickness

The thickness of the fringes in pixels.

This thickness is used when the `selected-window-accent-mode-style’ is either tiling or subtle.

6.2 selected-window-accent-custom-color

Custom accent color for the selected window.

When set to a color, this color will override the default highlight face background color as the accent color for the selected window. Setting this to nil disables the custom color, reverting to the default behavior.

6.3 selected-window-accent-mode

Mode variable for `selected-window-accent-mode’.

When non-nil, the `selected-window-accent-mode` is active, accenting the selected window according to the style defined in `selected-window-accent-mode-style`.

6.4 selected-window-accent-mode-style

Current style for accenting the selected window.

The style determines how the selected window is visually distinguished from unselected ones.

  • `default’: No special styling, uses the default Emacs appearance.
  • `tiling’: Accentuates the fringes and mode line of the selected window with a thicker appearance, based on `selected-window-accent-fringe-thickness`.
  • `subtle’: Adds a subtle accent to the selected window with minimal visual change.

7 Minor Mode

The selected-window-accent-mode is a global minor mode that you can toggle to enable or disable the accenting of the selected window.

When enabled, it distinguishes the selected window with a special accent color.

8 Hooks

Two hooks are used to automatically update the window accents when the window configuration or state changes:

  • window-configuration-change-hook
  • window-state-change-hook

These are added when the selected-window-accent-mode is enabled and removed when disabled.

9 TODOs / ROADMAP

____________________ roadmap ____________________

DOING add to MELPA

TODO Incorporate `mode-line-active’ and `mode-line-inactive’ somehow as this would make more sense especially in the ‘default mode.

TODO highlight selected tab with same accent color?

TODO header-line not shown on window split - I have a funny feeling this could be very difficult, if not impossible!

TODO restore modeline height when switching between modes

TODO adjust the not selected-window margin to avoid little window navigation. disruption, hence translating a fringe pixel width to a number of margin characters, not quite sure how I am going to do this yet.

TODO excess selected-window disruption in header-line. (not sure I can do much about this)

TODO define more custom variables:

  • accent color saturation adjustment
  • accent color darken adjustment
  • accent color hue adjustment
  • compensating margin

TODO define which theme face attribute to use as the main accent color

Currently the default is to use the `highlight’ face

WATCH possible overheads of updating visual elements for each window?

WATCH careful with removing header-line on all windows, for example magit commit window and probably some others may need to add some logic depending on mode.

10 Testing

See CHANGELOG.org