emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

xref--read-identifier should call project-identifier-completion-table?


From: Stephen Leake
Subject: xref--read-identifier should call project-identifier-completion-table?
Date: Mon, 03 Aug 2015 04:47:45 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (windows-nt)

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 via email to

[Prev in Thread] Current Thread [Next in Thread]