joaotavora / sly

Sylvester the Cat's Common Lisp IDE
1.25k stars 142 forks source link

Escape file name when completing? #367

Open Ambrevar opened 3 years ago

Ambrevar commented 3 years ago

Is it possible to escape filename when completing them? This is needed when a filename contains double quotes, e.g. foo"bar, otherwise the completion will result in incorrect syntax like #p"path/to/foo"bar".

In a SLY REPL, completion-at-point-functions is set to (sly-complete-filename-maybe sly-complete-symbol).

(defun sly-complete-filename-maybe ()
  (when (nth 3 (syntax-ppss)) (comint-filename-completion)))

So this calls comint-filename-completion which is also used by shell-mode and correctly escape double quotes. I must be missing something.

Any idea?

joaotavora commented 3 years ago

Any idea?

No, sorry. I suppose this is rare enough that it doesn'matter to most users. I personally use hippie-expand for filenames in the REPL, but that's a habit. But if you dig down into comint-filename-completion you'll probably find the culprit.

Ambrevar commented 3 years ago

I tried hippie-expand on a file with a double quote and it isn't escaped either. Does it escape for you?

joaotavora commented 3 years ago

Does it escape for you?

I don't know, I don't have an Emacs here. I'd suppose not. Only now to I see the what you're trying to achieve. You want the correct escaping for the syntax of the language you are typing. I think you have to add some escaping thing to sly-complete-filename-maybe. If I'm following you correctly...

Ambrevar commented 3 years ago

Yes, I think we are on the same page.

I just don't see the difference between shell-mode and sly-mrepl-mode. I need to investigate more.