Function: textsec-bidi-controls-suspicious-p

textsec-bidi-controls-suspicious-p is a byte-compiled function defined in textsec.el.gz.

Signature

(textsec-bidi-controls-suspicious-p STRING)

Documentation

Return non-nil of STRING uses bidi controls in suspicious ways.

If STRING doesn't include any suspicious uses of bidirectional formatting control characters, return nil. Otherwise, return the index of the first character in STRING affected by such suspicious use of bidi controls. If the returned value is beyond the length of STRING, it means any text following STRING on display might be affected by bidi controls in STRING.

Source Code

;; Defined in /usr/src/emacs/lisp/international/textsec.el.gz
(defun textsec-bidi-controls-suspicious-p (string)
  "Return non-nil of STRING uses bidi controls in suspicious ways.
If STRING doesn't include any suspicious uses of bidirectional
formatting control characters, return nil.  Otherwise, return the
index of the first character in STRING affected by such suspicious
use of bidi controls.  If the returned value is beyond the length
of STRING, it means any text following STRING on display might be
affected by bidi controls in STRING."
  (with-temp-buffer
    ;; We add a string that's representative of some text that could
    ;; follow STRING, with the purpose of detecting residual bidi
    ;; state at end of STRING which could then affect the following
    ;; text.
    (insert string "a1א:!")
    (let ((pos (bidi-find-overridden-directionality 1 (point-max) nil)))
      (and (fixnump pos)
           (1- pos)))))