From 5629af9cbe91feee8fb4d896224ed62e455f951d Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 28 Nov 2019 17:00:33 +0200 Subject: [PATCH] Allow disabling the BPA part of bidi reordering * src/xdisp.c (syms_of_xdisp): New variable 'bidi-inhibit-bpa'. * src/bidi.c (bidi_paired_bracket_type): If 'bidi-inhibit-bpa' is non-nil, return BIDI_BRACKET_NONE for all characters. * lisp/frame.el: Add 'bidi-inhibit-bpa' to the list of variables whose changes require redisplay. (Bug#38407) --- lisp/frame.el | 3 ++- src/bidi.c | 2 +- src/xdisp.c | 8 ++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lisp/frame.el b/lisp/frame.el index 1a15a4c9f26..1d1dcab580d 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -2736,7 +2736,8 @@ See also `toggle-frame-maximized'." display-fill-column-indicator-column display-fill-column-indicator-character bidi-paragraph-direction - bidi-display-reordering)) + bidi-display-reordering + bidi-inhibit-bpa)) (provide 'frame) diff --git a/src/bidi.c b/src/bidi.c index 1430d223313..cb94c4e0d7a 100644 --- a/src/bidi.c +++ b/src/bidi.c @@ -404,7 +404,7 @@ bidi_mirror_char (int c) static bidi_bracket_type_t bidi_paired_bracket_type (int c) { - if (c == BIDI_EOB) + if (c == BIDI_EOB || bidi_inhibit_bpa) return BIDI_BRACKET_NONE; if (c < 0 || c > MAX_CHAR) emacs_abort (); diff --git a/src/xdisp.c b/src/xdisp.c index c4d23be4cde..2467b336f4a 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -34839,6 +34839,14 @@ Intended for use during debugging and for testing bidi display; see biditest.el in the test suite. */); inhibit_bidi_mirroring = false; + DEFVAR_BOOL ("bidi-inhibit-bpa", bidi_inhibit_bpa, + doc: /* Non-nil means inhibit the Bidirectional Parentheses Algorithm. +Disabling the BPA makes redisplay faster, but might produce incorrect +display reordering of bidirectional text with embedded parentheses and +other bracket characters whose 'paired-bracket' Unicode property is +non-nil, see `get-char-code-property'. */); + bidi_inhibit_bpa = false; + #ifdef GLYPH_DEBUG DEFVAR_BOOL ("inhibit-try-window-id", inhibit_try_window_id, doc: /* Inhibit try_window_id display optimization. */); -- 2.39.2