15

You can add smartparens to the dotspacemacs-excluded-packages list of your dotfile.


11

Emacs-24.4's electric-pair-mode does one part of what you want already (this mode is very similar to autopair.el, not sure how it compares to smartparens). And c-toggle-auto-newline does the other part. But sadly they don't work right together. Please M-x report-emacs-bug so we can fix that. Instead of c-toggle-auto-newline, you can also use electric-...


9

In smartparens-mode, the function sp-up-sexp will move you out of a set of parentheses (bind to your key of choice): Move forward out of one level of parentheses. ... Examples: (foo |(bar baz) quux blab) -> (foo (bar baz) quux blab)| (foo (bar |baz) quux blab) -> (foo (bar baz) quux blab)| ;; 2 (foo bar |baz -&...


7

i (lispy-tab) from lispy does just that. Below is a screenshot of an ERT test visualization (using xv (lispy-view-test)).


7

Solved. The sequence of cursor movements from my first version (in the original post) was funky. As reference for future readers, the following code should work. It obv needs the Smartparens package (which you can get from git-hub). I'm running Emacs 24.4. It works with electric-indent mode enabled or disabled. (defun my-create-newline-and-allman-...


6

smartparens has a superset of the functionality provided by autopair. Apart from providing pair insertion (which is what autopair does) , it supports manipulating what it calls "hybrid sexps" or sexps in non-lisp modes. It provides commands for navigating, marking, joining, splitting, absorbing and more for sexps among other things. I personally use ...


6

Spacemacs uses the concept of toggles to enable/disable minor-modes per buffer. Toggles are grouped under SPC t and SPC T, but they only switch for the current buffer. You can temporarily disable smartparens for the current buffer by pressing SPC t p (spacemacs/toggle-smartparens). But if you want to disable smartparens for every buffer permanently, put ...


5

According to the author of smartparens, sp-autoinsert-if-followed-by-word has been deprecated. Instead, one should use the :when and :unless filters to accomplish what I wanted. (See the documentation.) Thus, the way I managed smartparens to work as I wanted was this: (sp-pair "(" nil :unless '(sp-point-before-word-p)) (sp-pair "[" nil :unless '(sp-point-...


5

Use defadvice to intercept define-key and check for your desired key sequence. (defadvice define-key (before define-key-check-n (keymap key def)) (when (equal key "n") (message "`n' redefined"))) (You can change (message ...) to (debug) or something else that'll give you more information about where you are.) Make the advice effective with (ad-...


4

Overwriting closing pair is called "autoskipping". By default it works only on "active sexp", that is, when user only moves cursor forward after opening delimiter. If user moves cursor backwards the sexp becomes "inactive" and smartparens inserts another pair of delimiters. There is a variable called sp-cancel-autoskip-on-backward-movement, that controls ...


4

Use quoted-insert (C-q) to get around this. E.g. C-q < inserts <. Or, create a key binding to toggle smartparens-strict-mode off and on. This is a waste of keys IMO, but up to you.


3

You can turn off auto pairing for web mode and enable pairing for < & % in smartparens. (require 'smartparens) (sp-pair "%" "%" :wrap "C-%") (sp-pair "<" ">" :wrap "C->") (require 'web-mode) (setq web-mode-enable-auto-pairing nil) Now when you press <%space you will get <% %> with both modes enabled.


3

Try up-list (which is a built-in Emacs function) It lets me jump out of strings, parens, brackets with any nesting.


3

I don't see an option in prelude to disable smartparens globally -- looks like it is enabled in a prog-mode-hook and a few other places. You could advise smartparens-mode (and perhaps smartparens-strict-modeas well) to prevent them from enabling the mode. Assuming you are on Emacs 24.4, try this: (advice-add #'smartparens-mode :before-until (lambda (&...


3

Another, terser, way is to use a smartparens insertion spec. (sp-local-pair 'c-mode "{" nil :post-handlers '(:add ("||\n[i]" "RET")))


3

Have a look at the package smartparens. It can be installed from melpa. You can enable pairs of <> with: (sp-with-modes '(c-mode c++-mode) (sp-local-pair "<" ">")) after (require 'smartparens-config) But be sure to finetune the rule. Have a look at the pair documentation and the complete documentation.


3

I use sp-unwrap-sexp. In your example, having sp-unwrap-sexp bind to M-Backspace sp-next-sexp bind to C-M-n sp-down-sexp bind to C-M-d and a cursor in the beginning of the text, I do: C-M-d to go to {text} M-Backspace to remove outer {} C-M-n 3 times to go to { { {some {extra} unneeded { M-Backspace 2 times to get {some {extra} unneeded { of course ...


2

You could do something like this: (add-hook 'post-command-hook (lambda () (when (not (eq (key-binding (kbd "n") t) 'org-self-insert-command)) (message "Command %s rebound the key!" this-command))) nil t) This will add the lambda function buffer-locally to be run after every command, ...


2

One basic difference is that smartparens can match escaped pairs and non-punctuation mark, like if and fi; you can also customize your pairs. smartparens is really great when working regex where there are lots of escaped pairs like \(...\), since it has its own highlighting for such pairs, making working with sed, awk... much more pleasant.


2

It turns out that the tag completion feature has been removed from the current version of smartparens. If you want to have tag completion, then you need to install the stable version, 1.6.3 from MELPA's stable package listing.


2

You can modify smartparen's behavior by using the functions sp-pair and sp-local-pair. The smartparens wiki explains these functions in detail. Basically you can something like following to customize the behavior globally (sp-pair "\"" nil :unless '(my-custom-predicate)) OR to customize the behavior just for some modes (sp-local-pair desired-modes "\"" ...


2

Yes, with pairing conditionals: ;; a sample from my .emacs.d (defun my-sp-pair-function (id action context) (if (eq action 'insert) ;; t to pair, nil to not pair (or (looking-at "[[:space:][:punct:]]") (sp-point-before-eol-p id action context)) t)) (with-eval-after-load 'smartparens (sp-pair "(" ")" :when '(my-sp-pair-function) :...


2

From https://github.com/syl20bnr/spacemacs/issues/1603#issuecomment-213553034: smartparens-global-mode is a global mode. If it is enabled you get smartparens-mode in every buffer. Turning it off does not prevent you from turning on smartparens-mode anywhere. (That would be silly, because if that were true there would be no way to selectively enable ...


2

Fun fact: there is LaTeX-mode, and then there is latex-mode. Both are aliases for TeX-latex-mode, which is part of the AUCTeX package. If you look at the default value of sp-pairs, you'll see settings for latex-mode, not LaTeX-mode. The following command disabled $ pairing for me in LaTex documents: (sp-local-pair #'latex-mode "$" nil :actions nil) (I use :...


2

What major mode are you using? In emacs-lisp-mode, Smartparens does not automatically close single quotes. To insert a single character, use C-q, quoted-insert, followed by the character. E.g. C-q ' to insert a single quote.


2

Type C-q ( to only insert a single opening paren.


2

Advices suck. Much easier is to just define a new function and bind it to C-w. This is what I use: (defun my-kill-region-or-word (&optional arg) "Kill active region or one word backward." (interactive "p") (if (use-region-p) (sp-kill-region (region-beginning) (region-end)) (if smartparens-strict-mode (sp-backward-kill-word arg) ...


2

One approach here is to use a context-specific key binding for the smartparens commands. (See How can I 'layer' a keybinding?). Here is some code to have the smartparens commands for deleting forward or backward only called when the next (or previous) char is not whitespace: (with-eval-after-load 'smartparens (dolist (key '( [remap delete-char] ...


2

There are a couple of options detailed on the Wiki: https://www.emacswiki.org/emacs/HighlightSexp https://www.emacswiki.org/emacs/HighlightSexps


2

You can try using sp-raise-sexp. From the documentation (C-h f sp-raise-sexp): Unwrap the current list and kill everything inside except next expression. For example, with this: {{text}} You can: place point/cursor on the second { M-x sp-raise-sexp And you will get: {text}


Only top voted, non community-wiki answers of a minimum length are eligible