32.8 Rational SearchesEmacs has, oh, a hundred or so different search commands. (Well, really, the number's probably more like 32, but who's counting?) There are searches of absolutely every flavor you could ever imagine: incremental searches, word searches, [3] regular expression searches, and so on.
However, when it comes to your plain, old garden-variety search, Emacs is strangely deficient. There is a simple search that just looks for some arbitrary sequence of characters; but it's rather well hidden. And it lacks one very important feature: you can't search for the same string repeatedly. That is, you can't say "OK, you found the right sequence of letters; give me the next occurrence"; you have to retype your search string every time.
;; real searches, courtesy of Chris Genly ;; substitute your own Emacs hack directory for /home/los/mikel/emacs (load-file "/home/los/mikel/emacs/search.el") Now you can type CTRL-s to search forward and CTRL-r to search back. Emacs will prompt you for a search string and start searching when you press RETURN. Typing another CTRL-s or CTRL-r repeats your previous search. When you try this, you'll see one other useful feature: unlike the other Emacs searches, this kind of search displays the "default" (i.e., most recent) search string in the mini-buffer. It's exactly the kind of search I want. It's conceivable that you'll occasionally want incremental searches. You'll have to "rebind" them in order to use them conveniently. Here are the key bindings that I use: ;; rebind incremental search as ESC-s and ESC-r (define-key global-map "\M-s" 'isearch-forward) (define-key global-map "\M-r" 'isearch-backward) ;; have to rebind ESC s separately for text-mode. It's normally ;; bound to 'center-line'. (define-key text-mode-map "\M-s" 'isearch-forward) That is: Of course, now you'll have to rebind the "center-line" command if you're fond of it. In my opinion, it's not worth the trouble. The game of "musical key-bindings" stops here. - |
|