emacs-bidi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [emacs-bidi] reordering based on implicit levels


From: Alex Schroeder
Subject: Re: [emacs-bidi] reordering based on implicit levels
Date: Tue, 13 Nov 2001 12:29:10 +0100
User-agent: Gnus/5.090004 (Oort Gnus v0.04) Emacs/21.1 (i686-pc-linux-gnu)

"Eli Zaretskii" <address@hidden> writes:

> Here's one important difference between the two conversions.  The
> logical to visual conversion needs to decide, one way or the other,
> what is the paragraph base direction.  By contrast, for a visual
> text, this is almost always known in advance by the calling
> application.  So it doesn't make much sense, IMHO, to invoke the
> visual-to-logical conversion asking it to guess the direction.  It
> also seems wrong to guess the direction by looking at the leftmost
> characters, as I think you do: in the visual order, the leftmost
> character is not necessarily the first character of the text.  To
> know what is the first character of the text, you need to know the
> paragraph direction ;-)

You are right.  Here's the declarations of the new wrapper functions.
Note how sometimes the context is required.  I hope that using them
will in fact help.

Alex.


;;;###autoload
(defun bidi-visual-to-logical (str context)
  "Reorder STR line by line.
See `bidi-reorder' for a description of CONTEXT."
  ;; This is just a wrapper.  It doesn't make sense to guess context
  ;; based on the first character, so all this wrapper does is make
  ;; direction (visual to logical) and context (argument required)
  ;; explicit.
)

;;;###autoload
(defun bidi-logical-to-visual (str &optional context)
  "Reorder STR line by line.
See `bidi-reorder' for a description of CONTEXT."
  ;; This is just a wrapper.  It makes sense to guess context based on
  ;; the first character, if STR is at the beginning of a paragraph.
  ;; Otherwise, it makes sense to provide CONTEXT.  So all this wrapper
  ;; does is make direction (logical to visual) explicit.
)

;;;###autoload
(defun bidi-reorder-region (start end &optional context)
  "Reorder the region between START and END.
See `bidi-reorder' for a description of CONTEXT."
  (interactive "r")
)

;;;###autoload
(defun bidi-visual-to-logical-paragraph (context)
  "Reorder the current paragraph.
See `bidi-reorder' for a description of CONTEXT."
  ;; This is just a wrapper.  It doesn't make sense to guess context
  ;; based on the first character, so all this wrapper does is make
  ;; direction (visual to logical) and context (argument required)
  ;; explicit.
  (interactive (let ((answer (completing-read
                              "Context: "
                              '(("left-to-right") 
                                ("right-to-left")))))
                 (if (eq (intern answer) 'left-to-right)
                     '(L2R)
                   '(R2L))))
)

;;;###autoload
(defun bidi-logical-to-visual-paragraph ()
  "Reorder the current paragraph."
  ;; This is just a wrapper.  Since we start with a new paragraph, the
  ;; context is guessed based on the first strong character.  So all
  ;; this wrapper does is make direction (logical to visual) explicit,
  ;; and it forces a guess.
  (interactive)
)

-- 
http://www.emacswiki.org/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]