When using Elixir html template (.eex) in web-mode, I sometimes need to type code like <%= for bid <- @bids do %> . At the moment because the opening left angled bracked is closed immediately with a matching right angled bracket, after I type <-, I'm left with a closing angled bracket that I don't need and have to delete.

I need help coming up with a way to prevent the left angled bracket from auto closing.

Below is my current web-mode and smartpatens configs:


(use-package web-mode
  :ensure t
  :mode (("\\.erb\\'" . web-mode)
         ("\\.mustache\\'" . web-mode)
         ("\\.html?\\'" . web-mode)
         ("\\.eex\\'" . web-mode)
         ("\\.php\\'" . web-mode)
         ("\\.jsx$" . web-mode))
  (setq web-mode-markup-indent-offset 2
        web-mode-css-indent-offset 2
        web-mode-code-indent-offset 2)
  ;; make web-mode play nice with smartparens
  (setq web-mode-enable-auto-pairing nil)
  ;(setq web-mode-enable-auto-closing nil)
  (setq web-mode-enable-current-element-highlight t)
  (setq web-mode-enable-current-column-highlight t)
  (sp-with-modes '(web-mode)
    (sp-local-pair "<" nil :actions nil)
    (sp-local-pair "% " " %"
                   :unless '(sp-in-string-p)
                   :post-handlers '(((lambda (&rest _ignored)
                                       (save-excursion (insert " ")))
                                     "SPC" "=" "#")))
    (sp-local-pair "<% " " %>" :insert "C-b %")
    (sp-local-pair "<%= " " %>" :insert "C-b =")
    (sp-local-pair "<%# " " %>" :insert "C-b #")
    (sp-local-pair "<-" "")))


(use-package smartparens
  :ensure t
  :hook (prog-mode . smartparens-mode)
  ;; https://stackoverflow.com/questions/23789962/how-to-disable-emacs-highlighting-whitespace-in-parenthesis
  (setq sp-highlight-pair-overlay nil)
  (:map smartparens-mode-map
        ("C-M-f" . sp-forward-sexp)
        ("C-M-b" . sp-backward-sexp)
        ("C-M-a" . sp-backward-down-sexp)
        ("C-M-e" . sp-up-sexp)
        ("C-M-w" . sp-copy-sexp)
        ("C-M-k" . sp-change-enclosing)
        ("M-k" . sp-kill-sexp)
        ("C-M-<backspace>" . sp-splice-sexp-killing-backward)
        ("C-S-<backspace>" . sp-splice-sexp-killing-around)
        ("C-]" . sp-select-next-thing-exchange))
  (require 'smartparens-config)
  (sp-local-pair 'emacs-lisp-mode "'" nil :actions nil)
  (sp-local-pair 'org-mode "[" nil :actions nil)
  (sp-local-pair 'prog-mode "{" nil :post-handlers '((my-create-newline-and-enter-sexp "RET")))
  (sp-local-pair 'prog-mode "(" nil :post-handlers '((my-create-newline-and-enter-sexp "RET"))))


  • Made simple-paren for this, available from melpa, which comes with explicit keys instead of implicit trigger. Jan 13, 2020 at 10:16
  • I'm trying to use your packge without success so far and therefore wondering if I'm doing it right. Below is my config: (use-package simple-paren :config (simple-paren-define left-pointing-single-arrow ?<-) (simple-paren-define angled-bracket-percent-pair ?<% ?%>) (simple-paren-define angled-bracket-equal-pair ?<%= ?%>))
    – Napoleon
    Jan 19, 2020 at 7:56
  • Please consider a bug-report at github.com/andreas-roehler/simple-paren. README there also tells how to extend the package. Jan 20, 2020 at 10:24

1 Answer 1


To remove pre-existing pairs, you have to use :action :rem, not :action nil. There is even an example in the documentation.

So this line:

    (sp-local-pair "<" nil :actions nil)

needs to be changed to:

    (sp-local-pair "<" nil :actions :rem)
  • I tried that before and just tried it again. It gives me an error message File mode specification error: (wrong-type-argument consp nil)
    – Napoleon
    Jan 19, 2020 at 10:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.