unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Kenichi Handa <handa@etl.go.jp>
Cc: spiegel@gnu.org, savannah-hackers@gnu.org, emacs-devel@gnu.org
Subject: Re: Several serious problems
Date: Tue, 23 Jul 2002 22:35:46 +0900 (JST)	[thread overview]
Message-ID: <200207231335.WAA25692@etlken.m17n.org> (raw)
In-Reply-To: <200207221711.g6MHBZo02496@aztec.santafe.edu> (message from Richard Stallman on Mon, 22 Jul 2002 11:11:35 -0600 (MDT))

In article <200207221711.g6MHBZo02496@aztec.santafe.edu>, Richard Stallman <rms@gnu.org> writes:

> I cannot save the file lisp/ChangeLog.  It specifies coding system
> iso-2022-7bit, but it contains something that cannot be encoded in that
> coding system.  

It seem that this problem was already fixed.  As I also
found one unnecessary mule-unicode-0100-24ff char, I deleted
it.

> I don't know any way to find the text that causes the
> problem; essentially I am helpless.

At least, (find-charset-region 1 (point-max)) will give you
some information.  If the returned value contains a
suspicious charset, we can search it (if it's not
eight-bit-xxx) by:
	(re-search-forward "[%c-%c]"
			   (make-char CHARSET 32 32) 
			   (make-char CHARSET 127 127))
To search for eight-bit-control:
	(re-search-forward "[\200-\237]")
To search for eight-bit-graphic:
	(re-search-forward (string-as-multibyte "[\240-\377]"))
It's not sophisticated.  :-(

> We MUST do something to make it easier for users to cope with such a
> situation.  We talked about this a few weeks ago but nothing was done.
> Perhaps we could add a command which simply scans forward for the next
> run of characters that can't be saved in the specified coding system.
> The message you get in that situation could tell you about this
> command.  This would be a powerful solution, since you could easily
> find all the problems, not just the first one.  Highlighting all of
> them would also be a useful thing to do.

Do you mean a command something like this?

