2

I use Emacs with various languages and have had trouble invoking isearch-forward from a keystroke when my keyboard layout (OS-level) is set to Greek. If I try the usual C-s, it says there is no binding for C-σ (since the 's' key is now the 'σ' key). I tried setting up a new key binding using global-set-key, switching to Greek, typing C-σ, switching back to English, and then indicating isearch-forward. This works fine for the first search, but I want to be able to hit C-σ again to search for the next occurrence, the way it works with C-s when my keyboard layout is set to English. But this doesn't work. Instead, it prompts me for a new search string. How can I set it up so that C-σ works exactly like C-s, so that I can hit C-σ again to advance to the next occurrence of my (Greek) search string? Of course I also want to do the same thing with C-ρ for isearch-backward.

Drew
  • 75,699
  • 9
  • 109
  • 225
user1951615
  • 123
  • 2

1 Answers1

1

Try binding keys also in isearch-mode-map. These keys are among those bound there by default, for example:

C-r    isearch-repeat-backward
C-s    isearch-repeat-forward
C-M-r  isearch-repeat-backward
C-M-s  isearch-repeat-forward
M-r    isearch-toggle-regexp
M-s r  isearch-toggle-regexp

For example:

(define-key isearch-mode-map (kbd "C-s") 'isearch-repeat-forward)

Instead of (kbd "C-s") you would substitute whatever key you also bound globally for Isearch.


You can see all of the isearch-mode-map key bindings if you load library help-fns+.el. Just use C-h M-k isearch-mode-map.

Drew
  • 75,699
  • 9
  • 109
  • 225
  • I tried loading the library as suggested, but got a "Cannot open load file no such file or directory" This emacs instance was complied locally from emacs-27.1.tar.gz. I tried with the version from the repository (this is Ubuntu 20.10), emacs 26.3, and got the same error. The file (neither .el nor .elc) is not in the lisp directory of either version. . – user1951615 Mar 24 '21 at 13:19
  • However... I just tried putting both of the global-set-key assignments, in addition to what you suggested, into my .emacs and it appears to have solved the problem. Thank you. – user1951615 Mar 24 '21 at 13:38
  • Yes, that's why I wrote "binding keys *also* in...". If this answers your question, and you don't get a better answer, consider accepting it. Questions with accepted answers are more helpful to others. – Drew Mar 24 '21 at 15:39
  • How do I do that (accept the answer)? – user1951615 Mar 24 '21 at 21:30
  • https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work – Drew Mar 24 '21 at 23:46