emacs-devel
[Top][All Lists]
Advanced

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

Re: xref and GNU Global (Re: ELPA policy)


From: Stephen Leake
Subject: Re: xref and GNU Global (Re: ELPA policy)
Date: Thu, 12 Nov 2015 01:05:58 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (windows-nt)

Nicolas Petton <address@hidden> writes:

> Stephen Leake <address@hidden> writes:
>
>>> What about having support for Global (I haven't followed the development
>>> of xref in a while, so I might have missed it).  I'm using ggtags now,
>>> but having support for it in xref would be awesome.
>>
>> I'm working on it, but I seem to be going very slowly.
>
> Do you want help?

Yes, but the main reason I'm not making progress on this backend is that
I keep getting distracted by other project.el and xref issues.

Here's what I have so far - feel free to play with it:

--- file symref-patches.el
;; Additions to semantic/symref.el

;; semantic/symref implementation of xref-find-function

(defun semantic-symref--xref-find-definitions (symbol &optional symref-tool)
  "Implement `xref-find-function' for 'definitions for the semantic/symref 
backend.
SYMREF-TOOL determines which symref tool to use (default
'detect); see `semantic-symref-tool-alist'."
  (require 'semantic/symref)
  (defvar semantic-symref-tool)
  (let* ((semantic-symref-tool (or symref-tool 'detect))
         (res (semantic-symref-find-tags-by-name symbol 'project))
         (hits (and res (oref res hit-lines)))
         xrefs)

    (dolist (hit hits)
      (push
       (xref-file-location
        :file (cdr hit)
        :line (car hit)
        :column 0)
       ;; FIXME: add :hint (match-string 3))
       xrefs))

    xrefs))

(defun semantic-symref-xref-find (action id)
  "Implement `xref-find-function' for semantic/symref."
  (cl-ecase action
    (definitions
      (semantic-symref--xref-find-definitions id))
    (references
     (semantic-symref--xref-find-references id))
    (apropos
     (semantic-symref--xref-find-apropos id)))
  )

(provide 'symref-patches)
--- end file


> BTW, regarding CEDET, I never tried it, but I don't plan to use it
> either.  I think the best would be to just add a simple backend for
> xref, with no dependency to CEDET.

The above requires that you enable EDE via:

 (require 'ede)
 (global-ede-mode)
 (ede-enable-generic-projects)

but it does not require semantic-mode.

EDE is required because the symref backend detection uses EDE to find
the project root. For Gnu Global, that could be changed to one call to
locate-dominating-file. But I'm waiting for the current CEDET merge to
master to be complete before suggesting changes to this.

This gets to the issue of whether CEDET is part of the Emacs standard
library or not. If it is, we should use it, while also making it more
transparent to users like you, who would rather not be bothered by it.
Which is an example of the kind of thing I get distracted by :).

Can you elaborate on why you don't want to use CEDET?

I'm assuming you mean you don't want to enable semantic-mode or
ede-mode; you should not care whether the file cedet-global.el is
loaded. 

-- 
-- Stephe



reply via email to

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