Skip to content

C-h does not ensure electric-pair deletes adjacent pairs #1974

Open
@jamescherti

Description

@jamescherti

When using electric-pair-mode, the expected behavior when pressing C-h near a pair of adjacent delimiters (e.g., () [] {} "") is that both the opening and closing delimiters should be deleted together if they were inserted as a pair.

Electric-pair achieves this by invoking a function bound to the DEL key (ASCII code 127) within electric-pair-mode-map:

electric-pair-mode-map is a variable defined in ‘elec-pair.el’.

Its value is
(keymap 
 (127 menu-item "" electric-pair-delete-pair :filter
  #f(compiled-function (cmd) #<bytecode 0x115035a9952592b3>)))

In Evil-mode, C-h deletes only the character before point because it calls evil-delete-backward-char-and-join instead of calling the same function as the DEL key.

Steps to reproduce

  1. Enable electric-pair-mode
  2. Ensure evil-want-C-h-delete is set to t and that evil-mode is enabled
  3. Insert a pair of delimiters such as ()
  4. Place point between the delimiters
  5. Press C-h

Expected behavior

Both delimiters should be deleted together, mirroring the behavior of DEL with electric-pair-mode.

Actual behavior

Only the character before point is deleted, leaving the unmatched delimiter behind.

Possible fix

Making C-h dynamically call the same function as the DEL key would not only resolve the issue with electric-pair-mode but also ensure consistent behavior across other modes that modify the default DEL key functionality.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions