Emacs Web-mode left arrow without the right closing angle bracket

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"))))


PS: I posted this here Emacs Stackexchange in case you think you’ve seen it asked before.

According to the documentation you have to use (sp-local-pair "<" nil :actions :rem).

Thanks for trying to help but I get the error message File mode specification error: (wrong-type-argument consp nil) when I use the form suggested in your reply.

In the docs, all examples of sp-local-pair take the major mode as argument.

Though I’m not sure if thats obselete due to your use of sp-with-modes.

Yeah in this case web-mode is the major mode but it’s not working for some reason. Any way thanks for trying.

I’ve also noticed this in emacs, it is quite irritating, though expected, I’ve mostly got used to just typing <delete to get a single <. ^.^;

How do you format keybinds like you do here in the forum? Never knew.

<kbd> HTML tag, C is created via <kbd>C</kbd>.