Description
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
- Enable
electric-pair-mode
- Ensure evil-want-C-h-delete is set to t and that evil-mode is enabled
- Insert a pair of delimiters such as
()
- Place point between the delimiters
- 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.