(defun check-coding-system-region (from to coding-system &optional max-num)
  "Check if the text after point is encodable by the specified coding system.
When called from a program, takes three arguments:
CODING-SYSTEM, FROM, and TO.  START and END are buffer positions.
Value is a list of positions of characters that are not encodable by
CODING-SYSTEM.
Optional 4th argument MAX-NUM, if non-nil, limits the length of
returned list.  By default, there's no limit."
  (interactive (list (point)
		     (point-max)
		     (read-non-nil-coding-system "Coding-system: ")
		     1))
  (check-coding-system coding-system)
  (or (and coding-system
	   (integerp (coding-system-type coding-system)))
      (error "Invalid coding system to check: %s" coding-system))
  (let ((safe-chars (coding-system-get coding-system 'safe-chars))
	(positions)
	(n 0))
    (save-excursion
      (save-restriction
	(narrow-to-region from to)
	(goto-char (point-min))
	(or max-num
	    (setq max-num (- (point-max) (point-min))))
	(if (eq safe-chars t)
	    (let ((re (string-as-multibyte "[\200-\237\240-\377]")))
	      (while (and (< n max-num) (re-search-forward re nil t))
		(setq positions (cons (1- (point)) positions)
		      n (1+ n))))
	  (while (and (< n max-num) (re-search-forward "[^\000-\177]" nil t))
	    (or (aref safe-chars (preceding-char))
		(setq positions (cons (1- (point)) positions)
		      n (1+ n)))))))
    (if (interactive-p)
	(if (not positions)
	    (message "All characters are encodable by %s" coding-system)
	  (goto-char (car positions))
	  (error "This character can't be encoded by %s" coding-system))
      (setq positions (nreverse positions)))))

---
Ken'ichi HANDA
handa@etl.go.jp

  parent reply	other threads:[~2002-07-23 13:35 UTC|newest]

Thread overview: 90+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-22 17:11 Several serious problems Richard Stallman
2002-07-22 19:01 ` Andre Spiegel
2002-07-22 19:03 ` Andre Spiegel
2002-07-23  4:00   ` Richard Stallman
2002-07-22 19:03 ` Andreas Schwab
2002-07-23 18:58   ` Richard Stallman
2002-07-22 19:11 ` Andre Spiegel
2002-07-23  4:42 ` Karl Eichwalder
2002-07-24  3:25   ` Richard Stallman
2002-07-24  4:43     ` Karl Eichwalder
2002-07-25  3:12       ` Richard Stallman
2002-07-25  3:24         ` Karl Eichwalder
2002-07-26 15:35           ` Richard Stallman
2002-07-27  3:19             ` Karl Eichwalder
2002-07-29  1:12               ` Richard Stallman
2002-07-29 14:32                 ` Karl Eichwalder
2002-07-30  1:00                   ` Richard Stallman
2002-08-09  7:42               ` Stefan Monnier
2002-08-09 16:08                 ` Karl Eichwalder
2002-08-10 17:16                 ` Richard Stallman
2002-08-12 16:20                   ` Stefan Monnier
2002-08-13  1:48                     ` Richard Stallman
2002-08-15  2:30                       ` Karl Eichwalder
2002-08-15  2:47                         ` Stefan Monnier
2002-08-15  5:31                           ` Karl Eichwalder
2002-08-15 15:30                             ` Stefan Monnier
2002-08-15 17:33                               ` Dave Love
2002-07-23 13:35 ` Kenichi Handa [this message]
2002-07-23 13:52   ` Alan Shutko
2002-07-24  3:25     ` Richard Stallman
2002-07-24  3:25   ` Richard Stallman
2002-07-24  4:37     ` Kenichi Handa
2002-07-25  3:12       ` Richard Stallman
2002-07-25  5:53         ` Miles Bader
2002-07-26 14:29         ` Francesco Potorti`
2002-07-27 18:52           ` Richard Stallman
2002-08-09  7:43           ` Stefan Monnier
2002-08-11  1:59         ` unencodable-char-position [Re: Several serious problems] Kenichi Handa
2002-08-12 17:06           ` Richard Stallman
2002-08-12 17:15             ` Stefan Monnier
2002-08-13  0:37               ` Kenichi Handa
2002-08-13 22:47                 ` Richard Stallman
2002-08-14  0:20                   ` Kenichi Handa
2002-08-14 23:13                     ` Richard Stallman
2002-08-15 17:51           ` Dave Love
2002-08-19  5:04             ` Kenichi Handa
2002-08-29 22:52               ` Dave Love
2002-08-30  6:53                 ` Andre Spiegel
2002-08-09  7:44       ` Several serious problems Stefan Monnier
2002-08-10 17:16         ` Richard Stallman
2002-08-12  0:26         ` Kenichi Handa
2002-08-09  4:41 ` Stefan Monnier
2002-08-15 17:23   ` Dave Love
  -- strict thread matches above, loose matches on Subject: below --
2002-08-19  7:48 Kenichi Handa
2002-08-22 17:08 ` Dave Love
2002-08-29 13:25   ` Kenichi Handa
2002-08-29 17:32     ` Stefan Monnier
2002-08-29 23:15       ` Dave Love
2002-08-30 14:36         ` Stefan Monnier
2002-09-04 17:23           ` Dave Love
2002-08-30  6:09       ` Richard Stallman
2002-08-31 17:30         ` Dave Love
2002-09-02  0:01           ` Richard Stallman
2002-09-04 17:15             ` Dave Love
2002-09-08 12:54               ` Richard Stallman
2002-09-12 22:38                 ` Dave Love
2002-09-13 19:34                   ` Richard Stallman
2002-08-29 23:09     ` Dave Love
2002-08-30  6:11       ` Richard Stallman
2002-09-04 17:21         ` Dave Love
2002-08-29 23:17     ` Dave Love
2002-08-30  6:11       ` Richard Stallman
2002-08-31 17:31         ` Dave Love
2002-09-02  0:01           ` Richard Stallman
2002-09-02  1:28             ` Kenichi Handa
2002-09-05 13:41               ` Dave Love
2002-09-05 23:32                 ` Kenichi Handa
2002-09-06 11:38                   ` Robert J. Chassell
2002-09-07 23:19                   ` Dave Love
2002-09-09  0:21                     ` Richard Stallman
2002-09-12 22:43                       ` Dave Love
2002-09-26  4:51                     ` Kenichi Handa
2002-09-10 16:36               ` Richard Stallman
2002-08-30  6:09     ` Richard Stallman
2002-08-24 12:11 ` Richard Stallman
2002-08-26 13:17   ` Kenichi Handa
2002-08-26 16:15     ` Stefan Monnier
2002-08-29 23:18       ` Dave Love
2002-08-30 14:36         ` Stefan Monnier
2002-08-29 23:19     ` Dave Love

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=200207231335.WAA25692@etlken.m17n.org \
    --to=handa@etl.go.jp \
    --cc=emacs-devel@gnu.org \
    --cc=savannah-hackers@gnu.org \
    --cc=spiegel@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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).