From 4ab6ce3bb26965c69c6d8173cf4a94afb8ce8145 Mon Sep 17 00:00:00 2001 From: Per Cederqvist <ceder@lysator.liu.se> Date: Fri, 4 Sep 2020 10:52:11 +0200 Subject: [PATCH] Isolate bidi directionality changes to a single text. * view-text.el (lyskom-print-text): Insert a paragraph separator if the bidi directionality was changed by the text. --- src/ChangeLog | 6 ++++++ src/view-text.el | 20 +++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index 676d03cb..3dbc1667 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2020-09-04 Per Cederqvist <ceder@lysator.liu.se> + + Isolate bidi directionality changes to a single text. + * view-text.el (lyskom-print-text): Insert a paragraph separator + if the bidi directionality was changed by the text. + 2020-08-17 Per Cederqvist <ceder@lysator.liu.se> Emacs 27.1 compatibility. diff --git a/src/view-text.el b/src/view-text.el index da8bdaeb..b3eb8e54 100644 --- a/src/view-text.el +++ b/src/view-text.el @@ -882,7 +882,8 @@ Mark the text as read if (and only if) MARK-AS-READ is non-nil. Args: TEXT-STAT TEXT MARK-AS-READ TEXT-NO FLAT-REVIEW." (let* ((lyskom-current-function 'lyskom-print-text) (cti (lyskom-get-aux-item (text-stat->aux-items text-stat) 1)) - (content-type (and cti (aux-item->data (car cti))))) + (content-type (and cti (aux-item->data (car cti)))) + (bidi-at-start (current-bidi-paragraph-direction))) (cond ((or (null text) (null text-stat)) @@ -1011,6 +1012,23 @@ Args: TEXT-STAT TEXT MARK-AS-READ TEXT-NO FLAT-REVIEW." (when kom-highlight-dashed-lines `(face ,(or kom-dashed-lines-face lyskom-default-dashed-lines-face))))))) + + ;; If the last paragraph of the text has a different bidi + ;; direction than the default bidi direction in this buffer, + ;; insert a newline so that the rest of the buffer will get + ;; its direction from the prompt. + ;; + ;; Perhaps it would be more correct to always insert a newline + ;; before the text and after the text, so that the text always + ;; has a bidi direction that is independent from the bidi + ;; direction of the prompts, headers and footers, but that + ;; would be too large a departure from the classical layout of + ;; a LysKOM buffer. If there were an invisible way to specify + ;; a paragraph break at those positions, that would be nice. + ;; For now, we live with this workaround. + (unless (eq (current-bidi-paragraph-direction) bidi-at-start) + (insert "\n")) + (if mark-as-read (lyskom-mark-as-read text-stat)) (setq lyskom-previous-text lyskom-current-text) -- GitLab