Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cite-autocompletion: problem with umlaut in pathname #121

Open
jarrndewitt opened this issue Jan 22, 2018 · 7 comments
Open

cite-autocompletion: problem with umlaut in pathname #121

jarrndewitt opened this issue Jan 22, 2018 · 7 comments
Labels

Comments

@jarrndewitt
Copy link

jarrndewitt commented Jan 22, 2018

I am using vim-latex on windows 10.

I want to use cite-autocompletion within chapter.tex which itself gets included in main.tex in the same directory. The file main.tex.latexmain resides in the same directory.

The autocompletion works without problems except when there are Umlauts (ÄÖÜäöüß) in the pathname. Spaces don't seem to be a problem though.

When I press [F9] vim-latex displays a line "(a) all (f) filter ..." at the bottom and prompts me to press ENTER. When I do that I get back into insert mode where I was before without an empty display of found bib-entries. To me this seems to be the same as if I had removed the bib-file.

However if I type :py Tex_BibFile=bibtools.BibFile("bibliographie.bib") autocompletion works. I have to retype this after every start of vim.

@gerw
Copy link
Contributor

gerw commented Jan 22, 2018

I cannot reproduce this with linux. Can you enable debugging

let g:Tex_Debug = 1
let g:Tex_DebugLog = "vim-latex-suite.log"

and show the log file after trying to complete a \cite{?

@jarrndewitt
Copy link
Author

I use the file main.tex

\documentclass{article}
\usepackage{natbib}
\bibliographystyle{dinat}
\begin{document}
\cite{s}
\bibliography{bibliography}
\end{document}

and bibliography.bib

@Article{six,
title = "The Six -- a Boring Number",
author = "Name, Alice and Other, Bob",
journal = "Journal for Testing Affairs",
year = 2066,
volume = 66,
number = 6,
pages = "66--666",
}
@Article{seven,
title = "The Seven -- an Interesting Number",
author = "Name, Alice and Other, Bob",
journal = "Journal for Testing Affairs",
year = 2077,
volume = 77,
number = 7,
pages = "77--777",
}

I have these files once in a directory called A and once in a directory called Ä. Everything else is identical. I now open the file main.tex, enable debugging, put the cursor behing the \cite{s and press [F9].

The log within a path without umlaut:

view : Tex_Complete: s:type = cite, typeoption =
view : :Tex_Complete: using s:prefix = s
view : :Tex_FindBibFiles:
proj : texproject.vim: catching LatexSuiteFileType event
env : envmacros.vim: Catching LatexSuiteFileType event
comp : compiler.vim: Catching LatexSuiteFileType event
fold : folding.vim: catching LatexSuiteFileType
brak : brackets.vim: Catching LatexSuiteFileType event
view : texviewer.vim: Catching LatexSuiteFileType event
main : main.vim: Catching LatexSuiteFileType event
pack : packages.vim: Catching LatexSuiteFileType event
pack : +Tex_pack_updateall
view : Tex_FindBibFiles: found bibliography command in main.tex
view : :Tex_FindBibFiles: bib command from line 6 to line 6
view : :Tex_FindBibFiles: concatenated bib command: "bibliography}"
view : :Tex_FindBibFiles: trying to search through [bibliography]
view : :Tex_FindBibFiles: returning [C:/Users/User/Documents/Temp/A/bibliography.bib
]

The log within a path with umlaut:

view : Tex_Complete: s:type = cite, typeoption =
view : :Tex_Complete: using s:prefix = s
view : :Tex_FindBibFiles:
proj : texproject.vim: catching LatexSuiteFileType event
env : envmacros.vim: Catching LatexSuiteFileType event
comp : compiler.vim: Catching LatexSuiteFileType event
fold : folding.vim: catching LatexSuiteFileType
brak : brackets.vim: Catching LatexSuiteFileType event
view : texviewer.vim: Catching LatexSuiteFileType event
main : main.vim: Catching LatexSuiteFileType event
pack : packages.vim: Catching LatexSuiteFileType event
pack : +Tex_pack_updateall
view : Tex_FindBibFiles: found bibliography command in main.tex
view : :Tex_FindBibFiles: bib command from line 6 to line 6
view : :Tex_FindBibFiles: concatenated bib command: "bibliography}"
view : :Tex_FindBibFiles: trying to search through [bibliography]
view : :Tex_FindBibFiles: returning [C:/Users/User/Documents/Temp/Ä/bibliography.bib
]

Till now the log looks identical to me (except the changed path of course)

@gerw
Copy link
Contributor

gerw commented Jan 23, 2018

Does

:py Tex_BibFile=bibtools.BibFile("""C:/Users/User/Documents/Temp/Ä/bibliography.bib""")

work?

@jarrndewitt
Copy link
Author

That produces

Traceback (most recent call last):
File "", line 1, in
File "C:\Users\User\vimfiles\ftplugin\latex-suite/bibtools.py", line 194, in init
self.addfile(f)
File "C:\Users\User\vimfiles\ftplugin\latex-suite/bibtools.py", line 197, in addfile
fields = urlopen('file://' + pathname2url(os.path.abspath(file))).read().decode('utf-8').split('@')
File "C:\Program Files\Python27\Lib\urllib.py", line 87, in urlopen
return opener.open(url)
File "C:\Program Files\Python27\Lib\urllib.py", line 8218 in open
return getattr(self, name)(url)
File "C:\Program Files\Python27\Lib\urllib.py", line 469, in open_file
return self.open_local_file(url)
File "C:\Program Files\Python27\Lib\urllib.py", line 483, in open_local_file
raise IOError(e.errno, e.strerror, e.filename)
IOError: [Errno 2] Das System kann den angegebenen Pfad nicht finden: 'C:\Users\User\Documents\Temp\\xc3\x84\bibliography.bib'

However when I just type :py Tex_BibFile=bibtools.BibFile("""bibliography.bib""") (without the path), cite-completion works afterwards.

@gerw
Copy link
Contributor

gerw commented Jan 23, 2018

Does the command with the full path work if you replace
https://github.com/vim-latex/vim-latex/blob/master/ftplugin/latex-suite/bibtools.py#L11
by

 from urllib2 import urlopen, pathname2url

?

Otherwise I would be very happy if you are able to fix the python code since I am not able to reproduce your error.

@jarrndewitt
Copy link
Author

If I do that the next time I open a .tex file I get ImportError: cannot import name pathname2url.

@gerw
Copy link
Contributor

gerw commented Jan 23, 2018

Ok. Maybe one has to fiddle around with the encoding of the filename? The filename is passed to python utf-8 encoded. However, NTFS seems to use utf-16.

@gerw gerw added the bug label Jan 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants