I wrote a little search function a long time ago, binded to ctrl-f. It has been working perfectly until I tried Emacs 24.4.
The purpose of the function is to highlight (region) the found word. Furthermore I have other functions that can select/look backward/forward for the same text. This set of dunctions are pretty useful and I am use to it.
The problem: Any key I hit (right arrow for example) after searching with this function with v24.3.1 will automatically disable the region highlighting. With v24.4 and above the region is still active and I need to disable it manually with ctrl-space before doing anything which is annoying.
Questions: Any idea on what change concerning this behavior between those versions? Is there a work around to have the old behavior?
(defun mp-search (string) "Search using search-forward instead of i-search, this search cannot search whole word only" (interactive "sSearch for : ") ; backup point (setq mp_backup_point (point)) (set-mark nil) ; search forward the selection if there is a selection (if (search-forward string nil t) (progn (set-mark (point)) (backward-char (length string)) (exchange-point-and-mark)) (progn (message "Return at the file's beginning...") (goto-char 0) (if (search-forward string nil t) (progn (set-mark (point)) (backward-char (length string)) (exchange-point-and-mark)) (progn (goto-char mp_backup_point) (message "Nothing was found..."))))) )
Binding: (global-set-key [(ctrl f)] 'mp-search)