• Stars
    star
    435
  • Rank 100,085 (Top 2 %)
  • Language
    Emacs Lisp
  • Created over 9 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Dim the font color of text in surrounding paragraphs

https://melpa.org/packages/focus-badge.svg https://stable.melpa.org/packages/focus-badge.svg

Focus

./focus-demo.gif

This is Focus, a package that dims surrounding text. It works with any theme and can be configured to focus in on different regions like sentences, paragraphs or code-blocks.

Installation

It’s available on MELPA and MELPA Stable:

M-x package-install focus

Usage

Enable focus-mode with M-x focus-mode.

A few interactive functions are provided:

FunctionDescription
focus-change-thingAdjust the narrowness of the focused section for the current buffer
focus-pinPin the focused section to its current location or the region, if active
focus-unpinUnpin the focused section
focus-next-thingMove the point to the middle of the Nth next thing
focus-prev-thingMove the point to the middle of the Nth previous thing

Focus relies on Thing At Point, which can retrieve a thing surrounding the point. These things may be a symbol, list, S-expression (sexp), function definition (defun), sentence, line, page and others. Calling M-x focus-change-thing allows you to interactively change the kind of region which should be in focus.

Focus read-only mode

Enable focus-read-only-mode with M-x focus-read-only-mode. It inhibits changes in a buffer, hides the cursor and provides bindings for moving between things.

Some bindings for simple navigation and exiting `focus-read-only-mode` are provided.

KeybindingDescription
nJump to next thing
SPCJump to next thing
pJump to previous thing
S-SPCJump to previous thing
iExit focus-read-only-mode
qExit focus-read-only-mode

Customization

The choice of what thing is suitable for a mode may be configured by setting the variable focus-mode-to-thing. The default is

'((prog-mode . defun) (text-mode . sentence))

For modes inheriting prog-mode (which are most programming modes), the default is the function-body, and for modes inheriting text-mode, the default is a sentence.

For instance, adding the following to your .emacs-file:

(add-to-list 'focus-mode-to-thing '(python-mode . paragraph))

changes python-mode to focus in on code-blocks with no blank lines rather than the entire function.

According to this reddit post, Focus plays nice with lsp-mode.

Faces

Focus offers two faces, one for the focused- and unfocused area. By default, the focus-focused is the empty face, meaning there is no change, and focus-unfocused inherits the comment face (which is usually subtle). The faces can easily be customized via M-x list-faces-display.