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.
See docs/selected-window-accent-mode.org for the manual!
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.
- Added texinfo manual
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
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))(use-package selected-window-accent-mode
:config (selected-window-accent-mode 1))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))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)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:
Command: selected-window-accent-switch-style
This command allows you to cycle between the three available accent styles:
default: Standard Emacs appearance without special accentingtiling: Thicker fringes and mode line for a more pronounced window bordersubtle: 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.
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.
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.
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.
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.
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.
(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 is using the theme doom-one
(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 is using the theme doom-one
(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 is using the theme doom-one
The takes the default highlight color from the theme as before but applies darkening and desaturation.
(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 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.
(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))| Custom variable | Description |
|---|---|
| selected-window-accent-custom-color | Custom accent color for the selected window. |
| selected-window-accent-mode-style | Style for accenting the selected window. |
| selected-window-accent-mode-hook | Hook run after entering or leaving `selected-window-accent-mode’. |
| selected-window-accent-percentage-desaturate | Percentage to desaturate the accent color. |
| selected-window-accent-map | Keymap for selected-window-accent commands. |
| selected-window-accent-smart-borders | When non-nil, don’t accent single-window frames. |
| selected-window-accent-tab-accent | When non-nil, accent the selected tab in the tab-bar. |
| selected-window-accent-fringe-thickness | Thickness of the accent fringes in pixels. |
| selected-window-accent-mode | Non-nil if Selected-Window-Accent mode is enabled. |
| selected-window-accent-percentage-darken | Percentage to darken the accent color. |
| selected-window-accent-sync-tab-bar-to-theme | Synchronize tab-bar faces with the current theme. |
| selected-window-accent-switch-selected-window-accent-style | Switch the selected window accent style to STYLE and apply it. |
| selected-window-accent-increment-foreground-color | Increment the foreground color brightness. With ARG, adjust by a larger factor. |
| selected-window-accent-decrement-foreground-color | Decrement the foreground color brightness. With ARG, adjust by a larger factor. |
| selected-window-accent-flip-foreground-color | Flip the current foreground color to its opposite value. |
| selected-window-accent-output-selected-window-accent-settings | Output current `selected-window-accent-mode’ settings to a new buffer. |
| selected-window-accent-transient | Transient for selected window accent. |
| selected-window-accent-toggle-tab-accent | Toggle between showing the tab accent. |
| selected-window-accent-mode | Toggle selected window accenting. |
| selected-window-accent-toggle-pywal | Toggle between pywal. |
| selected-window-accent-switch-accent-color | Switch the selected window accent color and apply it. |
| selected-window-accent-toggle-blend-background | Toggle between blend background. |
| selected-window-accent-toggle-smart-borders | Toggle between smart borders. |
| selected-window-accent-toggle-complementary-color | Toggle between complementary color for foreground based on background color. |
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.
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.
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.
position: left, right face-attribute: ‘fringe : all-windows size: (set-window-fringes left right) : per-window
position: top value: header-line-format : per-window face-attribute: ‘header-line : all-windows size: face-attribute :height : all-windows
position: bottom value: mode-line-format : selected-window face-attribute: ‘mode-line-active : selected-window size: face-attribute :height : all-windows
face-attribute: ‘tab-bar-tab
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
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!
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.
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.
| TODO | DOING | DONE |
|---|---|---|
| ISSUE #6 - Feature request: accent currently se… | ISSUE #4 - Doesn’t work well with other packages | ISSUE #1 - Do not apply highlighting when frame… |
| Limiting magit-log when enabled | ISSUE #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 |
| TODO | DOING |
|---|---|
| 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 |
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.
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.
- byte-compile / flycheck
- checkdoc
- package-lint
- other
This would make more sense especially in the ‘default mode. So in-built Emacs modeline functionality would come into play.
See CHANGELOG.org
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.
“It Loop windows at frame, measure and adjust contrast. Allow to set color (face) of background and text by comparing their brightness.”
“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.
“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.
“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.
“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.
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.






