purcell / emacs.d

An Emacs configuration bundle with batteries included
BSD 2-Clause "Simplified" License
6.84k stars 2.05k forks source link

[HowTo] parentheses manipulation/deletion #807

Closed dhruvinsh closed 2 years ago

dhruvinsh commented 2 years ago

What I am looking?

I am seeking better editing reference, like "how you would do?" kind of thing. If you would be able to point out the key evet that you would use, that would be great as well.

Description

Hi @purcell, thank you for this awesome configuration. I started using it and I need little guidance to manipulating text within parentheses. Please bare with me to go through below examples and use-case.

Example:1 lets say, I have lisp code as below, as you see I added two parentheses, how can I get rid of one parentheses pair? my cursor would be at the beginning of the line,

((add-hook 'python-mode-hook 'black-on-save))

Example: 2 Lets say I have below code,

(with-eval-after-load 'python-mode
  (when (executable-find "black")
    (add-hook 'python-mode-hook 'black-on-save-mode)))

If my cursor at the very beginning of (with-eval and using C-k would delete whole code block. C-d will not have any effect for the parentheses part. If I move my cursor within parentheses and use C-k then still all the parentheses remain and we fall back to exapmple-1 kind of code but with more brackets. But what I want to do is convert to below code. How can I do it?

(add-hook 'python-mode-hook 'black-on-save-mode)

I want to learn what you or anyone would do in this case. Thank you for your time and looking into it.

yourroledie commented 2 years ago
(with-eval-after-load 'python-mode
  (when (executable-find "black")
    |(add-hook 'python-mode-hook 'black-on-save-mode)))

M-r

(with-eval-after-load 'python-mode
    |(add-hook 'python-mode-hook 'black-on-save-mode))

M-r

|(add-hook 'python-mode-hook 'black-on-save-mode)