diff --git a/src/ChangeLog b/src/ChangeLog index 676d03cb59dc355a7abbb073e148390e832d12e4..3dbc1667c6c5ed6e2ec17e3f353d9895dc37859a 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 da8bdaeb948252211da9d1ba189e20663a07206e..b3eb8e54297733b6128126d0bf83c9b6d10f2805 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)