Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

How to insert [ ] brackets pair? #22

Closed
JohnGurin opened this Issue Nov 16, 2014 · 4 comments

Comments

Projects
None yet
3 participants

No description provided.

Contributor

bixuanzju commented Nov 16, 2014

press }

Owner

abo-abo commented Nov 16, 2014

Thanks, @bixuanzju.

@JohnGurin, it's a little weird, but if you're familiar with vi, you know how
important it is to quickly enter normal mode (ESC in vi).
Here [, ] and C-3 perform the function of entering normal mode.

The cost is just a small inconvenience for entering []. But since
you already enter {} with a shift key plus [, it's not to
different to enter the other pair shifted as well.

If you want to customize some bindings, look at lispy-setup-new-bindings.
It contains modifications to the default bindings that I don't like any more.
Most importantly the swap of a and h. It's possible that these corrections
will become defaults in a future release.

@abo-abo abo-abo closed this Nov 16, 2014

I'm just getting used to structural editing. So the question about brackets seems silly. Bindings is a matter of taste, and default bindings of current version are fine with me.
In my configuration I added "wrap sexp" binding to resemble paredit's wrap

(defun custom-lispy-wrap ()
    (interactive)
    (call-interactively 'lispy-mark-list)
    (call-interactively 'lispy-parens)
)
(add-hook 'lispy-mode-hook
      (lambda ()
        (local-set-key (kbd "M-(") 'custom-lispy-wrap))) 
Owner

abo-abo commented Nov 16, 2014

Actually lispy-pair will wrap sexp when called with a digit argument,
e.g. 2 ( or C-u (.

Also, lispy-mark-list only works in special currently, so it makes sense
to bind the command that uses it in the appropriate way:

(defun custom-lispy-wrap ()
  (interactive)
  (lispy-mark-list)
  (lispy-parens 1))

(lispy-define-key lispy-mode-map "Y" 'custom-lispy-wrap)

Or add a backup plan in case the point isn't special:

(defun custom-lispy-wrap ()
  (interactive)
  (unless (or (looking-at lispy-left)
              (looking-back lispy-right)
              (region-active-p))
    (lispy-backward 1))
  (lispy-mark-list)
  (lispy-parens 1))

(local-set-key (kbd "M-(") 'custom-lispy-wrap)

sooheon pushed a commit to sooheon/lispy that referenced this issue Sep 10, 2015

Use `font-lock-append-text-property' to non-destructively modify a
string

* ivy.el (ivy--add-face): Improve.
`font-lock-append-text-property' non-destructively changes properties in
a string, which means if a string was copied from another and modified,
the original will not be changed.
In this way, it's better than `add-face-text-property'; and still better
than `propertize' that simply erases all properties before applying.

Fixes #22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment