Giter VIP home page Giter VIP logo

wc-goal-mode's Introduction

Wordcount Goal Mode

This is a minor mode to provide a โ€˜wcโ€™ function for Emacs buffers as well as a modeline addition with live word, line and character counts.

Additionally, a user can set specific goals for adding or deleting words. These goals were partly inspired by 750words.com where the goal of the site is to encourage writing by setting a goal of 750 words at a time. I wanted the same functionality in Emacs.

Installation

Obtain the package from Github

git clone git://github.com/bnbeckwith/wc-goal-mode.git

Then, add to your Emacs setup.

;; Add the path to the repo
(add-to-list 'load-path "/path/to/wc-goal-mode/")
(require 'wc-goal-mode)
;; Suggested setting
(global-set-key "\C-cw" 'wc-goal-mode)

The code above sets up the minor mode and then assigns a global key to toggle the mode on and off.

Customization

There are a few settings that may be customized to provide better functionality for you.

Modline string

The default string displayed in the mode line can be changed to suit your needs. It can be defined through the variable customizaton interface.

The setting itself is simply a string with a few special characters to represent the available statistics. These character strings are listed in the follow table.

Format StringMeaning
%COriginal character count
%WOriginal word count
%LOriginal line count
%cChange (delta) in characters
%wChange (delta) in words
%lchange (delta) in lines
%gcCharacter change goal
%gwWord change goal
%glLine change goal
%tcTotal number of characters
%twTotal number of words
%tlTotal number of lines

Counting functions

The default character, word and line counting functions may not produce the desired results. They can be overridden on a per-buffer basis by supplying new functions to the appropiate variables.

These functions must take RSTART and REND arguments representing the start and end points of the region on which to perform the count.

For example, if you had a CSV file and wanted each entry to count as a word, you would override the default behavior as follows.

;; Override the counting of words to count commas (fields)
(setq wc-goal-count-words-function
   (function (lambda (rstart rend)
     (how-many "[^,\\n]+" rstart rend))))

Notes

This was originally named wc-mode, but another package had the same name. It was already on the ELPA servers, so I opted for a name change.

And since I lacked creativity that day, the functions are really just wc-goal- instead of the wc- prefix.

wc-goal-mode's People

Contributors

bnbeckwith avatar dato avatar lightquake avatar tarsius avatar

Watchers

 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.