unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Kenichi Handa <handa@m17n.org>
Cc: Peter_Dyballa@web.de, emacs-devel@gnu.org, emacs-pretest-bug@gnu.org
Subject: Re: GNU Emacs 22.0.50 fails to find ä in different ISO Latin encodings
Date: Wed, 20 Sep 2006 16:10:32 +0900	[thread overview]
Message-ID: <E1GPwE4-0001Se-00@etlken> (raw)
In-Reply-To: <E1GPoWo-0007PL-Pd@fencepost.gnu.org> (message from Richard Stallman on Tue, 19 Sep 2006 18:57:22 -0400)

In article <E1GPoWo-0007PL-Pd@fencepost.gnu.org>, Richard Stallman <rms@gnu.org> 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  <handa@m17n.org>

	* 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))

  reply	other threads:[~2006-09-20  7:10 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <F021B5CA-A186-4AFB-B650-520DBB6261C4@Web.DE>
2006-09-19  3:58 ` GNU Emacs 22.0.50 fails to find ä in different ISO Latin encodings Kenichi Handa
2006-09-19  6:43   ` David Kastrup
2006-09-19 22:57   ` Richard Stallman
2006-09-20  7:10     ` Kenichi Handa [this message]
2006-09-20  7:43       ` Peter Dyballa
2006-09-20  8:05         ` Kenichi Handa
2006-09-20 11:17           ` Peter Dyballa
2006-09-21  2:13             ` Kenichi Handa
2006-09-21  8:09               ` Peter Dyballa
2006-09-21 23:22               ` Peter Dyballa
2006-09-22  0:44                 ` Miles Bader
2006-09-22  9:06                   ` Peter Dyballa
2006-09-22 10:31                     ` Miles Bader
2006-09-22 10:55                       ` Peter Dyballa
2006-09-22 11:27                         ` Miles Bader
2006-09-22 22:54                           ` Peter Dyballa
2006-09-22 23:25                             ` Miles Bader
2006-09-23  8:45                               ` Peter Dyballa
2006-09-24  1:51                                 ` Miles Bader
2006-09-23  3:34                           ` Richard Stallman
2006-09-23  5:18                             ` Miles Bader
2006-09-24  2:10                               ` Richard Stallman
2006-09-22  1:06                 ` Kenichi Handa
2006-09-22  9:32                   ` Peter Dyballa
2006-09-21 17:20       ` Richard Stallman

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=E1GPwE4-0001Se-00@etlken \
    --to=handa@m17n.org \
    --cc=Peter_Dyballa@web.de \
    --cc=emacs-devel@gnu.org \
    --cc=emacs-pretest-bug@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).