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

File path with spaces #82

Open
j-oldroyd opened this issue Nov 3, 2024 · 0 comments
Open

File path with spaces #82

j-oldroyd opened this issue Nov 3, 2024 · 0 comments

Comments

@j-oldroyd
Copy link

I tried using the SageTeX functionality of this package on a TeX file that I had saved in Google Drive. When I tried to do so, it appeared that Sage was unable to find the correct file since the file path was being split on the first space in the filename. After a bit of digging, it seems like the issue lies in the definition of the sage-shell-sagetex:tex-master-maybe function. In my config file I added the advice

(advice-add 'sage-shell-sagetex:tex-master-maybe
                 :filter-return #'shell-quote-argument)

and this seemed to fix the line break issue I mentioned above.

At this point, it seemed that the correct filename was being fed to Sage, but using shell-quote-argument introduced escape slashes before the spaces in the filename that now caused issues in the function sage_tex_load in emacs_sage_shell.py. In particular, the .expanduser() method no longer worked on the input. I've modified this function to remove the escape slashes introduced by shell-quote-argument as follows:

def sage_tex_load(f: Path) -> None:
    f = f.split('\\')
    f = ''.join(f)
    f = Path(f)
    d = f.expanduser().parent
    with current_dir(d):
        ip.ev(f'load("{f}")')

So far this seems to be working, but I don't know if this will cause problems down the road or if there's a better way to handle filenames with spaces in them.

Thanks for writing a very nice package. I've gotten some good use out of it already, and I look forward to using it more in my LaTeX workflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant