unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* xref--read-identifier should call project-identifier-completion-table?
@ 2015-08-03  9:47 Stephen Leake
  2015-08-03  9:56 ` Dmitry Gutov
  0 siblings, 1 reply; 4+ messages in thread
From: Stephen Leake @ 2015-08-03  9:47 UTC (permalink / raw)
  To: emacs-devel

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



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-08-03 16:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-03  9:47 xref--read-identifier should call project-identifier-completion-table? Stephen Leake
2015-08-03  9:56 ` Dmitry Gutov
2015-08-03 15:24   ` Stephen Leake
2015-08-03 16:07     ` Dmitry Gutov

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).