all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#36006: electric-pair-mode fails to balance in certain cases
@ 2019-05-30 15:11 Dario Gjorgjevski
  2019-05-30 17:36 ` npostavs
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Dario Gjorgjevski @ 2019-05-30 15:11 UTC (permalink / raw)
  To: 36006

Consider the following text in html-mode with electric-pair-mode turned
on and electric-pair-skip-self set to electric-pair-default-skip-self:

         <|>

(Take | to denote point.)  In this situation, the expected result of
attempting to insert > is to skip over the one immediately after point,
i.e., end up with <>|.  However, what we get instead is <>|>.  Only if
we *now* attempt to insert >, we end up with <>>|, which doesn't make
any sense.

The same behavior is observed with ordinary parentheses in html-mode,
too.

From my debugging, the culprit seems to be an unnecessary (or mistaken?)
use of electric-pair--with-uncached-syntax.  I am not sure *why* exactly
it happens, and would appreciate further insight.

The patch shown below fixes the issue.

diff --git a/lisp/elec-pair.el b/lisp/elec-pair.el
index 5fb9d751e2..6450d02c9e 100644
--- a/lisp/elec-pair.el
+++ b/lisp/elec-pair.el
@@ -325,11 +325,9 @@ electric-pair--balance-info
                         (cond ((< direction 0)
                                (condition-case nil
                                    (eq (char-after pos)
-                                       (electric-pair--with-uncached-syntax
-                                           (table)
-                                         (matching-paren
-                                          (char-before
-                                           (scan-sexps (point) 1)))))
+                                       (matching-paren
+                                        (char-before
+                                         (scan-sexps (point) 1))))
                                  (scan-error nil)))
                               (t
                                ;; In this case, no need to use

-- 
Dario Gjorgjevski :: <dario.gjorgjevski@gmail.com>
                  :: 744A 4F0B 4F1C 9371
                  :: +48 1525 8666837





^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-02-10  7:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-30 15:11 bug#36006: electric-pair-mode fails to balance in certain cases Dario Gjorgjevski
2019-05-30 17:36 ` npostavs
2019-05-30 21:51   ` Dario Gjorgjevski
2019-06-06 23:39     ` Noam Postavsky
2019-11-22 12:28 ` Dario Gjorgjevski
2020-08-27 19:08 ` Gregory Heytings via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-08-27 21:38   ` Gregory Heytings via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-08-28  8:00     ` Gregory Heytings via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-10  7:50       ` Lars Ingebrigtsen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.