All Projects → hrehfeld → Emacs Smart Hungry Delete

hrehfeld / Emacs Smart Hungry Delete

An emacs package to delete whitespace between words, parenthesis and other delimiters in a (not very) smart way.

Projects that are alternatives of or similar to Emacs Smart Hungry Delete

Evil
The extensible vi layer for Emacs.
Stars: ✭ 2,265 (+7450%)
Mutual labels:  emacs, editing
Magit Cheatsheet
Stars: ✭ 13 (-56.67%)
Mutual labels:  emacs
Perfect Margin
[emacs] auto center emacs windows, work with minimap and/or linum-mode
Stars: ✭ 26 (-13.33%)
Mutual labels:  emacs
Irony Mode
A C/C++ minor mode for Emacs powered by libclang
Stars: ✭ 851 (+2736.67%)
Mutual labels:  emacs
Emacs Datetime
Stars: ✭ 8 (-73.33%)
Mutual labels:  emacs
Shader Mode
Unity shader editing mode for GNU Emacs
Stars: ✭ 10 (-66.67%)
Mutual labels:  emacs
Danneskjold Theme
Beautiful high-contrast emacs theme
Stars: ✭ 26 (-13.33%)
Mutual labels:  emacs
Hlinum Mode
This library extends linum-mode to highlight current line number.
Stars: ✭ 29 (-3.33%)
Mutual labels:  emacs
Nano Emacs
GNU Emacs / N Λ N O - Emacs made simple
Stars: ✭ 872 (+2806.67%)
Mutual labels:  emacs
Suscolors Emacs
Colorful theme for Emacs, Inspired by Gruvbox.
Stars: ✭ 9 (-70%)
Mutual labels:  emacs
Dakrone Light Theme
Dakrone's custom light Emacs theme
Stars: ✭ 9 (-70%)
Mutual labels:  emacs
Book And Ebook Writing Resources
📚 Tools, articles, publishers... everything you need to know about writing a book or an eBook
Stars: ✭ 8 (-73.33%)
Mutual labels:  editing
Doxymacs
Doxymacs is Doxygen + {X}Emacs.
Stars: ✭ 10 (-66.67%)
Mutual labels:  emacs
Kaleidoscope.el
Control Kaleidoscope-powered devices from the comfort of your Emacs.
Stars: ✭ 8 (-73.33%)
Mutual labels:  emacs
Cfgs
My personal configs
Stars: ✭ 14 (-53.33%)
Mutual labels:  emacs
Assess
Test support functions for Emacs
Stars: ✭ 26 (-13.33%)
Mutual labels:  emacs
Metamorph
Transform your code in turing-complete ways
Stars: ✭ 9 (-70%)
Mutual labels:  emacs
Bonjourmadame
Say "Hello ma'am!"
Stars: ✭ 9 (-70%)
Mutual labels:  emacs
Yard Mode.el
Emacs minor mode for editing YARD tags
Stars: ✭ 29 (-3.33%)
Mutual labels:  emacs
Emacs.dz
Awesome emacs config files
Stars: ✭ 886 (+2853.33%)
Mutual labels:  emacs
  • Smart-hungry-delete

Delete whitespace between words, parenthesis and other delimiters in a smart (dumb) way.

Suppose you have this text in the buffer:

[[./doc/demo-00-01.png]]

With =smart-hungry-delete/backward-char=, it will delete all but one (white-)space between =word= and =paren=:

[[./doc/demo-00-02.png]]

If you delete here:

[[./doc/demo-00-03.png]]

it deletes all whitespace, because it's on the inside of a paren:

[[./doc/demo-00-04.png]]

Inside of right paren:

[[./doc/demo-00-05.png]]

[[./doc/demo-00-06.png]]

This is configured for =C=-like languages (e.g. Python), where =:= usually has no space to the left:

[[./doc/demo-00-07.png]]

[[./doc/demo-00-08.png]]

It has space to the right though:

[[./doc/demo-00-09.png]]

[[./doc/demo-00-10.png]]

This also works for (nested) parentheses:

[[./doc/demo-00-11.png]]

[[./doc/demo-00-12.png]]

[[./doc/demo-00-13.png]]

Between words it will leave a space:

[[./doc/demo-00-14.png]]

[[./doc/demo-00-15.png]]

[[./doc/demo-00-16.png]]

Here's a small demonstration video:

#+begin_html Demonstration Video #+end_html

  • Installing

It's in [[https://melpa.org][MELPA]], so if you have that in your package lists, just =M-x= =package-install= =smart-hungry-delete=, and bind =smart-hungry-delete-backward-char= and =smart-hungry-delete-forward-char=: #+begin_src elisp (require 'smart-hungry-delete) (smart-hungry-delete-add-default-hooks) (global-set-key (kbd "") 'smart-hungry-delete-backward-char) (global-set-key (kbd "C-d") 'smart-hungry-delete-forward-char) #+end_src

If you use =use-package=: #+begin_src elisp (use-package smart-hungry-delete :ensure t :bind (("" . smart-hungry-delete-backward-char) ("C-d" . smart-hungry-delete-forward-char)) :defer nil ;; dont defer so we can add our functions to hooks :config (smart-hungry-delete-add-default-hooks) ) #+end_src

Here's the basic el-get recipe:

#+begin_src elisp (:name smart-hungry-delete :type github :pkgname "hrehfeld/emacs-smart-hungry-delete") #+end_src elisp

  • Configuration

smart-hungry-delete deletes hungrily if three regexps match:

#+begin_src (point) #+end_src

or with =smart-hungry-delete-forward-char=:

#+begin_src (point) #+end_src

You can configure these on a per buffer basis:

=smart-hungry-delete-char-kill-regexp= is a buffer-local variable holding a regex that defines what will be hungrily deleted ().

=smart-hungry-delete-char-trigger-killall-regexps= is a list of pairs:

#+begin_src elisp '(("\[" . ".") ;; delete when is "[" and is any of "." ("." . "\]") ;; delete when is any of "." and is "]" ...) #+end_src

=smart-hungry-delete-add-regexps-left-right= makes it easy to add left-right combinations of chars like parentheses:

#+begin_src elisp (smart-hungry-delete-add-regexps-left-right "\{" "\}") ;;as above, but with "{" and "}" #+end_src

=smart-hungry-delete-add-default-hooks= will add some good defaults for (some) programming modes. Check out the =smart-hungry-delete-default-*-hook= functions.

If you have good suggestions for more defaults, make sure to [[https://github.com/hrehfeld/emacs-smart-hungry-delete/issues][suggest the recipes!]]

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