6

Does emacs have an incremental search mode, where searching for a character will search for itself and for any other versions of the character with accent marks, similar to how Google Chrome (at least v27) will do when searching in a page?

Alternatively, is there an additional library or piece of elisp code that can put incremental search in such a mode?

For example, incremental search for:

  • 'manana', would find 'manana' or 'mañana'
  • 'motley crue', would also find 'Mötley Crüe' (with case-sensitivity off).

Even a solution that only covers a subset of these characters would be helpful.

  • Great question. Juri Linkov was talking about implementing this for Emacs, but nothing has come of it so far. See these two Emacs bug threads: (1) debbugs.gnu.org/cgi/bugreport.cgi?bug=13041 and (2) debbugs.gnu.org/cgi/bugreport.cgi?bug=13480#41. – Drew Nov 12 '13 at 4:14
  • Not the solution, but there are libraries that can at least remove accents from text. You might be able to get some of what you want done using one of those (remove accents temporarily etc.). I believe there are several such libraries, but I only know of one that I wrote long ago: unaccent.el. You can no doubt find something more recent and better. But we really need a solution such as that discussed in the first bug thread cited above. – Drew Nov 12 '13 at 4:17
  • This link (thread.gmane.org/gmane.emacs.devel/117003/focus=117959) in the first bug you mentioned meets my current need perfectly. Is there a way to have you enter your comment (and maybe the code snippet) as a reply so I can accept it as an answer? – user38983 Nov 12 '13 at 20:41
5

Great question. Juri Linkov was talking about implementing this for Emacs, but nothing has come of it so far. See these two Emacs bug threads:

See this part of the first bug thread, for instance. It includes this code from Ulrich Mueller:

   (let ((eqv-list '("aAàÀáÁâÂãÃäÄåÅ"
             "cCçÇ"
             "eEèÈéÉêÊëË"
             "iIìÌíÍîÎïÏ"
             "nNñÑ"
             "oOòÒóÓôÔõÕöÖøØ"
             "uUùÙúÚûÛüÜ"
             "yYýÝÿ"))
     (table (standard-case-table))
     canon)
     (setq canon (copy-sequence table))
     (mapcar (lambda (s)
           (mapcar (lambda (c) (aset canon c (aref s 0))) s))
         eqv-list)
     (set-char-table-extra-slot table 1 canon)
     (set-char-table-extra-slot table 2 nil)
     (set-standard-case-table table))

UPDATE

Character folding (ability to abstract from accents and such, when searching) will be available in Emacs 25. See the NEWS (C-h N) in an Emacs 25 development build. This is a welcome addition, and it promises to be enhanced in future releases.

My library character-fold+.el is one possible enhancement available now. It lets you optionally search not only for accented chars (e.g., é) by typing the base char (e.g., e) but also to do the reverse -- type any of a set of equivalent chars to search for any of them. And it lets you customize character folding by adding your own equivalence classes (and editing those defined by Emacs, other than those for diacritics).

Here is a message to emacs-devel@gnu.org about this.

1

I've no perfect solution, but I use incremental regexp search : C-S-s ma[nñ]ana or C-S-s ma.ana but this is not ideal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.