Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/zk-phi/electric-spacing

Insert spaces automatically between user-defined patterns
https://github.com/zk-phi/electric-spacing

emacs

Last synced: 3 days ago
JSON representation

Insert spaces automatically between user-defined patterns

Awesome Lists containing this project

README

        

* electric-spacing.el

空白の自動挿入

insert spaces automatically between user-defined patterns

** Screencast

[[screencast.gif]]

** Installation

Require this script

: (require 'electric-spacing)

and you may enable electric-spacing-mode with =M-x
electric-spacing-mode=. Loading the mode in major-mode-hooks may also
be useful.

: (add-hook 'org-mode-hook 'electric-spacing-mode)

** Defining Patterns

You may define a pattern where whitespaces should be inserted, by
adding a regexp-pair to =electric-spacing-regexp-pairs=. For example,
following setting inserts spaces between Japanese and English
characters like: =foo ほげ bar ふが=

#+begin_src emacs-lisp
(add-to-list 'electric-spacing-regexp-pairs
'("\\cA\\|\\cC\\|\\ck\\|\\cK\\|\\cH" . "[0-9A-Za-z]"))
(add-to-list 'electric-spacing-regexp-pairs
'("[0-9A-Za-z]" . "\\cA\\|\\cC\\|\\ck\\|\\cK\\|\\cH"))
#+end_src

You may define a buffer-local pattern by making
=electric-spacing-regexp-pairs= buffer-local before registering the
pattern.

: (make-local-variable 'electric-spacing-regexp-pairs)