My first emacs package - *selected-window-accent-mode*

From my previous two posts regarding defining a Selected Window Accent some interesting posts from irreal arose, especially:

Marking The Active Window

Where it looks like the simple mode-line-active and mode-line-inactive was a good way to indicate the current focussed window, and I do agree.

However to practice my elisp and to create my first emacs package I thought I would bring together my preference which is to have a tiling window manager type of focus involving typically a border around the current window while leveraging the usual customization options that come with emacs.

I have put it on github/captainflasmr for now and below is the README for a package called selected-window-accent-mode

It’s a bit rough around the edges (pardon the pun!) but I think it might be a good starting point for further improvements.


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.


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)

Installation

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"))

use-package (MELPA)

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)

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 :

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)

Examples

Example 1 - Default / custom color

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-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.


Example 2 - Tiling / custom color / custom fringe thickness

(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 #4175b2 more akin to a tiling window manager.


Example 3 - Tiling / theme highlight color

(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.


Example 4 - Subtle / custom fringe thickness (thick)

(setq selected-window-accent-fringe-thickness 40)
(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.


Customization

Can be done through the customization interface:

Selected Window Accent Group group:

Customization group for the selected-window-accent package.

Selected Window Accent Custom Color

Custom accent color for the selected window. Set this variable to change the accent color.

Selected Window Accent Fringe Thickness: Integer:

The thickness of the fringes in pixels.

Selected Window Accent Mode: Boolean: Toggle

Non-nil if Selected-Window-Accent mode is enabled

Selected Window Accent Mode Style

Current style for accenting the selected window.


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:

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


BUGS

The current version is pretty rough and probably definitely pre-alpha.

Fix these to get to a tagged Version 0.1.

In order of priority


ROADMAP

1. add to MELPA

2. define more custom variables:

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

Currently the default is to use the highlight face

4. DOING implement accent styles

Comments

comments powered by Disqus