emacs-evil / evil-cleverparens Goto Github PK
View Code? Open in Web Editor NEWEvil normal-state minor-mode for editing lisp-like languages
Evil normal-state minor-mode for editing lisp-like languages
After downloading emacs following http://eschulte.github.io/emacs24-starter-kit/#emacs-lisp-package-archive, I now want to enable Melpa.
The below is what I typed into an org document under the directory emacs.d :
#+BEGIN_SRC emacs-lisp
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/") t)
#+END_SRC
upon typing C-c C-c, I get the response "Wrong type argument: listp, "http://melpa.org/packages/"
What am I doing wrong??? I'd greatly appreciate any help offered.
I am watching editing support for lisp and Clojure quite a while now. At the moment I am using lispy hinting the author if I find something od while using it.
Using Clojure as my default language I plan to switch from my prelude based emacs to spacemacs once there is a seamless integration of lisp editing support.
The author of lispy provides the best documentation and training tutorials known to me.
Despite the potential of becoming the sweet spot in editing between text and graphical ui, I still hesitate to recommend emacs and lisp editing support because it is hard to figure out which mode and key bindings to get used to for editing text trees - lisp and even similar applications like org document trees and markdown.
I feel it as a burden having to switch key bindings for each text format although I am semantically doing the same thing - editing trees of text in multiple files.
As I see it at the moment all these projects providing support for editing text trees target a very important issue in keyboard based human computer interaction.
This seems to be a hard problem at the core and I feel respect for people tackling this one.
Given:
(spacemacs|define-transient-state sooheon-paste
"\n[%
[_M-n_/_M-p_] cycles through yanked text, [_p_/_P_] pastes the same text above or
below. Anything."
:bindings
("M-n" evil-paste-pop))
With cursor anywhere on line 4, D
will return something like this:
(spacemacs|define-transient-state sooheon-paste
"\n[%
[_M-n_/_M-p_] cycles through yanked text, [_p_/_P_] pastes the same text above or
M-n" evil-paste-pop))
with unbalanced parens. The snippet above is not valid elisp (I was looking for minimum reproducible fragment), but syntactically it's correct. The problem is that instead of deleting only to the end of the current string, it joins all the way to the start of the next string, deleting everything inbetween. I think the problem has something to with the weird characters in the string, as deleting the middle line of the multiline string makes this unreproducible.
From
"hello|9"
with cursor at |
, pressing ce
will result in:
"hello"|
leaving cursor outside the closing quote.
I think it would be a good idea to have a safe equivalent of evil-delete-backward-word
, evil-delete-backward-char
, etc. One technique would be to do nothing, but there is also the route that lispy takes, which is to delete the entire sexp when deleting at (|
or |)
. I think the latter makes the most sense.
evil-cp-change-line
puts cursor on the next line if:
For example, calling in the following situation:
(defn foo [|a]
bar)
Gives:
(defn foo []
|bar)
While you almost certainly want
(defn foo [|]
bar)
Does evil-cleverparens intend to support clojure specific edge cases?
Hi, how can I customize evil-cp-a-form
to select text surrounded by single quotes?
Since the comment and form text objects work for more than just lisp modes (modes where the user would want evil-cleverparens-mode
enabled), it might make sense to pull (evil-cp--enable-text-objects)
out of evil-clever-parens-mode
and add autoloads for each text object individually (which would also mean that the users could choose a different key for binding them if they wanted). For example, one might want to use the comment text object before ever entering some lisp mode, and currently, the text objects will not be defined/bound until the user has started the evil-cleverparens-mode
once.
As far as I understand - text objects should allow me operate on those objects while using yank/delete/etc operations. But df
does not delete a form and non of the other such commands work. Am I missing something?
Most of the key bindings go into the mode map, which only needs to be populated once. Binding the keys in the mode toggle function means that to change them I either need to manipulate the variables holding the bindings or rebind in a hook, both of which seem unnecessarily complicated. If you just define the keys in the map once, I can just change the binding in the map directly.
Best described with a video.
https://dl.dropboxusercontent.com/u/11400324/evilcleverparens.mov
(use-package evil-cleverparens
:commands (evil-cleverparens-mode)
:diminish (evil-cleverparens-mode)
:init
(setq evil-cleverparens-use-additional-bindings nil)
(setq evil-cleverparens-use-additional-movement-keys nil)
(dolist (hook '(lisp-mode-hook
emacs-lisp-mode-hook
lisp-interaction-mode-hook
clojure-mode-hook
cider-mode-hook
cider-repl-mode-hook))
(add-hook hook (lambda ()
(evil-cleverparens-mode)))))
I spent some time trying to figure this one out but there's too much going on with Evil and Emacs that I ran out of energy to figure it out. Will check up on it again later.
The documentation for evil-cp-additional-bindings says: "Alist containing additional functionality for evil-cleverparens via a modifier key (using the meta-key by default)." Is it possible to change the modifier key to (say) Alt?
Thanks!
Hi,
I am looking for help in how to disable certain key bindings in evil-cleverparens mode eg: M-w, M-[ as these casuing conflicts with certain other modes I use.
It can be categorized as not an issue but any help with extra documentation will certainly help.
I just updated packages and trying to enable cleverparens displays this error:
Symbol's value as variable is void: state
This is with Spacemacs, and I currently have installed:
Happy to help debug further, but I’m not much of an Emacs expert.
BTW, thank you so much for this package! I work with Clojure, and this does exactly what I want it do. It’s great.
Please add this line into evil-cleverparens.el
(require 'subr-x)
My emacs need this line to work. http://ergoemacs.org/emacs/elisp_trim_string.html
(f ;; (
'x)
Calling evil-cp-a-form
with the point at f
results in
Search failed. This means there is unmatched expression somewhere or we are at the beginning/end of file.
evil-cp-a-form: Wrong type argument: number-or-marker-p, nil
Now that evil jump is a part of evil itself, it would be great if moving around with M-h/l
, S-h/l
, etc. left history in the evil-jump history, to enable C-i/C-o
movement.
I've been noticing some odd behavior with > and < in normal state.
Can't barf an expression and end up with an empty sexp. This works fine with >
(func ([)] (a)) => (func ( (a)[)])
but I can't reverse this operation with <
I've had some issues with the point not staying on the point after a barf or a slurp (sorry I can't come up with a working example right now, but I'll post it as soon as I do)
I have tried (setq evil-cleverparens-use-additional-bindings nil)
, as well as custom-set-variables, and both do not seem to take effect. Can anybody reproduce this?
Hi again, I noticed that if I put the point on the first letter in a sexp and enter insert state cleverparens is adding an extra space between the point and the first letter. Is this intentional? If this doesn't happen for you I'll come up with some steps to reproduce. I'm pretty confident it happens consistently for me.
evil-cp-change must move the cursor similar to evil-change e. g.
(|foo "bar")
evil-change will move the cursor when pressing ci" into the double quote, while evil-cp-change will keep the current cursor position.
Given
(+ 1
(+ 2 3
4 5))
hitting yy
on line 2 will copy the whitespace before the parens instead of the contents afterward. This surprising to me, but perhaps reasonable behavior. The issue comes when using dd
on that line- it deletes + 2 3
but still yanks the whitespace before. I have found a simple patch for this which makes both yy
and dd
yank the text after the parens, which I will be uploading as a pr soon. It works by having evil-cp-yank
skip preceeding whitespace before calling evil-cp--ignoring-yank
.
Ran into this today. Example
(when ready
(let (a b)
(setq a 1
b 2)
(command a b)))
use V
to select the last three lines and y
. Then moving somewhere else, p
gives
(setq a 1
b 2)
(command a b)))
notice the extra parens. The extra parens are not there if you just yy
on the last line
It's not in Evil Cleverparens Use Additional Bindings
or Evil Cleverparens Use Additional Movement Keys
.
I'm using hook to disable it to get evil-shift
back.
Hi, This is a minor annoyance for me, but maybe there's something you can do about it. Here's an example, where I'm using .
to represent spaces
;;.A.sentence.in.a.comment
(progn.(a).(sequence).(of).(commands))
If I daw
on "sentence", I get
;;.A.in.a.comment
(progn.(a).(sequence).(of).(commands))
but daf
on sequence
then gives
;;.A.in.a.comment
(progn.(a)..(of).(commands))
Notice when I delete "sentence" it also deletes one space, but I'm left with two spaces between (a)
and (of)
, which I typically then have to fix right away.
Maybe this is too complicated to fix, but if it's not, I'd appreciate it if the behavior with regards to whitespace leftover was consistent.
By the way I've been using this package for a while now, and it really makes editing lisp much more pleasant, so thank you.
In regular evil and vim, cw
in this case:
foo |bar baz
Will drop you into insert in:
foo | baz
In evil-cp, it seems to be:
foo |baz
which is unexpected. Is there a way around this? I don't plan to change my muscle memory to use ce
:/
is there a way to disable evil-cleverparens x
behavior?
it would be handy to turn this off so you can delete with x
without accidentally dropping a set of parens.
When running emacs in a terminal, evil-cleverparens does something extra-funky to the keybindings.
Steps:
Result:
M-O
followd by A', with the result that you end up in insert mode, on a new line above the current function, with a capital letter
A`.Turning off cleverparens mode restores the normal functioning of the arrow keys. Also, as noted above, the weirdness does not start until you enter and then exit visual mode.
In case it matters, I see this behavior in Spacemacs.
Evil-unimpared uses [-<SPC>
and ]-<SPC>
to add spaces above and below the current line, but when you add evil-cleverparens-mode to the clojure-mode hook it clobbers the whole prefix space with evil-cp-previous-opening
and evil-cp-next-closing
.
If the mappings were to use [[
and ]]
instead then the [
and ]
prefix spaces would be left open for other packages to utilize as well.
For the following string, y will not copy the quotation mark with yf"
, but df"
will copy and delete the quotation mark.
"Example| string"
Noticed evil-cp-delete-char-or-splice is calling evil-cp--yank which eventually checks
(when evil-was-yanked-without-register
(evil-set-register ?0 text)) ; "0 register contains last yanked text
where evil-was-yanked-without-register is t (for some reason).
With evil-cleverparens disabled, on a text of
a
b
yy on line a -> :reg -> a is in the 0 register
dd on line b -> :reg -> a is in the 0 register, b is in the 1 register (and others) (expected)
With evil-cleverparens enabled, with the same text
yy on line a -> :reg -> a is in the 0 register
dd on line b -> : reg -> b has replaced a in the 0 register (unexpected)
Any time I press x
or X
(bound to evil-cp-delete-char-or-splice
/evil-cp-delete-char-or-splice-backwards
, respectively). I get the error "Wrong type argument: char-or-string-p, nil".
I'm using evil-cleverparens with clojure-mode/cider/smartparens-config. This is likely an interaction with some other configuration of mine, however the problem only occurs when evil-cleverparens is enabled, not with any of the other modes alone.
Any tips on how to debug this would be appreciated!
Here's a test case
(a
(c (d e)))
If I do yy
on the second line it doesn't copy the whole line which is fine, but if I then hit p
right away I expect the paste to be on a new line below line 2 but it's not. the result is something like this
(a
(c (d e))(c (d e)))
I would expect something like
(a
(c (d e)))
(c (d e))
That's different behavior from yyp
on
(c (d e))
Do you agree that this is wrong?
I think it would be better to "pretend" that you yanked a whole line for pasting purposes even though you didn't
I looked through the documentation and didn't see a way to move backwards and downwards into a sexp: something like paredit-backward-down (C-M-p). Actually, I don't see a command for moving forward and down into a list either: something like paredit-forward-down. I'm thinking this functionality must exist, so perhaps I'm just overlooking it...
Hi again,
I was wondering if there was a way to intelligently deal with comments. Here's an example
(let (a)
;; a is ...
(setq a 1))
Try dd
on the last line. The closing paren moves into the comment and now we have a problem and need a manual fix. Is it possible to jump the comment or put the closing paren before the comment? Something that would keep the expression valid.
Known issue, follow up here:
If I select commented lines that contain a sexp and hit d
, I get weird behavior. For example, the following
;; (defcustom example t
;; "example of commented sexp"
;; :type 'boolean)
will become
()
This also happens when using the comment text object.
Furthermore, if I visually select that comment and hit y
or use yac
, only ";; " will be copied to the kill ring instead of all three lines.
Trying to delete comments with unbalanced parenthesis will also delete everything but the parens and actually cause the file to have mismatched parens.
Test case
(["]a" "b")
I'm not sure what's going on here, and I don't have time to test a bunch of cases right now, but if you hit x from the state above you get this which is not what I expected.
("[a]" "b")
Hey, first of all thanks for this package, I think it's great.
I noticed a slightly annoying behavior for evil-cp-forward-sexp
and evil-cp-backward-sexp
(L and H). Consider this elisp file (|
denotes the cursor):
'(|("aaa" . bbb)
("ccc" . ddd))
If evil-move-beyond-eol
is t
, then pressing L once moves the cursor after "bbb)":
'(("aaa" . bbb)|
("ccc" . ddd))
From here, I can press either L or H. If I press L:
'(("aaa" . bbb)
("ccc" . ddd)|)
Or if I press H:
'(|("aaa" . bbb)
("ccc" . ddd))
Which is exactly what I expect to happen, so I consider it a good behavior.
On the other hand, if evil-move-beyond-eol
is nil
, the behavior is a bit off. Starting from the same place as before:
'(|("aaa" . bbb)
("ccc" . ddd))
Pressing L once moves the cursor after "bbb" but before the ")". Because evil-move-beyond-eol
is nil
, this is the expected behavior (so far so good).
'(("aaa" . bbb|)
("ccc" . ddd))
From here, however, pressing either L or H doesn't bring me to where I want. If I press L, the cursor doesn't move at all.
If I press H, the cursor moves in front of "bbb" instead of returning to where it was:
'(("aaa" . |bbb)
("ccc" . ddd))
The two problems here are that in this case H doesn't do the reverse of L, and that I can't move forward in the list because of how evil-mode adjusts the cursor.
Will it be possible to modify evil-cp-forward-sexp
and evil-cp-backward-sexp
for the case where the cursor is on a closing paren and evil-move-beyond-eol
is nil
? If not,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.