0
votes

In emacs-lisp mode whenever i insert a closing brace i prefer to have indented to the same column like the corresponding opening brace. How is that possible? If i have eg in my init.el

(defadvice isearch-forward-regexp (before kill-ring-save-before-search activate)
  "Save region (if active) to kill-ring before starting isearch. So that region
can be inserted into isearch easily with C-y."
  (when (region-active-p)
    (kill-ring-save (region-beginning) (region-end))
    ) ;; this should be under (when
  ) ;; this should be under (defadvice
1
Don't do this. Don’t make a habit of putting close-parentheses on lines by themselves; Lisp programmers find this disconcerting. gnu.org/software/emacs/manual/html_node/elisp/… - ntalbs
Please don't do this. It will make it harder for you to interchange code with other elisp writers. - Vatine
The reason strings of "))))))" don't bother lisp programmers is they never count them. The indentation is what matters and parentheses are always balanced because they use paredit. - event_jr

1 Answers

1
votes

It seems that you want to align the close parens to be able to visually match them to the opening ones. You can do that with show-paren-mode instead - it's much better at that job.

As pointed out by others, and I fully agree, the hanging parens are very annoying and painful to look at - don't make a habit out of using them. I've authored a minor mode for editing Elisp which might be interesting for you - lispy-mode:

  1. Pressing i will auto-indent an s-expression, eliminating the hanging parens.

  2. Pressing d will switch from one side of s-expression to the other: a quick way to see what the current list contains.

  3. Pressing m will toggle the region selection on the current list: you can see what it contains even more clearly.