All Projects → mrkkrp → Fix Word

mrkkrp / Fix Word

Transform words in Emacs (upcase, downcase, capitalize, etc.)

Projects that are alternatives of or similar to Fix Word

Magit Cheatsheet
Stars: ✭ 13 (-66.67%)
Mutual labels:  emacs
Geekbook
G33KB00K3 - fun to read & fun to write -- 🤓 eXtreme eXtendable note taking system for nerds/geeks (including scientists!) docs: http://geekbook.rtfd.io = beautiful html generator of your markdown-based notes
Stars: ✭ 31 (-20.51%)
Mutual labels:  emacs
Homebrew Emacs Plus
Emacs Plus formulae for the Homebrew package manager
Stars: ✭ 965 (+2374.36%)
Mutual labels:  emacs
Emacs.dz
Awesome emacs config files
Stars: ✭ 886 (+2171.79%)
Mutual labels:  emacs
Emacs Smart Hungry Delete
An emacs package to delete whitespace between words, parenthesis and other delimiters in a (not very) smart way.
Stars: ✭ 30 (-23.08%)
Mutual labels:  emacs
Ivy Erlang Complete
ivy-erlang-complete is context sensitive completion for erlang without connecting to erlang nodes.
Stars: ✭ 32 (-17.95%)
Mutual labels:  emacs
Darkmine Theme
Yet another emacs dark color theme
Stars: ✭ 10 (-74.36%)
Mutual labels:  emacs
Simple Modeline
A simple mode-line for Emacs.
Stars: ✭ 35 (-10.26%)
Mutual labels:  emacs
Vhdl Mode
A package for Sublime Text that aids coding in the VHDL language.
Stars: ✭ 31 (-20.51%)
Mutual labels:  emacs
Org Reverse Datetree
Reversed date trees for Emacs Org mode
Stars: ✭ 33 (-15.38%)
Mutual labels:  emacs
Globalregion
全球国家/地区下拉级联,包含中英文国际化,国家/省份(直辖市)/城市(区)/县
Stars: ✭ 28 (-28.21%)
Mutual labels:  region
Yard Mode.el
Emacs minor mode for editing YARD tags
Stars: ✭ 29 (-25.64%)
Mutual labels:  emacs
Coldnew Emacs
coldnew's emacs config
Stars: ✭ 32 (-17.95%)
Mutual labels:  emacs
Cfgs
My personal configs
Stars: ✭ 14 (-64.1%)
Mutual labels:  emacs
Organic
Outliner, organizer and notes management app.
Stars: ✭ 34 (-12.82%)
Mutual labels:  emacs
Nano Emacs
GNU Emacs / N Λ N O - Emacs made simple
Stars: ✭ 872 (+2135.9%)
Mutual labels:  emacs
Wordnut
Emacs major mode interface to WordNet lexical database
Stars: ✭ 31 (-20.51%)
Mutual labels:  emacs
Grugru
Rotate text at point in Emacs.
Stars: ✭ 39 (+0%)
Mutual labels:  emacs
Bin cnarea
中国行政区划数据,省市区镇村共五级
Stars: ✭ 34 (-12.82%)
Mutual labels:  region
Elegant Emacs
A very minimal but elegant emacs (I think)
Stars: ✭ 961 (+2364.1%)
Mutual labels:  emacs

Fix Word

License GPL 3 MELPA CI

This is a package that allows us to transform words intelligently. It provides the function fix-word that lifts functions that do string transformation into commands with interesting behavior. There are also some built-in commands built on top of fix-word.

Installation

The package is available via MELPA, so you can just type M-x package-install RET fix-word RET.

If you would like to install the package manually, download or clone it and put on Emacs' load-path. Then you can require it in your init file like this:

(require 'fix-word)

API description

fix-word fnc

Lift the function fnc into a command that operates on words and regions.

The following behaviors are implemented:

  1. If the point is placed outside of a word, apply fnc to the previous word. When the command is invoked repeatedly, every its invocation transforms one more word moving from right to left. For example (upcasing, ^ shows the position of the point):

    The quick brown fox jumps over the lazy dog.^
    The quick brown fox jumps over the lazy DOG.^
    The quick brown fox jumps over the LAZY DOG.^
    The quick brown fox jumps over THE LAZY DOG.^
    

    The point doesn't move, this allows us to fix recently entered words and continue typing.

  2. If the point is placed inside of a word, the entire word is transformed. The point is moved to the first character of the next word. This allows us to transform several words by invoking the command repeatedly.

    ^The quick brown fox jumps over the lazy dog.
    THE ^quick brown fox jumps over the lazy dog.
    THE QUICK ^brown fox jumps over the lazy dog.
    THE QUICK BROWN ^fox jumps over the lazy dog.
    
  3. If there is an active region, all words in that region are transformed.

Use fix-word to create new commands like this:

(defalias 'command-name (fix-word #'upcase)
  "Description of the command.")

There is also a macro that defines such commands for you: fix-word-define-command.


fix-word-define-command name fnc &optional doc

Define a fix-word-based command named name. fnc is the processing function and doc is the documentation string.

Built-in commands

The default commands to upcase/downcase/capitalize words are not convenient, for the following reasons:

  1. There are three different commands for upcaseing, for example. The user needs to remember the three commands, their key bindings, and when to use each of them. There should be one command per action: one for upcasing, one for downcasing, and one for capitalizing.

  2. The commands on regions don't have dedicated key bindings and are disabled by default.

  3. The commands like upcase-word depend on the position of pointer inside of the word, so that the result of upcasing "fo^o"is "foO". This packages assumes that you want "FOO".

  4. One needs to use arguments for commands like upcase-word to make them correct the words that one has just written and only one word can be adjusted in this way.

Here are the commands that try to fix these flaws:

  • fix-word-upcase
  • fix-word-downcase
  • fix-word-capitalize

I propose replacing of the built-ins with these new commands:

(global-set-key (kbd "M-u") #'fix-word-upcase)
(global-set-key (kbd "M-l") #'fix-word-downcase)
(global-set-key (kbd "M-c") #'fix-word-capitalize)

License

Copyright © 2015–present Mark Karpov

Distributed under GNU GPL, version 3.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].