Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Prague2049 opened this issue Sep 6, 2023 · 1 comment

Comments

@Prague2049
Copy link

Prague2049 commented Sep 6, 2023

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 () "Save rg' 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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants