Coder Social home page Coder Social logo

emacsmirror / whitespace-cleanup-mode Goto Github PK

View Code? Open in Web Editor NEW

This project forked from purcell/whitespace-cleanup-mode

0.0 4.0 0.0 28 KB

Intelligently call whitespace-cleanup on save

Home Page: https://github.com/purcell/whitespace-cleanup-mode

Emacs Lisp 89.45% Makefile 10.55%

whitespace-cleanup-mode's Introduction

Melpa Status Melpa Stable Status Build Status Support me

whitespace-cleanup-mode.el

This Emacs library minor mode will intelligently call whitespace-cleanup before buffers are saved.

whitespace-cleanup is a handy function, but putting it in before-save-hook for every buffer is overkill, and causes messy diffs when editing third-party code that did not initially have clean whitespace.

Additionally, whitespace preferences are often project-specific, and it's inconvenient to set up before-save-hook in a .dir-locals.el file.

whitespace-cleanup-mode is a minor mode which calls whitespace-cleanup before saving the current buffer, by default only if the whitespace in the buffer was initially clean. It determines this by quickly checking to see if whitespace-cleanup would have any effect on the buffer. With the custom variable whitespace-cleanup-mode-only-if-initially-clean toggled off, it will always clean up the buffer for you.

Installation

If you choose not to use one of the convenient packages in Melpa, you'll need to add the directory containing whitespace-cleanup-mode.el to your load-path, and then (require 'whitespace-cleanup-mode).

Usage

Enable whitespace-cleanup-mode in an individual buffer like this:

M-x whitespace-cleanup-mode

Optionally enable it everywhere by default using global-whitespace-cleanup-mode. (You can override that by setting whitespace-cleanup-mode to nil in file or directory local variables.)

Alternatively, enable whitespace cleanup for a particular major mode:

(add-hook 'ruby-mode-hook 'whitespace-cleanup-mode)

To enable it for an entire project, set whitespace-cleanup-mode to t in your .dir-locals.el file.

This mode is built upon some functionality built into whitespace-mode, namely whitespace-action: if you would rather see a warning when saving a file with bogus whitespace, or even have the save aborted, then set that variable.


Steve Purcell's blog // @sanityinc on Twitter

whitespace-cleanup-mode's People

Contributors

jrosdahl avatar nilninull avatar purcell avatar robertpark avatar skeeto avatar swsnr avatar wyuenho avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.