2

My first post here about Emacs. I've spent days trying to figure out answer before posting here.

I'm running Emacs 26.1 on Windows 10. The setup that I'd like to have is running a single instance of Emacs and to be able to open files from Windows file system in Emacs. So, I'm using Emacs with server-start and connecting to it via emacsclientw.

Things work as expected except for when file names have non-latin characters in file name. For example files called māss.txt or lūk.txt. When I open such files with emacsclientw, what I get in Emacs is empty mass.txt or luk.txt buffers.

If I understand correctly, emacs/emacsclient considers that a file with such characters kind of "doesn't exist", so it visits a new file. If I save this "new" empty buffer, it gets saved as a file without those special characters, as mass.txt or luk.txt, and the original files are not touched. If I open/visit the original files from within Emacs, they can be opened and edited as expected, all the characters show up just fine.

Do I understand correctly that emacsclient simply does not support such language specific characters and for emacsclient file names must be latin characters only?

Any other pointers where I should look and what to try?

  • I can open "ア.txt" using emacsclientw.exe flawlessly, so I think emacsclient itself supports filename which contain non-latin characters. – lurdan Jan 23 at 9:56
  • I am able to reproduce the problem as you describe it. Although not a solution, here's a potential workaround. When I drag lūk.txt into an open Emacs frame, the file loads as expected. I am also able to load the file when using the find-file command (usually bound to C-x C-f). It looks like this might be relevant: gnu.org/software/emacs/manual/html_node/emacs/… – Lorem Ipsum Jan 23 at 16:27
  • How are you opening the file? Are you double-clicking on it? Are you trying to open it from the console with something like emacsclient -c lūk.txt? When I try something like emacs -q --execute "(progn (set-file-name-coding-system 'iso-8859-1) (find-file "C:\\Users\\%USERNAME%\\Documents\\lūk.txt"))", Emacs opens with the error: Symbol's value as variable is void: C:\\Users\\...\\Documents\\luk\.txt. The last part of that indicates that luk was passed to Emacs instead of lūk. This makes me think this is a Windows 10 encoding problem. – Lorem Ipsum Jan 23 at 16:42
1

This is a Windows compatibility issue. The Emacs 26 source code states,

... For similar reasons, server.el and emacsclient are also limited to the current ANSI codepage for now. ...

A full explanation of specifically what's going on is several lines up, if you're interested in the details. At the time of this writing, the same comments are reflected in the master branch of Emacs.

0

Thank you both for input and ideas! What I did after numerous trials and errors, and what works for me at this moment:

  • I changed Windows locale from US English to my local language specific. This allowed me to open, edit and save files normally via emacsclientw.
  • there was still a problem that new buffers asked me every time to choose encoding because default was not able to "understand" some characters. Setting any of the publicly discussed emacs variables (like set-default-coding-systems, prefer-coding-system, set-default buffer-file-coding-system etc.) to UTF-8 did not help, on the contrary - file names in emacs (frame title, buffer list) had my language specific characters replaced with question marks and similar. So, to solve new buffers asking to choose encoding on save, this is what I used the following (found online, not smart enough on my own yet): (setq coding-system-for-read 'utf-8) (setq coding-system-for-write 'utf-8)

@Lorem Ipsum: regarding opening of files. I want to simply press enter on a file name in file manager in Windows (Total Commander is what I'm using) and have the file opened in the existing instance of Emacs. No dragging, no mouseclicking. Although double click I assume is equal to pressing enter in this context. Never dragged any file with mouse into an application, I try to be keyboard oriented.

My aim was to use emacs as text editor and Total Commander as file manager. I'm not ready yet to leave Total Commander for dired in emacs, not sure if that makes sense for my usage.

Anyway, this seems to be solved ... for now ... I'm sure I'll be surprised by emacs again soon.

  • Changing encoding of the contents of files won't affect how file names are handled. This is an issue with windows and how it handles character encoding, and there are numerous problems (like launching processes and passing filenames with non-ASCII characters as arguments). – DoMiNeLa10 Jan 24 at 18:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.