How can I define a command in paredit mode that swaps parentheses and square brackets?
相关问题
- Symbol's function definition is void: declare-
- How can I set the SVN password with Emacs 23.1 bui
- Emacs shell: save commit message
- emacs bind key to the insertion of another
- Emacs - set mark on edit location
相关文章
- ess-rdired: I get this error “no ESS process is as
- Emacs/xterm color annoyance on Linux
- Does learning one Lisp help in learning the other?
- Pipe less to Emacs
- Capturing the output of “diff” with org-babel
- emacs terminal mode: how to copy and paste efficie
- How to permanently enable the hs-minor-mode in ema
- Pipe emacs shell output to a new buffer
The following code does what you request. You can bind
swap-parens
to whatever key binding you want.So the task is to turn this, for example:
into this:
With paredit mode, move to start of the expression
(a ..)
and then:Without paredit, but still wanting to maintain balanced parens during transitions, move to
a
and then pressC-M-SPC
multiple times until error and then (assuming that CUA mode is on):Well that is complex, so let's stick with paredit mode version, and try to make a command out of it. Keyboard Macro Editor tells you the names of commands being used, so you would be able to come up with at least the following code:
--
indicates part of code we have not yet decided. After you read documentation of each function in the code, you learn what arguments to pass, and that there is no need to callmark-sexp
. After rewriting docstring and adding a call toleft-char
, the code you end up with would be:bzr branch lp:s-x-emacs-werkstatt
will deliver a library inspired by paredit, but delivering more detailed commands
M-x ar-bracket-parentized-atpt RET
puts brackets around parenteses at point
look inside thing-at-point-utils.el and the other files what else is provided
I'm not sure what you mean by "define command"? You can do it like this:
"|" is point.
Although to be honest, this type of usage scenario is more common for VIM trickery. I've never actually used this IRL.