dajva / rg.el

Emacs search tool based on ripgrep
https://rgel.readthedocs.io
GNU General Public License v3.0
465 stars 38 forks source link

How to make "enter" key open target file at the location of the searched keyword? #162

Open Prague2049 opened 10 months ago

Prague2049 commented 10 months ago

When I press "Enter" key on rg result buffer to open target file. When opening target file, the displayed content is at the beginning of the entire file. Doesn't it show the location of the file where the search keyword is located? Is there any solution? Mac , Org mode version 9.6.7, emacs-plus@29, rg-20230430.721 My configuration is as follows: (use-package rg :bind* (("C-c C-s" . my-grep-vc-or-dir)) :bind (:map rg-mode-map ("f" . next-error-follow-minor-mode) ("s" . my-rg-save-search-as-name) ("n" . next-line) ("p" . previous-line) ("C-n" . next-line) ("C-p" . previous-line) ("M-n" . rg-next-file) ("M-p" . rg-prev-file)) :config (with-eval-after-load 'rg (require 'wgrep) (setq rg-group-result t) (setq rg-hide-command t) (setq rg-show-columns nil) (setq rg-show-header t) (setq rg-custom-type-aliases nil) (setq rg-default-alias-fallback "all") (rg-enable-menu) (setq rg-executable "rg") (rg-define-search my-grep-vc-or-dir :query ask :format regexp :files "everything" :case-fold-search smart :dir (let ((vc (vc-root-dir))) (if vc vc default-directory)) :confirm prefix :flags ("--hidden -g !.git")) (defun my-rg-save-search-as-name () "Saverg' buffer, naming it after the current search query. This function is meant to be mapped to a key in `rg-mode-map'." (interactive) (let ((pattern (car rg-pattern-history))) (rg-save-search-as-name (concat "«" pattern "»"))))

(defun my-next-window (_)
  (other-window 1))

(advice-add 'my-grep-vc-or-dir :after 'my-next-window)))

`

ZelphirKaltstahl commented 7 months ago

Can you please cleanup your question? I am not sure anyone will take a look at this, thrown out like it looks now, but it could be relevant.