unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* weird bug with `Russian-computer'?
@ 2005-07-03 21:27 Paul Pogonyshev
  2005-07-04  0:03 ` Miles Bader
  2005-07-04  0:44 ` Juri Linkov
  0 siblings, 2 replies; 7+ messages in thread
From: Paul Pogonyshev @ 2005-07-03 21:27 UTC (permalink / raw)


With the `Russian-computer' input method, S-/ combination produces a comma
(instead of a question mark with standard English.)  That is OK and the
way it should be.  However, when I start incremental search, the key works
as in English, while the rest of the keyboard keeps producing Russian
letters etc.

To reproduce:

$ emacs -Q

C-x RET C-\ russian-computer RET
S-/	(note the comma)
C-s S-/ (note the question mark!)

I have a few months old CVS snapshot here.

Paul

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: weird bug with `Russian-computer'?
  2005-07-03 21:27 weird bug with `Russian-computer'? Paul Pogonyshev
@ 2005-07-04  0:03 ` Miles Bader
  2005-07-04  0:44 ` Juri Linkov
  1 sibling, 0 replies; 7+ messages in thread
From: Miles Bader @ 2005-07-04  0:03 UTC (permalink / raw)
  Cc: emacs-devel

2005/7/4, Paul Pogonyshev <pogonyshev@gmx.net>:
> With the `Russian-computer' input method, S-/ combination produces a comma
> However, when I start incremental search, the key works
> as in English, while the rest of the keyboard keeps producing Russian
> letters etc.
> 
> I have a few months old CVS snapshot here.

Hmmm seems to work correctly for me; you might try upgrading to the
latest CVS and see if it's fixed for you.

When I type C-s to isearch, the prompt looks like:  I-search [RU]:
Is this also true for you?

Thanks,

-Miles
-- 
Do not taunt Happy Fun Ball.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: weird bug with `Russian-computer'?
  2005-07-03 21:27 weird bug with `Russian-computer'? Paul Pogonyshev
  2005-07-04  0:03 ` Miles Bader
@ 2005-07-04  0:44 ` Juri Linkov
  2005-07-04 16:03   ` Paul Pogonyshev
  1 sibling, 1 reply; 7+ messages in thread
From: Juri Linkov @ 2005-07-04  0:44 UTC (permalink / raw)
  Cc: emacs-devel

> With the `Russian-computer' input method, S-/ combination produces a comma
> (instead of a question mark with standard English.)  That is OK and the
> way it should be.

Perhaps you have a US keyboard layout with `?' on the same key as `/'.
Finnish keyboards have quite a different layout where `?' is on the
same key as `+', and it is produced by `S-+'.  Other keyboards have
other layouts, but anyhow I understand how to reproduce the problem.
What is essential here is to press shift with the `?' key, because the
`russian-computer' input method maps `?' to `,'.

> However, when I start incremental search, the key works as in
> English, while the rest of the keyboard keeps producing Russian
> letters etc.

The root of the problem is in `isearch-mode-map' which binds `?' to
`isearch-*-char'.  When you type a key corresponding to `?' with
the input method, `isearch-*-char' intercepts it and interprets as
the regexp special character `?'.

