all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Ulrich Mueller <ulm@gentoo.org>
Cc: emacs-devel@gnu.org
Subject: Re: Subsets of Unicode and coding systems
Date: Tue, 06 Dec 2011 07:08:49 -0500	[thread overview]
Message-ID: <E1RXtpJ-0002MS-Ax@fencepost.gnu.org> (raw)
In-Reply-To: <20189.65233.636624.766245@a1i15.kph.uni-mainz.de> (message from Ulrich Mueller on Tue, 6 Dec 2011 12:38:57 +0100)

> Date: Tue, 6 Dec 2011 12:38:57 +0100
> From: Ulrich Mueller <ulm@gentoo.org>
> 
> Sometimes I want to check if a file saved in UTF-8 encoding contains
> only characters from a certain subset of the Unicode character
> repertoire, like the MES-* [1] or WGL4 [2] subsets. (For example, for
> things published on the WWW one might rather avoid exotic characters
> for better compatibility.)
> 
> My idea was now to define a coding system e.g. for MES-2 and set the
> buffer-file-coding-system accordingly, so that Emacs would check it
> upon saving the file.
> 
> Now I have the following questions:
> 1. Is using coding systems for this purpose a reasonable approach
>    at all, or is there a better way to achieve this?

I don't think defining a new coding-system is the best way to go about
this.  I would suggest to define a new category instead, see
"(elisp)Categories" (which includes a working example), and then make
a category table (which is just a special type of char-table) where
the relevant characters are marked with the appropriate categories.
Then you can simply scan the buffer with a regexp that uses "\\Cx"
where "x" is the letter you assign to your category.  (You will
probably need a separate letter for each of the MES-* and WGL4 sets.)

> 2. Where can I find documentation how to define a coding system?

You don't want to know that ;-)



  reply	other threads:[~2011-12-06 12:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-06 11:38 Subsets of Unicode and coding systems Ulrich Mueller
2011-12-06 12:08 ` Eli Zaretskii [this message]
2011-12-06 12:24   ` Werner LEMBERG
  -- strict thread matches above, loose matches on Subject: below --
2011-12-08  4:16 Kenichi Handa

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=E1RXtpJ-0002MS-Ax@fencepost.gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=ulm@gentoo.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.