Gleb Arshinov <gleb(a)barsook.com> writes:
 -	  ;; #### What we really need is a buffer-local
 -	  ;; overriding-local-map.  See isearch-pre-command-hook for
 -	  ;; more details.
 - 	  overriding-local-map (progn
 - 				 (set-keymap-parents isearch-mode-map
 - 				  (nconc (current-minor-mode-maps)
 -					 (and (current-local-map)
 -					      (list (current-local-map)))))
 - 				 isearch-mode-map)
+	  ;; #### - don't do this statically: isearch-mode must be FIRST in
+	  ;; the minor-mode-map-alist -- Stig
+	  minor-mode-map-alist (cons (cons 'isearch-mode isearch-mode-map)
+				     minor-mode-map-alist) 
[...]
 XEmacs switched to using overriding-local-map (presumable to sync
 with FSF). 
No.  Isearch uses the overriding local map because it wants to take
precedence over extent-local keymaps.
 @@ -4757,6 +4752,18 @@
  	 (folding-xemacs-p
  	  (let ((f 'set-keymap-name))
  	    (funcall f folding-isearch-mode-map 'folding-isearch-mode-map))
+          ;; Gleb Arshinov: later version of XEmacs (21.2+) use
+          ;; overriding-local-map for isearch keymap rather than
+          ;; fiddling with minor-mode-map-alist (presumably to sync
+          ;; isearch with FSF).  The "right way" do deal with this
+          ;; would be to not even have this specialized block of code,
+          ;; but rather use overriding-local-map.  This _almost_ works
+          ;; -- isearch enters folds, however, you cannot get _out_ of
+          ;; isearch for some reason.  I could not figure out exactly
+          ;; why, so instead, I put in a workaround to disable
+          ;; overriding-local-map instead.  It would be good to figure
+          ;; out exactly what's going on and get rid of this hack.
+          (setq overriding-local-map nil) 
I wouldn't do this because some parts of isearch might depend on
overriding-local-map being used.
Why not do this:
    (set-keymap-parent folding-isearch-mode-map overriding-local-map)
    (setq overriding-local-map folding-isearch-mode-map)