Skip to content

bnbeckwith/wc-goal-mode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 

Repository files navigation

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

You can easily install this via the packages in MELPA or MELPA Stable.

Alternatively, 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)

Once installed, you can set up a key binding:

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

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

About

Emacs mode to achieve word-count goals

Resources

Stars

Watchers

Forks

Packages

No packages published