Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically jump to tag in Emacs

Tags:

emacs

ctags

etag

I'd like to have find-tag automatically accept the default option (i.e. the word at point) and jump to the tag postion without prompting.

Is this possible?

I'm also using the advised version of find-tag from Emacswiki, that in case of match re-runs ctags. So I'd like something like this:

is current word a known tag?
-> yes: jump to it without further confirmation
-> no: rerun ctags
is it known now?
-> yes: jump to it without further confirmation
-> no: prompt user for input

Thank you!

like image 408
user673592 Avatar asked Dec 27 '22 19:12

user673592


1 Answers

This is one of the top hits on Google for "find tags emacs no prompt." For the simple version of that - without the ctag-regeneration logic the poster mentioned - it seems the key is:

(find-tag (find-tag-default))

So, for me, this works:

(defun find-tag-no-prompt ()
  "Jump to the tag at point without prompting"
  (interactive)
  (find-tag (find-tag-default)))
;; don't prompt when finding a tag
(global-set-key (kbd "M-.") 'find-tag-no-prompt)
like image 83
Michael Bosworth Avatar answered Jan 01 '23 20:01

Michael Bosworth