読者です 読者をやめる 読者になる 読者になる

helm-occurをhelm-migemo対応させた後にすること

emacs helm

以下のhelm-migemoの修正を施した後にやればいいと思われる修正。

http://rubikitch.com/2014/12/19/helm-migemo/

(cl-defun helm-moccur-action (candidate
                              &optional (method (quote buffer)) mark)
          "Jump to CANDIDATE with METHOD.
arg METHOD can be one of buffer, buffer-other-window, buffer-other-frame."
          (require 'helm-grep)
          (let* ((split (helm-grep-split-line candidate))
                 (buf (car split))
                 (lineno (string-to-number (nth 1 split)))
                 (split-pat (if helm-occur-match-plugin-mode
                                (helm-mp-split-pattern helm-pattern)
                              (list helm-pattern)))
                 (search-func (if (featurep 'migemo)
                                  'migemo-forward
                                're-search-forward)))
            (cl-case method
                     (buffer              (switch-to-buffer buf))
                     (buffer-other-window (switch-to-buffer-other-window buf))
                     (buffer-other-frame  (switch-to-buffer-other-frame buf)))
            (helm-goto-line lineno)
            ;; Move point to the nearest matching regexp from bol.
            (cl-loop for reg in split-pat
                     when (save-excursion
                            (funcall search-func reg (point-at-eol) t))
                     collect (match-beginning 0) into pos-ls
                     finally (when pos-ls (goto-char (apply #'min pos-ls))))
            (when mark
              (set-marker (mark-marker) (point))
              (push-mark (point) 'nomsg))))

絞り込んだ候補を選択した後、絞り込みでハイライトされた箇所にきちんとジャンプするために関数を再定義している。