An open API service indexing awesome lists of open source software.

https://github.com/mgalgs/indent-hints-mode

Emacs minor mode that gives you helpful hints about whether your buffer is space- or tab-loving.
https://github.com/mgalgs/indent-hints-mode

Last synced: over 1 year ago
JSON representation

Emacs minor mode that gives you helpful hints about whether your buffer is space- or tab-loving.

Awesome Lists containing this project

README

          

Emacs Logo
## indent-hints.el
*Get some hints about whether your buffer is space- or tab-loving*

---
[![License GPLv3](https://img.shields.io/badge/license-GPL_v3-green.svg)](http://www.gnu.org/licenses/gpl-3.0.html)

As the Eternal Holy War of tabs-versus-spaces rages on, even within
individual projects, an emacs minor mode arises from the depths of
github with the goal of easing the burden placed on the programmer
of trying to maintain consistency in text files.

If you jump into a file that uses tabs for indentation, you shall
continue using tabs for indentation. If you jump into a file that
uses spaces for indentation, you shall continue using spaces for
indentation. That's the idea.

### Installation

* For the impatient, here's a quick setup example (after putting
indent-hints.el in your load path):

(require 'indent-hints)
(add-hook 'c-mode-common-hook 'indent-hints-activate)

You should probably at least customize the indent-hints-mode
group to use your preferred space/tabs setup, like so:

M-x customize-group [RET] indent-hints [RET]

* You can set up some "whitespace profiles" that get selected
automatically when a buffer is detected to be tab-loving or
space-loving. To enable this functionality, you should customize
the `indent-hints-mode` group and enable
indent-hints-profile-switching-enabled, or add to your .emacs:

(setq indent-hints-profile-switching-enabled t)

* You can also add your own custom functions to the hooks
`indent-hints-mode-tab-loving-hook` and
`indent-hints-mode-space-loving-hook` which run after a buffer is
detected to be tab-loving or space-loving, respectively.

* To disable profile switching for a particular C style, add the style
name to `indent-hints-ignore-c-styles`, for example:

(setq indent-hints-ignore-c-styles '("linux"))

### Use

Just check out your mode-line to see whether the buffer you're
visiting is space-loving or tab-loving. It also shows the ratio of
space-to-tab (or tab-to-space, whichever your buffer loves)
loving-ness that your current buffer exudes. Here's a "screenshot":

test.el Top -- (Emacs-Lisp \t:0.53 yas pair)--etc. etc.--

The file being visited in the "screenshot" has more tabs than
spaces (53% of the lines that start with some sort of indentation
start with tabs, to be exact).

### Customization Documentation

#### `indent-hints-profile-switching-enabled`

Non-nil means switch between spacing profiles depending on the
tab- or space-lovingness of buffers

#### `indent-hints-tab-width`

When non-nil, the tab-width to use when the tab-loving profile
is enabled.

#### `indent-hints-c-basic-offset`

When non-nil, the c-basic-offset to use when the space-loving
profile is enabled.

#### `indent-hints-c-default-space-loving-style`

When non-nil, the c-default-style to use when the space-loving
profile is enabled.

#### `indent-hints-c-default-tab-loving-style`

When non-nil, the c-default-style to use when the tab-loving
profile is enabled.

#### `indent-hints-space-loving-modeline-indicator`

Modeline indicator to use when the file is space-loving

#### `indent-hints-tab-loving-modeline-indicator`

Modeline indicator to use when the file is tab-loving

#### `indent-hints-neither-loving-modeline-indicator`

Modeline indicator to use when the file is neither-loving

### Function and Macro Documentation

#### `(ih/activate-space-loving-profile)`

Activate the space-loving profile

#### `(ih/activate-tab-loving-profile)`

Activate the tab-loving profile

#### `(ih/count-line-beginnings)`

The real meat. Examine the first character of each line in the
buffer. This can be used to determine if a buffer is space-loving
or tab-loving. Returns a list of the
form: (num-beginning-with-tab num-beginning-with-space
num-beginning-with-something-else)

#### `(ih/update-space-loving-ratio RATIO)`

Update the of space-loving-ness shown in the mode line

#### `(ih/update-tab-loving-ratio RATIO)`

Update the of tab-loving-ness shown in the mode line

#### `(indent-hints-activate)`

Activate indent-hints minor mode for this buffer, if
appropriate.

#### `(indent-hints-mode-on)`

Turns on indent-hints-mode, if appropriate.
This function is intended to be used with define-globalized-minor-mode

#### `(ih/is-temp-buffer THE-BUFFER-NAME)`

Returns true if given buffer name is a temp buffer (starts with " *")

-----


Markdown README file generated by
make-readme-markdown.el