emacs

Fil 2025-05-08T12:49:36.512799Z

do you know how I can grep a symbol at the cursor using vanilla emacs?

2025-05-08T12:53:01.106319Z

one option on vanilla is to do M-x rgrep

2025-05-08T12:53:33.079169Z

by default it takes the current symbol the cursor is on

Fil 2025-05-08T12:54:14.879009Z

I liked it, thanks

1
Roma 2025-05-08T13:03:23.320429Z

M-s . will start isearch-symbol with the symbol at point in the current buffer. C-x p g will start project-find-regexp with symbol at point by default

πŸš€ 1
Fil 2025-05-08T13:06:13.438509Z

Cool! That is a good way to do it, too, with fewer interactive prompts! Nice!

Roma 2025-05-08T13:07:34.776389Z

after starting M-s . you can also execute M-% to rename all occurrences, works like rename symbol πŸ™‚

4
Fil 2025-05-08T13:15:21.361129Z

very cool

Roma 2025-05-08T13:17:21.391529Z

after running project-find-regexp you can hit r in *xref* buffer to start project-wide query replace

a13 2025-05-08T13:19:47.722739Z

also, there's always a way to insert a thing at point into minibuffer prompt by M-n

oyakushev 2025-05-08T13:32:24.381709Z

I use helm-ag package with ripgrep and the following hack to search for things under the cursor:

(defun helm-ag--insert-thing-at-point (thing)
    (helm-aif (thing-at-point thing)
        (s-replace-all '(("-" . "\\-")) (regexp-quote (substring-no-properties it)))
      ""))

(defun helm-do-ag-project-root-custom (sym-at-p)
    (interactive "P")
    (let ((helm-ag-base-command (if (equal current-prefix-arg '(16))
                                    helm-ag-base-command
                                  (concat helm-ag-base-command " -j1")))
          (helm-ag-insert-at-point (when sym-at-p 'symbol)))
      (helm-do-ag-project-root)))

βž• 1
Fil 2025-05-08T13:46:03.198159Z

@a13 what M-n stands for? In my emacs version v29.3 this keybinding is undefined

a13 2025-05-08T13:47:42.679039Z

Roma 2025-05-08T13:47:46.835039Z

When you're in minibuffer, it's bound to next-history-element command, but if you're at the beginning of the history, it tries to predict your choice

πŸ‘ 1
πŸ‘πŸ½ 1
Roma 2025-05-08T13:48:02.733309Z

next-history-element is an interactive native-comp-function in
β€˜simple.el’.

(next-history-element N)

Inferred type: (function (t) t)

Insert into the minibuffer the Nth next element of minibuffer history.
Interactively, N is the prefix numeric argument and defaults to 1.
The value N can go beyond the current position in the minibuffer
history,  and invoke "future history."

a13 2025-05-08T13:48:28.980349Z

and by default it inserts the entity at the point

Roma 2025-05-08T13:48:42.209569Z

I'd say it depends

Roma 2025-05-08T13:49:00.142689Z

if you use find-file command, M-n will insert the name of the current file

Fil 2025-05-08T13:50:52.203969Z

cool!

Fil 2025-05-08T13:51:04.328249Z

lot of learnings today

πŸ™Œ 1
a13 2025-05-08T13:52:07.705529Z

@rrudakov in grep/search scenarios, it inserts the entity at point

a13 2025-05-08T13:53:29.579599Z

btw, for counsel-find-file it inserts the thing at point, probably an ivy thing

Roma 2025-05-08T13:53:31.388739Z

yes, I'm just saying that this command is quite powerful and it's worth trying it in different scenarios πŸ™‚