Last active
December 25, 2015 07:49
-
-
Save tam17aki/6941835 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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))) | |
;; for helm-migemo | |
(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 (goto-char (apply #'min pos-ls))) | |
(when mark | |
(set-marker (mark-marker) (point)) | |
(push-mark (point) 'nomsg)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment