astoff / comint-mime

Display graphics and other MIME attachments in Emacs shells
66 stars 7 forks source link

comint-mime in MS Windows emacs #15

Closed chlee1126 closed 2 years ago

chlee1126 commented 2 years ago

It works when line 99 of comint-mime.el is changed: (url-filename url) --> (url-host url)

astoff commented 2 years ago

What is the value of the file variable in both cases? (You can try e.g. adding (message "=> %s" file) to line 101.)

chlee1126 commented 2 years ago

1) ..... (let ((tmp (match-beginning 1))
(url (url-generic-parse-url payload)) (file (concat (file-remote-p default-directory) (url-filename url)))) (with-temp-buffer (message "=>%s" file) (set-buffer-multibyte nil) ..... => 2) ..... (let
((tmp (match-beginning 1))
(url (url-generic-parse-url payload)) (file (concat (file-remote-p default-directory) (url-host url)))) (with-temp-buffer (message "=>%s" file) (set-buffer-multibyte nil) ..... =>c:\users\user\appdata\local\temp\tmpa533hli4

O/S: windows 10 gnu emacs: 28.1

chlee1126 commented 2 years ago

I checked some other variables as below: _=>5151 text=>{"type": "image/png"} tmpfile://C:\Users\user\AppData\Local\Temp\tmpc5dpr6c8 paylod=>tmpfile://C:\Users\user\AppData\Local\Temp\tmpc5dpr6c8 url=>#s(url tmpfile nil nil c:\users\user\appdata\local\temp\tmpc5dpr6c8 nil nil nil t nil t t)

astoff commented 2 years ago

Thanks for the info!

Can you check that the version in the fix-windows-uri branch works? You can just dump the new version of comint-mime.py into wherever Emacs originally installed this file for you.

chlee1126 commented 2 years ago

I overwrited comint-mime.py from fix-windows-uri. but It didn't work. And I checked the variables were as below: _=>5151 text =>{"type": "image/png"} tmpfile:///C:/Users/user/AppData/Local/Temp/tmpz8nk9t7x payload=>tmpfile:///C:/Users/user/AppData/Local/Temp/tmpz8nk9t7x url=>#s(url tmpfile nil nil nil /C:/Users/user/AppData/Local/Temp/tmpz8nk9t7x nil nil t nil t t) file=>/C:/Users/user/AppData/Local/Temp/tmpz8nk9t7x

I found file variable started with "/".
So I temporarily forced to remove first "/" character using substring function in comint-mime.el as below:

(let* ((tmp (match-beginning 1)) (url (url-generic-parse-url payload)) (file (concat (file-remote-p default-directory) (url-filename url))) (file (substring file 1)))

After that, I found It worked properly.

astoff commented 2 years ago

Thanks. The change you mentioned of course only works on Windows, so let me see how to do this in a way that works on any OS.

astoff commented 2 years ago

Okay, this should be fixed in the main branch (but not yet in the released ELPA version). It would be great if you could do a quick test, since I don't have access to a Windows machine.