2022 Developer Survey is open! Take survey.
6 votes
Accepted

How do I match a closing bracket in Emacs lisp

Put the ] as the first character after the [ which starts the character class, e.g. [])}] This is the manual page
user avatar
  • 1,829
4 votes
Accepted

Change field separator for sort-fields

See the code for sort-fields? Have you tried substituting a regexp that matches your preferred separators for the hard-coded regexp in sort-fields, which matches whitespace? Untested whether just ...
user avatar
  • 69.2k
3 votes

Easily changing matching quotes

I knew this was going to take some time, but in the end I couldn't resist the temptation to figure out how it's done properly. :) Enjoy! (defun toggle-quotes (uarg) "Toggle single and double ...
user avatar
  • 2,793
3 votes

Getting electric-pair mode to behave more nicely around existing strings

You can also probably (setq-default electric-pair-inhibit-predicate (lambda (c) (if (looking-at "[ \n\t]") (electric-pair-default-inhibit c) ...
user avatar
3 votes
Accepted

Getting electric-pair mode to behave more nicely around existing strings

Change the way pair insertion is inhibited: (setq-default electric-pair-inhibit-predicate 'electric-pair-conservative-inhibit)
user avatar
2 votes

Change field separator for sort-fields

Just use sort-regexp-fields. (Don't change sort.el or redefine any of its functions.)
user avatar
  • 21
2 votes

Determining number of left and right bracketing marks within region

Use M-x count-matches to count matches for a regexp that specifies each char you want to count. E.g M-x count-matches ( counts the number of ( chars in the region. If you want to check for matching ...
user avatar
  • 69.2k
2 votes
Accepted

Easily changing matching quotes

To continue this thread of alternatives... A better workflow than the one you describe is to use electric-pair-mode the way it is meant to so that it works for you instead of against you: Place the ...
user avatar
  • 2,793
2 votes

Highlight matching quotes

Of course it is. (defun show-paren--match-quotes () (let ((ppss (syntax-ppss))) ;; In order to distinguish which quote is opening and which is starting, ;; check that that point is not ...
user avatar
  • 25.2k
1 vote

Easily changing matching quotes

First of all, I disabled electric-pair-mode by: (setq-default c-electric-flag nil) To remove a pair of matching quotes/parens, we can: use expand-region to select the content without the quotes you ...
user avatar
  • 959
1 vote

Easily changing matching quotes

Try embrace. It’s easy to use and does what you want and more.
user avatar
  • 1,259
1 vote
Accepted

How to customize the delimiter in the minor mode Hideshow for use with JSON data?

M-x finder-commentary RET hideshow RET says: Normally, hideshow tries to determine appropriate values for block and comment definitions by examining the buffer's major mode. If there are problems, ...
user avatar
  • 43.1k
1 vote

Lispy and Racket

As noted this is the keybindindgdefined by lispy - } is bound to lispy-brackets which inserts the pair [] I liked the idea of modes that lispy uses but found the keys too odd - I don't like or try to ...
user avatar
  • 275
1 vote
Accepted

Lispy and Racket

Type C-q [ to insert a single square bracket. As noted in the comments type } for a balanced pair of square brackets.
user avatar
  • 10.9k
1 vote

Is there toggle-syntax package for parens, brackets, brokets, braces?

This is a simplistic way to accomplish it for lisp modes (for the limited cases I just tried), using some smartparens functions: (defun toggle-parens () "Toggle parens, braces, brackets." ...
user avatar
1 vote

How to find the matching bracket at a point in elisp?

Generally forward-sexp should know what to do in any given mode, so you could perhaps base it on this: (save-excursion (ignore-errors (forward-sexp) (1- (point)))) Alternatively... Something like ...
user avatar
  • 43.1k
1 vote

Easily changing matching quotes

One option is to use Xah Lee's xah-change-bracket-pairs from http://ergoemacs.org/emacs/elisp_change_brackets.html. To get you started, here are two simple interactive functions that use it to do ...
user avatar
  • 2,793
1 vote

Easily changing matching quotes

https://github.com/andreas-roehler/thing-at-point-utils comes with a ar-delimited2.el which provides for example a command ar-delimited2singlequoted
user avatar
1 vote
Accepted

How to configure the delimiter for evil-search-word for C/C++ modes?

Even though I had: (modify-syntax-entry ?_ "w") Set, some modes ignore this (C/C++ for example) Found solution is to set this for spesific modes: (modify-syntax-entry ?_ "w" c-mode-syntax-table) (...
user avatar
  • 7,069
1 vote
Accepted

How to do paredit-kill backwards?

Since no one here has come up with an answer that is sufficient for my needs, I've continued with my aforementioned implementation which uses paredit-backward-delete under certain conditions. What I'...
user avatar
  • 1,270

Only top scored, non community-wiki answers of a minimum length are eligible