The following patch fixes this problem by sending the input character
to `isearch-process-search-char' which takes care of processing the
character according to the current input method.  Also a new condition
was added before processing a regexp character.  If an input method is
active, it processes a regexp character only if a typed character is
the same with and without an input method, so that all input methods
that don't redefine regexp characters won't be affected.

Index: lisp/isearch.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/isearch.el,v
retrieving revision 1.263
diff -c -r1.263 isearch.el
*** lisp/isearch.el	23 Apr 2005 15:38:07 -0000	1.263
--- lisp/isearch.el	4 Jul 2005 00:35:07 -0000
***************
*** 1413,1420 ****
  If optional TO-BARRIER non-nil, ignore previous matches and go exactly to the
  barrier."
    ;; (eq (not a) (not b)) makes all non-nil values equivalent
!   (when (and isearch-regexp (eq (not (isearch-backslash isearch-string))
! 				(not want-backslash))
  	     ;; We have to check 2 stack frames because the last might be
  	     ;; invalid just because of a backslash.
  	     (or (not isearch-error)
--- 1423,1435 ----
  If optional TO-BARRIER non-nil, ignore previous matches and go exactly to the
  barrier."
    ;; (eq (not a) (not b)) makes all non-nil values equivalent
!   (when (and isearch-regexp
! 	     (or (not current-input-method)
! 		 (let ((qchar (quail-find-key last-command-char)))
! 		   (or (eq qchar t)
! 		       (equal (car-safe qchar) (string last-command-char)))))
! 	     (eq (not (isearch-backslash isearch-string))
! 		 (not want-backslash))
  	     ;; We have to check 2 stack frames because the last might be
  	     ;; invalid just because of a backslash.
  	     (or (not isearch-error)
***************
*** 1458,1464 ****
  			   (max last-other-end isearch-barrier)
  			 (min last-other-end isearch-barrier)))
  	    (setq isearch-adjusted t))))))
!   (isearch-process-search-char last-command-char))
  
  ;; * and ? are special when not preceded by \.
  (defun isearch-*-char ()
--- 1473,1479 ----
  			   (max last-other-end isearch-barrier)
  			 (min last-other-end isearch-barrier)))
  	    (setq isearch-adjusted t))))))
!   (isearch-printing-char))
  
  ;; * and ? are special when not preceded by \.
  (defun isearch-*-char ()

Index: lisp/international/isearch-x.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/international/isearch-x.el,v
retrieving revision 1.19
diff -c -r1.19 isearch-x.el
*** lisp/international/isearch-x.el	13 May 2005 06:03:45 -0000	1.19
--- lisp/international/isearch-x.el	4 Jul 2005 00:35:19 -0000
***************
*** 96,104 ****
  
  ;;;###autoload
  (defun isearch-process-search-multibyte-characters (last-char)
!   (if (eq this-command 'isearch-printing-char)
        (let ((overriding-terminal-local-map nil)
! 	    (prompt (concat (isearch-message-prefix)))
  	    (minibuffer-local-map isearch-minibuffer-local-map)
  	    str)
  	(if isearch-input-method-function
--- 96,105 ----
  
  ;;;###autoload
  (defun isearch-process-search-multibyte-characters (last-char)
!   (if (memq this-command '(isearch-printing-char
! 			   isearch-*-char isearch-}-char isearch-|-char))
        (let ((overriding-terminal-local-map nil)
! 	    (prompt (isearch-message-prefix))
  	    (minibuffer-local-map isearch-minibuffer-local-map)
  	    str)
  	(if isearch-input-method-function

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: weird bug with `Russian-computer'?
  2005-07-04  0:44 ` Juri Linkov
@ 2005-07-04 16:03   ` Paul Pogonyshev
  2005-07-05  5:27     ` Juri Linkov
  0 siblings, 1 reply; 7+ messages in thread
From: Paul Pogonyshev @ 2005-07-04 16:03 UTC (permalink / raw)
  Cc: emacs-devel

Juri Linkov wrote:
> > With the `Russian-computer' input method, S-/ combination produces a
> > comma (instead of a question mark with standard English.)  That is OK and
> > the way it should be.
>
> Perhaps you have a US keyboard layout with `?' on the same key as `/'.
> Finnish keyboards have quite a different layout where `?' is on the
> same key as `+', and it is produced by `S-+'.  Other keyboards have
> other layouts, but anyhow I understand how to reproduce the problem.
> What is essential here is to press shift with the `?' key, because the
> `russian-computer' input method maps `?' to `,'.

Yes, I use US and Russian keyboard layouts.

> > However, when I start incremental search, the key works as in
> > English, while the rest of the keyboard keeps producing Russian
> > letters etc.
>
> The root of the problem is in `isearch-mode-map' which binds `?' to
> `isearch-*-char'.  When you type a key corresponding to `?' with
> the input method, `isearch-*-char' intercepts it and interprets as
> the regexp special character `?'.
>
> The following patch fixes this problem by sending the input character
> to `isearch-process-search-char' which takes care of processing the
> character according to the current input method.  Also a new condition
> was added before processing a regexp character.  If an input method is
> active, it processes a regexp character only if a typed character is
> the same with and without an input method, so that all input methods
> that don't redefine regexp characters won't be affected.

Works for me, thanks.  However, why ``only if a typed character is the
same with and without an input method''?  Maybe it should just process
the character _after_ it has been processed/converted by the input method,
as opposed to processing it _before_, as currently.  So, S-7 in `russian-
computer' would trigger special '?' character processing.

(I don't know how input methods works in Emacs, though...)

Paul

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: weird bug with `Russian-computer'?
  2005-07-04 16:03   ` Paul Pogonyshev
@ 2005-07-05  5:27     ` Juri Linkov
  2005-07-11 21:47       ` Paul Pogonyshev
  0 siblings, 1 reply; 7+ messages in thread
From: Juri Linkov @ 2005-07-05  5:27 UTC (permalink / raw)
  Cc: emacs-devel

> Works for me, thanks.  However, why ``only if a typed character is the
> same with and without an input method''?  Maybe it should just process
> the character _after_ it has been processed/converted by the input method,
> as opposed to processing it _before_, as currently.  So, S-7 in `russian-
> computer' would trigger special '?' character processing.

This also means removing key bindings for `?', `*', `}', `|',
and hard-coding them.  But I think it is not a bad idea after all:
I can't imagine a user wanting to rebind these characters (for reasons
other than remapping them in the input method).

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: weird bug with `Russian-computer'?
  2005-07-05  5:27     ` Juri Linkov
@ 2005-07-11 21:47       ` Paul Pogonyshev
  2005-07-12  6:56         ` Juri Linkov
  0 siblings, 1 reply; 7+ messages in thread
