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

From: Stefan Monnier <[email-masked]>
Date: Fri, 05 Jul 2013 06:37:39 -0400

> @@ -2379,7 +2616,67 @@ (defun isearch-other-meta-char (&optiona
>               (if ab-bel
>                   (isearch-back-into-window (eq ab-bel 'above) isearch-point)
>                 (goto-char isearch-point)))
>            (isearch-update))
> +	  ;; 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* ((old-point (point))
> +		  (new-point (save-excursion
> +			       (condition-case ()
> +				   (command-execute move-command)
> +				 (error nil))
> +			       (point))))
> +	     ;; Change search direction between forward and backward.
> +	     (when (if isearch-forward
> +			 (< new-point old-point)
> +		       (> new-point old-point))
> +	       (setq isearch-forward (not isearch-forward))
> +	       (setq isearch-string "" isearch-message "")
> +	       (if isearch-other-end (setq old-point isearch-other-end)))
> +	     (if (< old-point new-point)
> +		 (if isearch-forward
> +		     (isearch-yank-string
> +		      (buffer-substring-no-properties old-point new-point))
> +		   (isearch-del-char (- new-point old-point) t))
> +	       (if isearch-forward
> +		   (isearch-del-char (- old-point new-point))
> +		 (isearch-yank-string
> +		  (buffer-substring-no-properties old-point new-point) t))))
> +	   (setq isearch-allow-move (cons 'only isearch-allow-move)))
>  	  ;; A mouse click on the isearch message starts editing the search string
>  	  ((and (eq (car-safe main-event) 'down-mouse-1)
>  		(window-minibuffer-p (posn-window (event-start main-event))))

Could you move this new code to a separate function?

        Stefan