Doom-emacs: Erroneously deleting right parenthesis in nested parentheses

Created on 1 Jun 2020  路  2Comments  路  Source: hlissner/doom-emacs

What did you expect to happen?
Given some nested parentheses, e.g. ((|)), where | is the cursor in insert mode, pressing backspace deletes the corresponding inner paren, resulting in (|).

What actually happened?
Given some nested parentheses, e.g. ((|)), where | is the cursor in insert mode, pressing backspace deletes the corresponding inner paren as well as the outer paren, resulting in (|.

Additional details:
This applies to any editing mode I have used so far, e.g. elisp, Fundamental, Scheme, Python, etc.
This may be already reported since it happens frequently, but I did not find an existing issue.

config.el

;;; .doom.d/config.el -*- lexical-binding: t; -*-
;; Place your private configuration here:
;; Color theme changer depending on time
(setq hour
      (string-to-number
       (substring (current-time-string) 11 13))) ;; gets the hour
(if (member hour (number-sequence 6 16)) ;; light theme if between 06:00-16:59
    (setq now 'doom-solarized-light)
  (setq now 'doom-dracula)) ;; dark theme from 5pm
(if (equal now doom-theme)
    nil
  (setq doom-theme now))
;; end of color theme code

Steps to reproduce:

  1. Enter scratch buffer (for example).
  2. Enter insert mode and type the character '(' twice. Your buffer should contain '(())' now.
  3. Press backspace.
  4. Note the single left paren remaining.

System information:

emacs   version    26.3
        features   XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS GLIB NOTIFY ACL GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD LCMS2
        build      May 19, 2020
        buildopts  (--prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib --localstatedir=/var --with-x-toolkit=gtk3 --with-xft --with-wide-int --with-modules 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt' CPPFLAGS=-D_FORTIFY_SOURCE=2 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now)
        windowsys  x
        daemonp    server-running
doom    version    2.0.9
        build      HEAD -> develop 134554dd6 2020-05-31 06:19:17 -0400
        dir        ~/.doom.d/
system  type       gnu/linux
        config     x86_64-pc-linux-gnu
        shell      /usr/bin/zsh
        uname      Linux 5.6.15-1-MANJARO #1 SMP PREEMPT Wed May 27 20:38:56 UTC 2020 x86_64
        path       (~/.emacs.d/bin/../bin ~/.emacs.d/bin ~/bin /usr/local/bin ~/.gem/ruby/2.7.0/bin ~/.local/bin /usr/local/sbin /usr/local/bin /usr/bin /usr/lib/jvm/default/bin /usr/bin/site_perl /usr/bin/vendor_perl /usr/bin/core_perl /var/lib/snapd/snap/bin /usr/lib/emacs/26.3/x86_64-pc-linux-gnu/)
config  envfile    envvar-file
        elc-files  0
        modules    (:completion company ivy :ui doom doom-dashboard doom-quit hl-todo modeline nav-flash ophints (popup +all +defaults) treemacs vc-gutter vi-tilde-fringe window-select workspaces :editor (evil +everywhere) file-templates fold multiple-cursors rotate-text snippets :emacs dired electric ibuffer vc :term vterm :tools (eval +overlay) :checkers syntax :tools (lookup +docsets) magit make :lang cc data emacs-lisp latex markdown (org +dragndrop +ipython +pandoc +present) plantuml python scheme sh :app calendar :config (default +bindings +smartparens))
        packages   (n/a)
        unpin      (n/a)
        elpa       (n/a)

:core bug resolved

All 2 comments

@hlissner What's going on with this code?

                  (cond ((and end beg (= end (+ beg (length op) (length cl))))
                         (sp-backward-delete-char 1))

It seems to be duplicating the functionality that Smartparens already provides, which of course causes two parens to be deleted.

The workaround for now is:

(advice-remove #'delete-backward-char #'+default--delete-backward-char-a)

As of 2cedf15 this should be fixed.

What's going on with this code?

@raxod502 Up until fairly recently, smartparens surprisingly didn't do that (for pairs with length>1), but I suppose it was fixed upstream. Or deferred to change hooks instead.

Was this page helpful?
0 / 5 - 0 ratings