From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kenichi Handa Newsgroups: gmane.emacs.devel,gmane.emacs.pretest.bugs Subject: Re: GNU Emacs 22.0.50 fails to find =?iso-8859-1?q?=E4?= in different ISO Latin encodings Date: Wed, 20 Sep 2006 16:10:32 +0900 Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") Content-Type: text/plain; charset=US-ASCII X-Trace: sea.gmane.org 1158736347 14838 80.91.229.2 (20 Sep 2006 07:12:27 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 20 Sep 2006 07:12:27 +0000 (UTC) Cc: Peter_Dyballa@web.de, emacs-devel@gnu.org, emacs-pretest-bug@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Sep 20 09:12:23 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GPwFn-0000Th-Sb for ged-emacs-devel@m.gmane.org; Wed, 20 Sep 2006 09:12:20 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GPwFn-0004VC-6w for ged-emacs-devel@m.gmane.org; Wed, 20 Sep 2006 03:12:19 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GPwFU-0004Sg-3P for emacs-devel@gnu.org; Wed, 20 Sep 2006 03:12:00 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GPwFS-0004Qh-1W for emacs-devel@gnu.org; Wed, 20 Sep 2006 03:11:59 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GPwFR-0004QG-MZ; Wed, 20 Sep 2006 03:11:57 -0400 Original-Received: from [150.29.246.133] (helo=mx1.aist.go.jp) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GPwIe-0006fC-Oh; Wed, 20 Sep 2006 03:15:17 -0400 Original-Received: from smtp4.aist.go.jp ([150.29.246.12]) by mx1.aist.go.jp with ESMTP id k8K7Bqtp010082; Wed, 20 Sep 2006 16:11:52 +0900 (JST) env-from (handa@m17n.org) Original-Received: by smtp4.aist.go.jp with ESMTP id k8K7Bkld009273; Wed, 20 Sep 2006 16:11:46 +0900 (JST) env-from (handa@m17n.org) Original-Received: from handa by etlken with local (Exim 3.36 #1 (Debian)) id 1GPwE4-0001Se-00; Wed, 20 Sep 2006 16:10:32 +0900 Original-To: rms@gnu.org In-reply-to: (message from Richard Stallman on Tue, 19 Sep 2006 18:57:22 -0400) User-Agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/22.0.50 (i686-pc-linux-gnu) MULE/5.0 (SAKAKI) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:60032 gmane.emacs.pretest.bugs:14016 Archived-At: In article , Richard Stallman writes: > A while ago, I proposed to change isearch so that it > translates characters by translation-table-for-input to > solve such a problem, but there raised an objection that > read-char should do that translation. RMS asked to check if > such a change to read-char is surely safe or not, but as > such a check is very difficult and time-consuiming, no one > took on the job. > So, this problem is still unfixed. > I again propose to change isearch. > Yes, let's do it that way. Could you do it now? Oops, it seems that my brain is seriously damaged :-(. I have already installed such a change (perhaps accoding to your decision). The problem is that the change took care only for a typed character. If isearch-string is set from a (possibly different) buffer (e.g. by C-s C-w), the translation doesn't happen. So, I've just installed the attached change. But, there still exists a case that isearch fails. For instance, if your buffer's buffer-file-coding-system is iso-8859-2, and you somehow insert a-acute of iso-8859-1, isearch won't be able to find that a-acute. The fix for that case is very difficult in Emacs 22. --- Kenichi Handa handa@m17n.org 2006-09-20 Kenichi Handa * isearch.el (isearch-process-search-char): Cancel the previous change. (isearch-search-string): New function. (isearch-search): Use isearch-search-string. (isearch-lazy-highlight-search): Likewise. Index: isearch.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/isearch.el,v retrieving revision 1.289 retrieving revision 1.290 diff -u -r1.289 -r1.290 --- isearch.el 9 Jul 2006 11:04:18 -0000 1.289 +++ isearch.el 20 Sep 2006 06:13:43 -0000 1.290 @@ -1807,8 +1807,6 @@ ((eq char ?|) (isearch-fallback t nil t))) ;; Append the char to the search string, update the message and re-search. - (if (char-table-p translation-table-for-input) - (setq char (or (aref translation-table-for-input char) char))) (isearch-process-search-string (char-to-string char) (if (>= char ?\200) @@ -1993,6 +1991,36 @@ (t (if isearch-forward 'search-forward 'search-backward))))) +(defun isearch-search-string (string bound noerror) + ;; Search for the first occurance of STRING or its translation. If + ;; found, move point to the end of the occurance, update + ;; isearch-match-beg and isearch-match-end, and return point. + (let ((func (isearch-search-fun)) + (len (length string)) + pos1 pos2) + (setq pos1 (save-excursion (funcall func string bound noerror))) + (if (and (char-table-p translation-table-for-input) + (> (string-bytes string) len)) + (let (translated match-data) + (dotimes (i len) + (let ((x (aref translation-table-for-input (aref string i)))) + (when x + (or translated (setq translated (copy-sequence string))) + (aset translated i x)))) + (when translated + (save-match-data + (save-excursion + (if (setq pos2 (funcall func translated bound noerror)) + (setq match-data (match-data t))))) + (when (and pos2 + (or (not pos1) + (if isearch-forward (< pos2 pos1) (> pos2 pos1)))) + (setq pos1 pos2) + (set-match-data match-data))))) + (if pos1 + (goto-char pos1)) + pos1)) + (defun isearch-search () ;; Do the search with the current search string. (isearch-message nil t) @@ -2008,9 +2036,7 @@ (setq isearch-error nil) (while retry (setq isearch-success - (funcall - (isearch-search-fun) - isearch-string nil t)) + (isearch-search-string isearch-string nil t)) ;; Clear RETRY unless we matched some invisible text ;; and we aren't supposed to do that. (if (or (eq search-invisible t) @@ -2353,7 +2379,7 @@ (isearch-regexp isearch-lazy-highlight-regexp) (search-spaces-regexp search-whitespace-regexp)) (condition-case nil - (funcall (isearch-search-fun) + (isearch-search-string isearch-lazy-highlight-last-string (if isearch-forward (min (or isearch-lazy-highlight-end-limit (point-max))