(require 'helm) (require 'helm-migemo) (defvar helm-match-part-use-migemo nil) (defun helm-search-from-candidate-buffer--migemo-p (pattern get-line-fn search-fns limit start-point match-part-fn source) (setq helm-match-part-use-migemo (assq 'migemo source))) (advice-add 'helm-search-from-candidate-buffer :before 'helm-search-from-candidate-buffer--migemo-p) ;;; REDEFINED (defun helm-search-match-part--use-migemo (candidate pattern match-part-fn) "Match PATTERN only on part of CANDIDATE returned by MATCH-PART-FN. Because `helm-search-match-part' maybe called even if unspecified in source (negation), MATCH-PART-FN default to `identity' to match whole candidate. When using fuzzy matching and negation (i.e \"!\"), this function is always called." (let ((part (funcall match-part-fn candidate)) (match-fn (if helm-match-part-use-migemo (lambda (re str) (helm-string-match-with-migemo str re)) 'string-match)) (fuzzy-regexp (cadr (gethash 'helm-pattern helm--fuzzy-regexp-cache)))) (if (string-match " " pattern) (cl-loop for i in (split-string pattern) always (if (string-match "\\`!" i) (not (funcall match-fn (substring i 1) part)) (funcall match-fn i part))) (if (string-match "\\`!" pattern) (not (funcall match-fn (if helm--in-fuzzy ;; Fuzzy regexp have already been ;; computed with substring 1. fuzzy-regexp (substring 1 pattern)) part)) (funcall match-fn (if helm--in-fuzzy fuzzy-regexp pattern) part))))) (advice-add 'helm-search-match-part :override 'helm-search-match-part--use-migemo) (provide 'mylisp-helm-migemo-match-part-fix)