Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

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

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 .gitignore
Octocat-spinner-32 Makefile
Octocat-spinner-32 README.md
Octocat-spinner-32 indent-hints.el
README.md

indent-hints.el

Get some hints about whether your buffer is space- or tab-loving


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) (indent-hints-global-mode)

    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.

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

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

(indent-hints-global-activate)

Sets up the minor-mode-alist and buffer-local variable for indentation hints

(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-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
Something went wrong with that request. Please try again.