Skip to content

This Emacs package provides functions designed to visually distinguish the currently selected window by applying a unique accent color to its fringes, mode line, header line, and margins.

License

Notifications You must be signed in to change notification settings

captainflasmr/selected-window-accent-mode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

selected-window-accent-mode

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

See docs/selected-window-accent-mode.org for the manual!

Whats New

v2.2.0 <2025-04-23>

Added back in Pywal color support

Introduce selected-window-accent-use-pywal option to allow the usage of a color from the Pywal generated palette.

v2.1.0 <2025-04-05>

  • Added texinfo manual

v2.0.0 <2025-03-04>

refactored/streamlined selected-window-accent-mode

  • Removed dependencies on json and transient libraries
  • Replaced complex color manipulation with straightforward foreground detection
  • Removed pywal integration and background blending features
  • Eliminated header line special handling logic
  • Replaced transient UI with simple keymap for commands
  • Consolidated window handling code for cleaner implementation
  • Reduced overall codebase by ~50%
  • Maintained backward compatibility for core configuration options

Quick Start

To use left and bottom accent based on the themes highlight color:

(use-package selected-window-accent-mode
  :config (selected-window-accent-mode 1)
  :custom
  (selected-window-accent-fringe-thickness 10)
  (selected-window-accent-custom-color nil)
  (selected-window-accent-mode-style 'subtle))

OR define your own color:

(use-package selected-window-accent-mode
  :config (selected-window-accent-mode 1)
  :custom
  (selected-window-accent-fringe-thickness 10)
  (selected-window-accent-custom-color "#427900")
  (selected-window-accent-mode-style 'subtle))

Installation

use-package (MELPA)

(use-package selected-window-accent-mode
  :config (selected-window-accent-mode 1))

use-package (emacs 30+)

Put the following into your emacs init file:

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

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)
(selected-window-accent-mode 1)

Usage

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

Optionally define a keymap:

(global-set-key (kbd “C-c w”) selected-window-accent-map)

and then select any of the following keys:

w - Switch Window Accent Style

Command: selected-window-accent-switch-style

This command allows you to cycle between the three available accent styles:

  • default: Standard Emacs appearance without special accenting
  • tiling: Thicker fringes and mode line for a more pronounced window border
  • subtle: Minimal visual change with accent color applied to fringes

When invoked, it will prompt you with a minibuffer completion interface to select your preferred style. This is ideal for quickly testing which style works best for your workflow.

RET (Enter) - Switch Accent Color

Command: selected-window-accent-switch-color

Pressing Enter in the keymap will prompt you to choose a custom color for your window accenting. This opens a color selection interface where you can either:

  • Type a color name (like “blue”, “tomato”, or “forest green”)
  • Enter a hex code (like “#FF5500”)
  • Use the color picker if your Emacs supports it

This command allows you to personalize your window accenting to match your theme or preferences.

t - Toggle Tab Bar Accent

Command: selected-window-accent-toggle-tab-accent

This toggles whether the tab-bar-tab face should also be accented with your selected color. When enabled, the active tab in your tab bar will match the accent color of your selected window, creating a cohesive visual experience.

This is particularly useful if you use Emacs with tab-bar-mode enabled and want visual consistency between your active window and active tab.

l - Sync Tab Bar to Theme

Command: selected-window-accent-sync-tab-bar-to-theme

This command synchronizes your tab bar appearance with your current theme colors. It sets the tab-bar, tab-bar-tab, and tab-bar-tab-inactive faces to use colors derived from your default face.

This is helpful when switching themes or when you want to reset your tab bar appearance to something that matches your overall Emacs theme rather than your accent color.

b - Toggle Smart Borders

Command: selected-window-accent-toggle-smart-borders

This toggles the “smart borders” feature, which automatically disables window accenting when you have only a single window displayed in a frame. This is a thoughtful optimization that avoids unnecessary visual elements when they’re not needed for distinguishing between windows.

When enabled, your accent colors only appear when you have multiple windows in a frame; when disabled, accent colors are always applied regardless of window count.

Examples

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
  :config (selected-window-accent-mode 1)
  :custom
  (selected-window-accent-fringe-thickness 20)
  (selected-window-accent-custom-color "goldenrod")
  (selected-window-accent-mode-style 'default))

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

Example 2 - Tiling / custom color / custom fringe thickness

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

(use-package selected-window-accent-mode
  :config (selected-window-accent-mode 1)
  :custom
  (selected-window-accent-fringe-thickness 6)
  (selected-window-accent-custom-color "#4179b2")
  (selected-window-accent-mode-style 'tiling))

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

Example 3 - Tiling / theme highlight color

Example is using the theme doom-one

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

(use-package selected-window-accent-mode
  :config (selected-window-accent-mode 1)
  :custom
  (selected-window-accent-fringe-thickness 10)
  (selected-window-accent-custom-color nil)
  (selected-window-accent-mode-style 'tiling))

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

Example 4 - Subtle / custom fringe thickness (thick)

Example is using the theme doom-one

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

(use-package selected-window-accent-mode
  :config (selected-window-accent-mode 1)
  :custom
  (selected-window-accent-fringe-thickness 20)
  (selected-window-accent-custom-color nil)
  (selected-window-accent-mode-style 'subtle))

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

Example 5 - Subtle / theme accent color with darkening and desaturation

Example is using the theme doom-one

The takes the default highlight color from the theme as before but applies darkening and desaturation.

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

(use-package selected-window-accent-mode
  :config (selected-window-accent-mode 1)
  :custom
  (selected-window-accent-fringe-thickness 20)
  (selected-window-accent-percentage-darken 10)
  (selected-window-accent-percentage-desaturate 100)
  (selected-window-accent-custom-color nil)
  (selected-window-accent-mode-style 'subtle))

Example 6 - Subtle / theme accent color with lightening and saturation and tab accent

Example is using the theme doom-one

The takes the default highlight color from the theme as before but applies lightening and saturation along with the same color tab accent.

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

(use-package selected-window-accent-mode
  :config (selected-window-accent-mode 1)
  :custom
  (selected-window-accent-fringe-thickness 20)
  (selected-window-accent-percentage-darken -10)
  (selected-window-accent-percentage-desaturate -100)
  (selected-window-accent-tab-accent t)
  (selected-window-accent-custom-color nil)
  (selected-window-accent-mode-style 'subtle))

Customization

Custom variableDescription
selected-window-accent-custom-colorCustom accent color for the selected window.
selected-window-accent-mode-styleStyle for accenting the selected window.
selected-window-accent-mode-hookHook run after entering or leaving `selected-window-accent-mode’.
selected-window-accent-percentage-desaturatePercentage to desaturate the accent color.
selected-window-accent-mapKeymap for selected-window-accent commands.
selected-window-accent-smart-bordersWhen non-nil, don’t accent single-window frames.
selected-window-accent-tab-accentWhen non-nil, accent the selected tab in the tab-bar.
selected-window-accent-fringe-thicknessThickness of the accent fringes in pixels.
selected-window-accent-modeNon-nil if Selected-Window-Accent mode is enabled.
selected-window-accent-percentage-darkenPercentage to darken the accent color.

Commands

selected-window-accent-sync-tab-bar-to-themeSynchronize tab-bar faces with the current theme.
selected-window-accent-switch-selected-window-accent-styleSwitch the selected window accent style to STYLE and apply it.
selected-window-accent-increment-foreground-colorIncrement the foreground color brightness. With ARG, adjust by a larger factor.
selected-window-accent-decrement-foreground-colorDecrement the foreground color brightness. With ARG, adjust by a larger factor.
selected-window-accent-flip-foreground-colorFlip the current foreground color to its opposite value.
selected-window-accent-output-selected-window-accent-settingsOutput current `selected-window-accent-mode’ settings to a new buffer.
selected-window-accent-transientTransient for selected window accent.
selected-window-accent-toggle-tab-accentToggle between showing the tab accent.
selected-window-accent-modeToggle selected window accenting.
selected-window-accent-toggle-pywalToggle between pywal.
selected-window-accent-switch-accent-colorSwitch the selected window accent color and apply it.
selected-window-accent-toggle-blend-backgroundToggle between blend background.
selected-window-accent-toggle-smart-bordersToggle between smart borders.
selected-window-accent-toggle-complementary-colorToggle between complementary color for foreground based on background color.

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.

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.

Design / Algorithm / Limitations

Just as a note, the overall design of this package is a little, lets just say clunky, something that has been somewhat shoehorned into the Emacs functional architecture, therefore there will be a few little quirks. In this section I look to explain my general design ideas regarding how I achieved some kind of window highlighting / accenting and the associated limitations.

This section is mainly for me, as the maintainer of this package, but may be informative to others. This section is to try and fully understand how I have designed this thing for when I come back and have another rethink on improvements.

Firstly it is important to define the scope of window based visual highlighting in Emacs, which hopefully will help to explain some of the limitations of this package.

It works well enough I think at the moment and I especially I tend to favour the ‘subtle accent mode which inherently has the fewest issues along with providing a satisfying visually distinguishing highlighting mechanism, more bang for the buck if you will.

Emacs repurposed elements

fringe

position: left, right face-attribute: ‘fringe : all-windows size: (set-window-fringes left right) : per-window

header-line

position: top value: header-line-format : per-window face-attribute: ‘header-line : all-windows size: face-attribute :height : all-windows

mode-line

position: bottom value: mode-line-format : selected-window face-attribute: ‘mode-line-active : selected-window size: face-attribute :height : all-windows

tab-bar

face-attribute: ‘tab-bar-tab

Pseudo-code

calculate accent colors
update global face-attributes

walk-windows
  for each window
    update window with accent or default appearance
    if window is not selected
      reset header-line to nil
      reset fringes to 0

Limitations

As a header-line can only have a single global color it does mean that the header-line-format for each window needs to be made blank in order to preserve accent consistency, this means that modes which change the header-line, such as some modes of magit and org-sticky-header will possibly have to be sacrificed for this selected-window-accent-mode to function coherently.

There is a possibility that I could add in some extra logic depending on the mode that is set, but that might be for a future version, and at this moment I’m just not sure the effort is worth it.

The accent is now always alongside an Emacs default margin so as not to overlap with existing packages that utilize the window margin settings, this would make the accent facility look a little less visually appealing then applying a little margin for the selected window along with a compensating margin for non selected windows, but this will have to be sacrificed for not disrupting other Emacs package functionality.

All non selected windows have been fringe zeroed to preserve fringe accent consistency as the fringe color can only be set globally meaning that any Emacs packages that implement fringe functionality, which I have found to be uncommon, would show varying levels of window accents.

When a buffer is split into multiple windows in tiling mode the header line is shared, thus leading to an accented header line across all splits, this is an inherent limitation of Emacs and how it processes windows / buffers.

Phew!, that might be it, this can get quite complicated!

What about overlays?

At the moment this package works well enough for my needs and I will think about overlays again at some point to see if I can somehow re-purpose them to fit my needs, currently it is the buffer / window scrolling that I think would always tend to look pretty clunky if implemented.

The Future

I of course shall keep an eye on Emacs development to see if at some time in the future a more flexible per window visual facility becomes available.

ISSUES

TODODOINGDONE
ISSUE #6 - Feature request: accent currently se…ISSUE #4 - Doesn’t work well with other packagesISSUE #1 - Do not apply highlighting when frame…
Limiting magit-log when enabledISSUE #3 - Package breaks fringes
Add pywal toggle to transient
blend accent color into selected window background
Added pywal integration
Restore modeline height when switching between …
Define accent color saturation adjustment
Define accent color darken adjustment
Highlight selected tab with same accent color
Add to MELPA
Minor change to properly format color-theme-buf…
Pacified package-lint with visual-fill-column 0.0
Added similar package comparisons as suggested
Rename color-name-to-hex to selected-window-acc…
Fixing issues to be able to submit to MELPA
Images to img directory and referenced from README
Expand emacs help / documentation
Add GNU header
Cope better with 0 thickness
Add ChangeLog.
isual-fill-column-mode not working again!
Improve modeline contrast between fg and bg

ROADMAP

TODODOING
Incorporate mode-line-active and mode-line-inactive
Header-line not shown on window split
Adjust the not selected-window margin to avoid little window navigation. disruption
Excess selected-window disruption in header-line. (not sure I can do much about this)
Add some form of unit test

ISSUES (github)

ISSUE #6 - Feature request: accent currently selected/focused frame

If multiple Emacs frames exist, then the selected window in each will be accented. It would be nice if the currently selected/focused frame was accented more than non-focused frames.

ISSUE #4 - Doesn’t work well with other packages

olivetti & org-sticky-header broken with selected-window-accent-mode

I have decided to disable the setting of windows margins as part of this package as this is often used for padding in other packages. This means I can now let packages such as olivetti-mode and visual-fill-column do their own thing without any margin interference. Therefore this package will mainly achieve its functionality via fringe modification rather than fringe/margins.

The disadvantage of this is that on window transition there will be more of a text in buffer offset shift as the select-window-accent-mode fringe is applied to the select window without a default compensatory margin / fringe shift. This didn’t really work anyway and there was always a little shift depending on the width of the native emacs margin character vs fringe pixel size.

This means I don’t have to depend on package checks and maybe packages I am unaware of that depend on window buffer margin changes will work better in the future.

Maybe I can just define a non selected window compensatory margin in the future, for now I will leave as is and see how it goes!

However this currently doesn’t cover any mode that modifies a window header, like for example org-sticky-header.

ISSUE #1 - Do not apply highlighting when frame only contains 1 window

ISSUE #3 - Package breaks fringes

ISSUES (other)

Limiting magit-log when enabled

Add pywal toggle to transient

blend accent color into selected window background

Added pywal integration

Restore modeline height when switching between modes

Define accent color saturation adjustment

Define accent color darken adjustment

Highlight selected tab with same accent color

Add to MELPA

Minor change to properly format color-theme-buffer-local

Pacified package-lint with visual-fill-column 0.0

Added similar package comparisons as suggested

Rename color-name-to-hex to selected-window-accent–color-name-to-hex

Fixing issues to be able to submit to MELPA

  • byte-compile / flycheck
  • checkdoc
  • package-lint
  • other

Images to img directory and referenced from README

Expand emacs help / documentation

Add GNU header

Cope better with 0 thickness

Add ChangeLog.

isual-fill-column-mode not working again!

Improve modeline contrast between fg and bg

ROADMAP

Incorporate mode-line-active and mode-line-inactive

This would make more sense especially in the ‘default mode. So in-built Emacs modeline functionality would come into play.

Header-line not shown on window split

Add some form of unit test

Testing

See CHANGELOG.org

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.

selected-window-contrast

“It Loop windows at frame, measure and adjust contrast. Allow to set color (face) of background and text by comparing their brightness.”

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.

hiwin

“This package provides a minor-mode to change the background color 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.

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.

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.

Contributing

Contributions to arscript-mode are welcome! Whether it’s bug reports, feature suggestions, or code contributions, feel free to reach out or submit pull requests on GitHub.

About

This Emacs package provides functions designed to visually distinguish the currently selected window by applying a unique accent color to its fringes, mode line, header line, and margins.

Resources

License

Stars

Watchers

Forks

Packages

No packages published