This is a minor mode to insert semicolon smartly, like Eclipse does.
When smart-semicolon-mode
is enabled, typing ; inserts
semicolon at the end of line if there is no semicolon there.
If there is semicolon at the end of line, typing ; inserts semicolon at the point.
After smart semicolon insert, backspace command reverts the behavior as if ; is inserted normally.
- Emacs 26
Package install from MELPA.
M-x package-install
[RET] smart-semicolon
[RET]
Clone the repository from GitHub.
$ git clone https://github.com/iquiw/smart-semicolon.git
Add the directory to load-path
and require smart-semicolon
.
(add-to-list 'load-path "/path/to/smart-semicolon")
(require 'smart-semicolon)
Add smart-semicolon-mode
to some major mode hooks where you want to
enable smart-semicolon
.
(add-hook 'c-mode-common-hook #'smart-semicolon-mode)
To trigger the smart insert by other character than semicolon, add the
character into smart-semicolon-trigger-chars
.
(add-to-list 'smart-semicolon-trigger-chars ?:)
Or set smart-semicolon-trigger-chars
to list of the character to use only
the character.
(setq smart-semicolon-trigger-chars '(?:))
To block smart semicolon insert when some character exists at eol, add the
character into smart-semicolon-block-chars
.
(add-to-list 'smart-semicolon-block-chars ?,)
Or set smart-semicolon-block-chars
to list of the character to use only
the character.
(setq smart-semicolon-block-chars '(?,))
To treat some command as backspace command, add the command to
smart-semicolon-backspace-commands
.
(add-to-list 'smart-semicolon-backspace-commands 'my-backspace)
Licensed under the GPL 3+ license.