For alphapapa, so he can insert frownies with electric-pair-mode.
This package ships `frowny-mode’, which enables inserting a single “(”
when after a “:” – meaning it’ll insert :( without closing the
parentheses for modes like electric-pair-mode
, paredit-mode
, and
others.
2021-11-07: Add frowny-inhibit-modes
, so I can toggle
hide-details-mode
in dired.
Version 0.2, now with smileys! Yes, if you’re one of those happy-go-lucky people who just has to smile all the time, frowny.el is now for you as well. Go nuts, ya filthy animal.
I use straight.el, which looks like this:
(straight-use-package '(frowny
:host github
:repo "duckwork/frowny.el"))
You might need a different form.
Simple as adding it to whatever modes you don’t want to always insert electric pairs, e.g.
(add-hook 'erc-mode-hook #'frowny-mode)
Or you can enable global-frowny-mode
, which enables frowny in every
buffer. If you want to enable global-frowny-mode
but only for some
modes, customize frowny-modes
.
There are a (growing?) number of customization options available for
frowny-mode
:
frowny-eyes
- the regex to look for when seeing if
(
is completing a frowny. Default:\\(?::-\\|[:=]\\)
, which captures frownies like:(
,:-(
, and ==(. I'd recommend replacing it with an =rx
form, like this:(setq frowny-eyes (rx (or ":" ":-" "=" ":'-")))
frowny-eyes-looking-back-limit
frowny
useslooking-back
to determine whether the(
you type is part of a frowny. Emacs’s manual recommends limiting the number of characterslooking-back
searches for performance reasons, so I recommend setting this number to the maximum length of the strings you have as options infrowny-eyes
. As such, the default is 2.frowny-modes
- When enabling
global-frowny-mode
, you might not want frowny to apply to every buffer. Add modes to this list to only apply frowny to them. By default, frowny applies to every mode. frowny-inhibit-modes
- A list of modes in which to inhibit frowny
mode. By default, only
special-mode
is inhibited. I also adddired-mode
in my configuration.
Of course, you can always customize these options using Emacs’s Customize functionality.
- I should probably make
frowny-modes
more … complex, and allow specifying modes not to apply frowny to. - I could do a
frowny-prog-mode
that checks whether the point is in a comment or not, and frowny accordingly.