all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kenichi Handa <handa@m17n.org>
To: ehud@unix.mvs.co.il
Cc: eliz@gnu.org, emacs-devel@gnu.org
Subject: Re: Usage of standard-display-table in MSDOS
Date: Thu, 09 Sep 2010 20:57:27 +0900	[thread overview]
Message-ID: <tl7eid3nn88.fsf@m17n.org> (raw)
In-Reply-To: <201009072111.o87LBeU2009811@beta.mvs.co.il> (ehud@unix.mvs.co.il)

In article <201009072111.o87LBeU2009811@beta.mvs.co.il>, "Ehud Karni" <ehud@unix.mvs.co.il> writes:

> > If you don't like it, you must give up decoding bytes
> > #x80..#x9A into Hebrew chars.  You decode them as raw-bytes,
> > and setup a display table to display them as Hebrew chars.
> > It can be done by this code:

> I think I solved this by using text properties.

Ah, ummm, a kind of dirty hack, but, perhaps it's
unavoidable in your situation.

> It is still unfinished, but it works, and I'll appreciate any comments.
> There are some problems, see at the end.

> Here is what I did (based on your advice).


> (define-charset 'hebrew-MSDOS-binary
>   "Hebrew subset of CP862 (#x80-#x9A) with no-conversion"
>   :code-space [#x80 #x9A]
>   :map (let ((map (make-vector 54 0))
>              (ix 27))
>          (while (> ix 0)
> 	   (setq ix (1- ix))
>            (aset map (+ ix ix)   (+ #x80 ix))
>            (aset map (+ ix ix 1) (+ #x80 ix)))
>          map)
>   :supplementary-p t)

For that, you don't have to use :map but can use
:code-offset as this:

(define-charset 'hebrew-MSDOS-binary
  "Hebrew subset of CP862 (#x80-#x9A) with no-conversion"
  :code-space [#x80 #x9A]
  :code-offset #x80
  :supplementary-p t)

> (defun hebrew-iso-with-8bit-pre-write (start end)
>        (let* ((text (if (numberp start)
>                       (buffer-substring start end)
>                       start))
>               (beg 0)
>               (end (length text))
>               va)
>            (while (setq beg (text-property-any beg end 'Hebrew 'DOS text))
>                (setq va (aref text beg))
>                (and (>= va #x05D0)                 ;; א
>                     (<= va #x05EA)                 ;; ת
>                     (aset text beg (- va #x550)))
>                (setq beg (1+ beg)))
>            (set-buffer (get-buffer-create " *heb-wrt*"))
>            (delete-region (point-min) (point-max))
>            (insert text)
>            nil))

You don't have to make a working buffer.  You can directly
modify the current buffer because it's already a working
buffer managed by Emacs itself.

> There are some Problems:

> 1. (describe-character-set 'hebrew-MSDOS-binary) exit with error:
>    Wrong type argument: char-or-string-p, [128 128 129 129 130 130 131 131 132 132 ...]
>    The vector is the :map value.

Ah, I'll fix it soon.

> 2. The `:post-read-conversion' function must return a number otherwise there is an error.
>    There is nothing about it in `define-coding-system' documentation.

I'm going to fix the docstring as this.

`:post-read-conversion'

VALUE must be a function to call after some text is inserted and
decoded by the coding system itself and before any functions in
`after-insert-functions' are called.  This function is passed one
argument; the number of characters in the text to convert, with
point at the start of the text.  The function should leave point
the same, and return the new character count.


> 3. The documentation for `write-region-annotate-functions' has:
>     "The function should return a list of pairs of the form (POSITION . STRING),
>     consisting of strings to be effectively inserted at the specified positions
>     of the file being written (1 means to insert before the first byte written).
>     The POSITIONs must be sorted into increasing order."
>   This did not work at all. I had to use the alternate pathway:
>     An annotation function can return with a different buffer current.
>     Doing so removes the annotations returned by previous functions, and
>     resets START and END to `point-min' and `point-max' of the new buffer.

For this part, I'm going to fix as this:

`:pre-write-conversion'

VALUE must be a function to call after all functions in
`write-region-annotate-functions' and `buffer-file-format' are
called, and before the text is encoded by the coding system
itself.  This function should convert the whole text in the
current buffer.  For backward compatibility, this funciton is
passed two arguments which can be ignored.

---
Kenichi Handa
handa@m17n.org



      reply	other threads:[~2010-09-09 11:57 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-23 12:44 Usage of standard-display-table in MSDOS Kenichi Handa
2010-08-24  5:34 ` Stephen J. Turnbull
2010-08-24 11:13   ` Ehud Karni
2010-08-24 16:51     ` Eli Zaretskii
2010-08-25 13:04       ` Ehud Karni
2010-08-25 18:09         ` Eli Zaretskii
2010-08-26 15:26           ` Ehud Karni
2010-08-26 16:43             ` Eli Zaretskii
2010-08-27 13:35               ` Ehud Karni
2010-08-27 16:30                 ` Eli Zaretskii
2010-08-27 10:24 ` Eli Zaretskii
2010-08-27 11:44   ` Kenichi Handa
2010-08-27 14:13     ` Eli Zaretskii
2010-08-28  4:18       ` Kenichi Handa
2010-08-28  7:22         ` Eli Zaretskii
2010-08-30  2:24           ` Kenichi Handa
2010-08-30  3:02             ` Eli Zaretskii
2010-09-01  3:21             ` Kenichi Handa
2010-09-01  9:20               ` Ehud Karni
2010-09-01 23:33               ` Ehud Karni
2010-09-02  5:19                 ` Eli Zaretskii
2010-09-02  5:20                 ` Kenichi Handa
2010-09-04 22:54                   ` Ehud Karni
2010-09-06  1:30                     ` Kenichi Handa
2010-09-02 12:32                 ` Kenichi Handa
2010-09-04 23:32                   ` Ehud Karni
2010-09-05  5:30                     ` Eli Zaretskii
2010-09-06  5:14                     ` Kenichi Handa
2010-08-29 10:16         ` Ehud Karni
2010-08-29 11:21           ` Eli Zaretskii
2010-08-29 11:49             ` Ehud Karni
2010-08-29 13:06               ` Ehud Karni
2010-08-29 13:50                 ` Eli Zaretskii
2010-08-29 14:04               ` Eli Zaretskii
2010-09-07 21:11                 ` Ehud Karni
2010-09-09 11:57                   ` Kenichi Handa [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tl7eid3nn88.fsf@m17n.org \
    --to=handa@m17n.org \
    --cc=ehud@unix.mvs.co.il \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.