Add html-, mhtml- and python-mode support to semantic symref

* lisp/cedet/semantic/symref/grep.el
(semantic-symref-filepattern-alist): Fix the entry for
'html-mode', which used a regexp-like syntax where only glob
syntax is permitted.  As a result, 'xref-find-references' (M-?)
can now find references in HTML files.  Also duplicate the same
entry for the sake of 'mhtml-mode', and add a new one for
'python-mode'.
(semantic-symref-derive-find-filepatterns): In the documentation,
clarify that returned patterns must follow the glob syntax.  Fix
an 'if' test that always evaluates to nil.
(semantic-symref-tool-grep):
(semantic-symref-perform-search): Fix typos.
This commit is contained in:
Charles A. Roelli 2017-11-04 22:19:08 +01:00
parent 369da28702
commit 725ab635d9

View file

@ -38,16 +38,22 @@
( (
) )
"A symref tool implementation using grep. "A symref tool implementation using grep.
This tool uses EDE to find he root of the project, then executes This tool uses EDE to find the root of the project, then executes
find-grep in the project. The output is parsed for hits find-grep in the project. The output is parsed for hits and
and those hits returned.") those hits returned.")
(defvar semantic-symref-filepattern-alist (defvar semantic-symref-filepattern-alist
'((c-mode "*.[ch]") '((c-mode "*.[ch]")
(c++-mode "*.[chCH]" "*.[ch]pp" "*.cc" "*.hh") (c++-mode "*.[chCH]" "*.[ch]pp" "*.cc" "*.hh")
(html-mode "*.s?html" "*.php") (html-mode "*.html" "*.shtml" "*.php")
(mhtml-mode "*.html" "*.shtml" "*.php") ; FIXME: remove
; duplication of
; HTML-related patterns.
; Maybe they belong in the
; major mode definition?
(ruby-mode "*.r[bu]" "*.rake" "*.gemspec" "*.erb" "*.haml" (ruby-mode "*.r[bu]" "*.rake" "*.gemspec" "*.erb" "*.haml"
"Rakefile" "Thorfile" "Capfile" "Guardfile" "Vagrantfile") "Rakefile" "Thorfile" "Capfile" "Guardfile" "Vagrantfile")
(python-mode "*.py" "*.pyi" "*.pyw")
(perl-mode "*.pl" "*.PL") (perl-mode "*.pl" "*.PL")
(cperl-mode "*.pl" "*.PL") (cperl-mode "*.pl" "*.PL")
(lisp-interaction-mode "*.el" "*.ede" ".emacs" "_emacs") (lisp-interaction-mode "*.el" "*.ede" ".emacs" "_emacs")
@ -58,7 +64,7 @@ See find -name man page for format.")
(defun semantic-symref-derive-find-filepatterns (&optional mode) (defun semantic-symref-derive-find-filepatterns (&optional mode)
;; FIXME: This should be moved to grep.el, where it could be used ;; FIXME: This should be moved to grep.el, where it could be used
;; for "C-u M-x grep" as well. ;; for "C-u M-x grep" as well.
"Derive a list of file patterns for the current buffer. "Derive a list of file (glob) patterns for the current buffer.
Looks first in `semantic-symref-filepattern-alist'. If it is not Looks first in `semantic-symref-filepattern-alist'. If it is not
there, it then looks in `auto-mode-alist', and attempts to derive something there, it then looks in `auto-mode-alist', and attempts to derive something
from that. from that.
@ -78,7 +84,7 @@ Optional argument MODE specifies the `major-mode' to test."
(error "Customize `semantic-symref-filepattern-alist' for %S" (error "Customize `semantic-symref-filepattern-alist' for %S"
major-mode) major-mode)
(let ((args `("-name" ,(car pat)))) (let ((args `("-name" ,(car pat))))
(if (null (cdr args)) (if (null (cdr pat))
args args
`("(" ,@args `("(" ,@args
,@(mapcan (lambda (s) `("-o" "-name" ,s)) pat) ,@(mapcan (lambda (s) `("-o" "-name" ,s)) pat)
@ -149,7 +155,7 @@ This shell should support pipe redirect syntax."
(oref tool searchfor)) (oref tool searchfor))
(t (t
;; Can't use the word boundaries: Grep ;; Can't use the word boundaries: Grep
;; doesn't always agrees with the language ;; doesn't always agree with the language
;; syntax on those. ;; syntax on those.
(format "\\(^\\|\\W\\)%s\\(\\W\\|$\\)" (format "\\(^\\|\\W\\)%s\\(\\W\\|$\\)"
(oref tool searchfor))))) (oref tool searchfor)))))