From: Paul Pogonyshev @ 2005-07-11 21:47 UTC (permalink / raw)
  Cc: emacs-devel

Juri Linkov wrote:
> > Works for me, thanks.  However, why ``only if a typed character is the
> > same with and without an input method''?  Maybe it should just process
> > the character _after_ it has been processed/converted by the input
> > method, as opposed to processing it _before_, as currently.  So, S-7 in
> > `russian- computer' would trigger special '?' character processing.
>
> This also means removing key bindings for `?', `*', `}', `|',
> and hard-coding them.  But I think it is not a bad idea after all:
> I can't imagine a user wanting to rebind these characters (for reasons
> other than remapping them in the input method).

Any progress on this?  (Just bugging you around so that we don't leave
this out of the release accidentally; it might happen any other year, you
know.)

Paul

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: weird bug with `Russian-computer'?
  2005-07-11 21:47       ` Paul Pogonyshev
@ 2005-07-12  6:56         ` Juri Linkov
  0 siblings, 0 replies; 7+ messages in thread
From: Juri Linkov @ 2005-07-12  6:56 UTC (permalink / raw)
  Cc: emacs-devel

> Any progress on this?  (Just bugging you around so that we don't leave
> this out of the release accidentally; it might happen any other year, you
> know.)

Since nobody objected to removing key bindings for `?', `*', `}', `|',
below is a patch that changes isearch.el to process special regexp
characters after the input is completed and before putting characters
into the search string.

Index: lisp/isearch.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/isearch.el,v
retrieving revision 1.264
diff -c -r1.264 isearch.el
*** lisp/isearch.el	4 Jul 2005 23:08:56 -0000	1.264
--- lisp/isearch.el	12 Jul 2005 06:52:59 -0000
***************
*** 356,368 ****
      (define-key map "\M-\C-y" 'isearch-yank-char)
      (define-key map    "\C-y" 'isearch-yank-line)
  
-     ;; Define keys for regexp chars * ? } |.
-     ;; Nothing special for + because it matches at least once.
-     (define-key map "*" 'isearch-*-char)
-     (define-key map "?" 'isearch-*-char)
-     (define-key map "}" 'isearch-}-char)
-     (define-key map "|" 'isearch-|-char)
- 
      ;; Turned off because I find I expect to get the global definition--rms.
      ;; ;; Instead bind C-h to special help command for isearch-mode.
      ;; (define-key map "\C-h" 'isearch-mode-help)
--- 361,366 ----
***************
*** 1457,1482 ****
  	    (goto-char (if isearch-forward
  			   (max last-other-end isearch-barrier)
  			 (min last-other-end isearch-barrier)))
! 	    (setq isearch-adjusted t))))))
!   (isearch-process-search-char last-command-char))
! 
! ;; * and ? are special when not preceded by \.
! (defun isearch-*-char ()
!   "Maybe back up to handle * and ? specially in regexps."
!   (interactive)
!   (isearch-fallback nil))
! 
! ;; } is special when it is preceded by \.
! (defun isearch-}-char ()
!   "Handle \\} specially in regexps."
!   (interactive)
!   (isearch-fallback t t))
! 
! ;; | is special when it is preceded by \.
! (defun isearch-|-char ()
!   "If in regexp search, jump to the barrier unless in a group."
!   (interactive)
!   (isearch-fallback t nil t))
  
  (defun isearch-unread-key-sequence (keylist)
    "Unread the given key-sequence KEYLIST.
--- 1460,1466 ----
  	    (goto-char (if isearch-forward
  			   (max last-other-end isearch-barrier)
  			 (min last-other-end isearch-barrier)))
! 	    (setq isearch-adjusted t)))))))
  
  (defun isearch-unread-key-sequence (keylist)
    "Unread the given key-sequence KEYLIST.
***************
*** 1796,1801 ****
--- 1780,1793 ----
  	(isearch-process-search-char char)))))
  
  (defun isearch-process-search-char (char)
+   ;; * and ? are special in regexps when not preceded by \.
+   ;; } and | are special in regexps when preceded by \.
+   ;; Nothing special for + because it matches at least once.
+   (cond
+    ((memq char '(?* ??)) (isearch-fallback nil))
+    ((eq   char ?\})      (isearch-fallback t t))
+    ((eq   char ?|)       (isearch-fallback t nil t)))
+ 
    ;; Append the char to the search string, update the message and re-search.
    (isearch-process-search-string
     (char-to-string char)

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-07-12  6:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-03 21:27 weird bug with `Russian-computer'? Paul Pogonyshev
2005-07-04  0:03 ` Miles Bader
2005-07-04  0:44 ` Juri Linkov
2005-07-04 16:03   ` Paul Pogonyshev
2005-07-05  5:27     ` Juri Linkov
2005-07-11 21:47       ` Paul Pogonyshev
2005-07-12  6:56         ` Juri Linkov

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