unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stephen Leake <stephen_leake@stephe-leake.org>
To: emacs-devel@gnu.org
Subject: xref--read-identifier should call project-identifier-completion-table?
Date: Mon, 03 Aug 2015 04:47:45 -0500	[thread overview]
Message-ID: <86k2tchfem.fsf@stephe-leake.org> (raw)

xref--read-identifier uses a completion table set by the variable
xref-identifier-completion-table-function, which is normally
buffer-local, set by the major mode.

However, if I'm debugging an elisp package (ie JDEE), I want to be able
to search for elisp identifiers via C-u M-. from any buffer, not just
elisp buffers. Similarly, if I'm debugging an Ada package, I want to
search for Ada identifiers.

That means the identifier completion table is associated with the
current project, not the current mode.

Which means xref--read-identifier should call a project function to get
the completion-table:

(cl-defgeneric project-identifier-completion-table (project)
  "Return a completion table of identifiers in PROJECT."
  (when xref-identifier-completion-table-function
    (funcall xref-identifier-completion-table-function)))

(defun xref--read-identifier (prompt)
  "Return the identifier at point or read it from the minibuffer."
  (let ((id (funcall xref-identifier-at-point-function)))
    (cond ((or current-prefix-arg
               (not id)
               (xref--prompt-p this-command))
           (completing-read (if id
                                (format "%s (default %s): "
                                        (substring prompt 0 (string-match
                                                             "[ :]+\\'" prompt))
                                        id)
                              prompt)
                            (project-identifier-completion-table)
                            nil nil nil
                            'xref--read-identifier-history id))
          (t id))))

The default method for project-identifier-completion-table uses the
current xref buffer-local variable, so that's the same as the current
behavior. It might be better to change that to have a project- prefix.


Now I can override project-identifier-completion-table in a project
backend to give the behavior I need.

-- 
-- Stephe



             reply	other threads:[~2015-08-03  9:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-03  9:47 Stephen Leake [this message]
2015-08-03  9:56 ` xref--read-identifier should call project-identifier-completion-table? Dmitry Gutov
2015-08-03 15:24   ` Stephen Leake
2015-08-03 16:07     ` 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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86k2tchfem.fsf@stephe-leake.org \
    --to=stephen_leake@stephe-leake.org \
    --cc=emacs-devel@gnu.org \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).