Subject: Re: bug#14742: 24.3.50; enhancement request: be able to prepend stuff from buffer when search backward

From: Juri Linkov <[email-masked]>
Date: Sat, 06 Jul 2013 02:17:35 +0300

>> +	  ;; Handle a motion function.
>> +	  ((and isearch-allow-move
>> +		(progn (setq key (isearch-reread-key-sequence-naturally keylist))
>> +		       (setq keylist (listify-key-sequence key))
>> +		       (setq main-event (aref key 0))
>> +		       (setq move-command (or
>> +					   (isearch-lookup-move-key key)
>> +					   (isearch-lookup-move-key
>> +					    ;; Use the last key in the sequence.
>> +					    (vector (aref key (1- (length key)))))))))
>> +	   (setq prefix-arg arg)
>> +	   (let ((new-point (save-excursion
>> +			      (condition-case ()
>> +				  (command-execute move-command)
>> +				(error nil))
>> +			      (point))))
>> +	     ;; An alternative to move without yanking is (goto-char new-point)
>> +	     (isearch-yank-or-del (point) new-point))
>> +	   (unless (eq (car-safe isearch-allow-move) 'only)
>> +	     (setq isearch-allow-move (cons 'only isearch-allow-move))))
>
> Hmm... that still adds a crap load of code in this already too-long function.
> Can't we bring it down to something like
>
>   +       ((isearch-handle-motion-function <blabla>))

This code is mostly a copy of code that implements the `isearch-allow-scroll'
feature.  If it's necessary to refactor the whole `isearch-other-meta-char'
then code for `isearch-allow-scroll' should be moved to a separate
function like `isearch-handle-scroll-function' too.

But still I don't understand how this would be possible to handle
outside of `isearch-other-meta-char', because this code changes the
local variables `key', `keylist', `main-event', `move-command'
locally bound in `isearch-other-meta-char'.