From: "R. Diez" <rdiezmail-emacs@yahoo.de>
To: Noam Postavsky <npostavs@gmail.com>
Cc: Help Gnu Emacs mailing list <help-gnu-emacs@gnu.org>
Subject: Re: Replacing find-tag with xref
Date: Thu, 2 May 2019 11:34:40 +0200 [thread overview]
Message-ID: <0199ffcd-c37f-4e41-c76b-fb4f4a2c1fa7@yahoo.de> (raw)
In-Reply-To: <CAM-tV-8zP5sbbzh1gShkA3hks7HPpcdWj-68TrWBcNjjVTT53A@mail.gmail.com>
>> This deprecation has now become a more serious issue, because etags.el is no longer present in a convenient package repository, like Emacs'
>> default one or MELPA.
>
> Um, isn't it still in master?
Sorry, in the meantime I have realised that it was actually package etags-select, which was removed from MELPA.
I have managed to come up with alternative implementations for find-tag and etags-select-find-tag-at-point . In case it helps anybody, the
code is at the bottom.
Incidentally, I think I found a small bug: when xref-find-definitions prompts, and you press Enter (provide an empty string to look for), it
hangs with 100 % CPU usage.
; find-tag has been deprecated in emacs 25.1, and package etags-select has been removed from MELPA,
; so I am switching now to xref-find-definitions.
; (global-set-key [M-f11] 'etags-select-find-tag-at-point)
;
; Alternatively, we could use jump-to-definition-at-point-only-from-tags-file.
(global-set-key [M-f11] 'jump-to-definition-at-point)
(defun jump-to-definition-at-point () ""
(interactive)
(let* ((thing (xref-backend-identifier-at-point 'etags)))
(unless thing
(error "No identifier found at point."))
; Alternatively, we could use xref-find-definitions-other-window.
(xref-find-definitions thing)
)
)
; This routine makes xref-find-definitions use only the TAGS file. Otherwise, in Lisp mode,
; it would not use the TAGS file at all, but another backend that uses dynamic information to find symbols.
; That would also be the case for other modes in any future if new xref backends are added to Emacs.
;
; An alternative to this routine would be to turn the xref-etags-mode on globally.
; But then we may want to use other backends in other scenarios.
;
; Yet another way would be (add-hook 'emacs-lisp-mode-hook #'xref-etags-mode),
; because the lisp mode is the only thing as of Emacs 26 that uses another backend.
; But again, that can change in the future.
(defun jump-to-definition-at-point-only-from-tags-file () ""
(interactive)
(let ((xref-backend-functions '(etags--xref-backend)))
(jump-to-definition-at-point))
)
(defun jump-to-definition () ""
(interactive)
(let ((current-prefix-arg '(1))) ; With a prefix argument, xref-find-definitions will always prompt.
(call-interactively 'xref-find-definitions)
)
)
(defun jump-to-definition-only-from-tags-file () ""
(interactive)
(let ((xref-backend-functions '(etags--xref-backend)))
(jump-to-definition))
)
next prev parent reply other threads:[~2019-05-02 9:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-30 9:15 Replacing find-tag with xref R. Diez
2019-04-30 14:33 ` Noam Postavsky
2019-05-02 9:34 ` R. Diez [this message]
2019-05-02 11:15 ` Noam Postavsky
2019-05-02 22:53 ` Dmitry Gutov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0199ffcd-c37f-4e41-c76b-fb4f4a2c1fa7@yahoo.de \
--to=rdiezmail-emacs@yahoo.de \
--cc=help-gnu-emacs@gnu.org \
--cc=npostavs@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.