Open lawremi opened 8 years ago
Could you tell me your use-case in more detail ? I think tag name(function, class/struct field, variable name) does not contain .
(dot) in C, C++, Java, PHP.
Not in those languages, but unusual languages like R do allow .
in symbol names and it is actually quite common. It would be great to have a variable that one could set when entering a specific editing mode. It would allow a custom pattern for extracting symbols.
What major-mode do you use in such case ? If it does not treat .
as symbol, mode implementation is wrong.
You can fix by adding following configuration in your hook function
;; Please replace `some-mode' with your major-mode
(defun my/some-mode-hook ()
(modify-syntax-entry ?. "_" some-mode-syntax-table))
(add-hook 'some-mode-hook 'my/some-mode-hook)
Hmm, well, it looks like the mode (ess) is already allowing .
. See here. Perhaps something else is wrong?
Please check .
syntax by M-x describe-syntax
. Could you show me test code of this issue and ess configuration for reproducing this issue ? (I don't know ess well).
I think it would be tough to reproduce right now, because it depends on a way to build a gtags index for R code. I've written one, but it's not yet cleared by the lawyers for release ;) The syntax table looks good though, because it contains this line:
. _ which means: symbol
But when I index an R function like:
foo.bar = function(x) { x }
And then put the point on a call like:
foo.bar(x)
I get the error: "foo.bar: not found" even though I can find it in the index with e.g. helm-gtags-select
.
If I change the function name to foobar
, everything works.
I have the exact same problem, also with R. I generate the GTAGS file with a call to gtags, for instance. I have configured my ~.globalrc
so that the default uses also pygments, and this works just fine with global from the shell.
Minimal example: steps
(This I am not sure how much it matters). My .globalrc
file has:
default:\
:tc=pygments-parser:tc=gtags:
native:\
:tc=gtags:tc=htags:
pygments:\
:tc=pygments-parser:tc=htags:
(so that pygments is always used in addition to gtags in the default). And the pygments-parser part has these lines (though I do not recall modifying anything here).
:langmap=S\:.S.R:\
(...)
:gtags_parser=S\:/usr/local/lib/gtags/pygments-parser.la:\
(Of course, I can share my complete .globalrc
if needed).
Open a buffer and call it, say, f1.R
and copy the following code (you should see the modeline display ESS[S]
):
foo.bar <- function(x) return(x)
foobar <- function(x) return(x)
3 + foo.bar(4)
5 + foobar(4)
helm-gtags-create-tags
foobar
: with helm-gtags-dwim
one jumps to the definition. Not so if you are on the one before last line (3 + foo.bar(4)
): here I get foo.bar: not found
.global -x foo.bar
and check that global can indeed find the definition. In my case I get foo.bar 1 f1.R foo.bar <- function(x) return(x)
.Syntax table
I just did the M-x describe-syntax
and this is what I get (only showing what I understand to be the relevant entries; let me know if you need anything else)
C-j > which means: endcomment
" " which means: string
# < which means: comment
$ _ which means: symbol
% .. & . which means: punctuation
' " which means: string
* .. + . which means: punctuation
- . which means: punctuation
. _ which means: symbol
/ . which means: punctuation
: _ which means: symbol
< .. > . which means: punctuation
@ _ which means: symbol
\ \ which means: escape
_ _ which means: symbol
` " which means: string
| . which means: punctuation
The parent syntax table is:
C-@ .. C-h . which means: punctuation
TAB .. C-j which means: whitespace
C-k . which means: punctuation
C-l .. RET which means: whitespace
C-n .. C-_ . which means: punctuation
SPC which means: whitespace
! . which means: punctuation
" " which means: string
# . which means: punctuation
$ .. % w which means: word
& _ which means: symbol
' . which means: punctuation
( () which means: open, matches )
) )( which means: close, matches (
* .. + _ which means: symbol
, . which means: punctuation
- _ which means: symbol
. . which means: punctuation
I have the exact same problem, also with R.
1) I generate the GTAGS file with a call to gtags, using universal-ctags. Command line global
works as expected.
2) Using helm-gtags-dwim
fails (with the following message, foo.bar: not found)
3) Using helm-gtags-find-tag
works as expected
The following example can be used to reproduce the problem: a) Minimal example in R
cat << 'EOF' > foo.bar.R
foo.bar <- function(x) return(x)
EOF
cat << 'EOF' > foobar.R
foobar <- function(x) {
y <- foo.bar(x)
return(y)
}
EOF
b) minimal global configuration (with universal-ctags)
cat << 'EOF' > $HOME/.globalrc
default:\
:tc=new-ctags:
native:\
:tc=gtags:tc=htags:
new-ctags:\
:tc=universal-ctags:tc=htags:
common:\
:skip=HTML/,HTML.pub/,tags,TAGS,ID,y.tab.c,y.tab.h,gtags.files,cscope.files,cscope.out,cscope.po.out,cscope.in.out,SCCS/,RCS/,CVS/,CVSROOT/,{arch}/,autom4te.cache/,*.orig,*.rej,*.bak,*~,#*#,*.swp,*.tmp,*_flymake.*,*_flymake,*.o,*.a,*.so,*.lo,*.zip,*.gz,*.bz2,*.xz,*.lzh,*.Z,*.tgz,*.min.js,*min.css:
# Built-in parsers.
gtags:\
:tc=common:\
:tc=builtin-parser:
builtin-parser:\
:langmap=c\:.c.h,yacc\:.y,asm\:.s.S,java\:.java,cpp\:.c++.cc.hh.cpp.cxx.hxx.hpp.C.H,php\:.php.php3.phtml:
# Plug-in parser to use Universal Ctags.
universal-ctags|setting to use Universal Ctags plug-in parser:\
:tc=common:\
:ctagscom=/usr/bin/ctags:\
:ctagslib=$libdir/gtags/universal-ctags.so:\
:langmap=R\:.r.R.s.q:\
:gtags_parser=R\:$ctagslib:
# Configuration for htags(1)
htags:\
::
EOF
c) create tags, investigate global behavior (which is correct)
export GTAGSLABEL=universal-ctags
gtags
global foo.bar
it will answer foo.bar
d) Using helm-gtags
with ess
and (add-hook 'ess-mode-hook 'helm-gtags-mode)
in foobar.R
on the name foo.bar
will work with helm-gtags-find-tag
but not with helm-gtags-dwim
It looks like
helm-gtags-dwim
andhelm-gtags-find-tag-from-here
fail to find tags with a period (".") in their name. Perhaps this is due to howthing-at-pt
parses symbols. Is there any way to work around this?helm-gtags-find-tag
does make the correct auto suggestion.