bug#81489: 32.0.50; w32--terminal-is-conhost is nil in gui emacs.
TAKAHASHI Yoshio <[email protected]> Thu, 30 Jul 2026 09:24:47 +0900
| Newsgroups | gmane.emacs.bugs |
|---|---|
| Message-ID | <[email protected]> |
Eli Zaretskii <[email protected]> writes: >> Call (set-language-environment 'Japanese) at the beginning of a.el does >> not change the result, still returns 5. > > What happens if you add this at the beginning of a.el: > > (set-language-environment "English") > (set-language-environment "Japanese") > > Does that work then? No. current-column returns 5. >> My guess is: >> c-a-c-a-wide is defcustomed to t in characters.el. >> its set function is called during bootstrap. >> ambigous chars table are set to 1 because we have no window-system, >> and the table is dumped into emacs binary. >> dumped binary has c-a-c-a-wide is t, but ambigous chars' width is 1. > > That is correct, but it is not the whole story. > > When Emacs starts, startup.el calls set-locale-environment. > set-locale-environment looks at the environment variables "LC_ALL", > "LC_CTYPE", and "LANG", and uses the first one which has a non-nil > non-empty value. It then calls set-language-environment with a > language derived from the locale found in these variables. In your > case, the above should cause set-language-environment be called with > "Japanese" as the language. In Mingw64 bash console. --8<---------------cut here---------------start------------->8--- tkh:~$ echo $LC_ALL tkh:~$ echo $CL_CTYPE tkh:~$ echo $LANG ja_JP.UTF-8 tkh:~$ --8<---------------cut here---------------end--------------->8--- > If you run Emacs under GDB and put a > breakpoint in Fassoc_string (a function called by > set-language-environment), you should be able to see this call dureing > startup. > > Now, in japanese.el you will see that the Japanese > language-environment defines setup-japanese-environment-internal as > the setup function, and that function issues this call: > > (use-cjk-char-width-table 'ja_JP) > > Which should have set the character-width table according to > cjk-ambiguous-chars-are-wide, if you look at the code of > use-cjk-char-width-table. > > I wonder why this doesn't work for you during startup. Perhaps you > could look at the relevant codes and try figuring this out? There's > probably something I'm missing here, but what? These call flows are in loadup.el, and not in individual emacs startup??? > Please tell the values of the variables current-locale-environment and > current-iso639-language in a GUI session of Emacs which you built with > the patched characters.el. Also, what does 'M-: (getenv "LANG")' > produce in that session? In *scrach* buffer of gui emacs instance invoked with "emacs -Q -l ./a.el". --8<---------------cut here---------------start------------->8--- ;; This buffer is for text that is not saved, and for Lisp evaluation. ;; To create a file, visit it with C-x C-f and enter text in its buffer. current-locale-environment "ja_JP.UTF-8" current-iso639-language ja (getenv "LANG") "ja_JP.UTF-8" --8<---------------cut here---------------end--------------->8--- > In an earlier message you wrote: > >> And, my LANG is ja_JP.UTF-8. > > But ja_JP.UTF-8 is not the way Windows designates the Japanese locale. > The above looks like a Posix locale string, so I wonder where did you > get it. Is it possible that you are running Emacs from the MSYS2 Bash > window, which sets LANG to this string? Yes. I build emacs master branch and execute it in mingw64 shell. I tried to set LANG to jp_JP, but current-column still returns 5. > If so, could you please try > running from the Command Prompt window that runs cmd.exe? I'm not > sure this is relevant, but it will reduce the number of unknowns. I cd to my mingw64/bin directory to load dynamic load libraries, the result of current-column is 5. In cmd prompt. --8<---------------cut here---------------start------------->8--- C:\Users\tkh>cd c:\msys64\mingw64\bin c:\msys64\mingw64\bin>c:\opt\emacs_MINGW64\bin\emacs.exe -Q -l c:\tmp\a.el c:\msys64\mingw64\bin> --8<---------------cut here---------------end--------------->8--- >> >From characters.el comment: >> ;; MS-Windows Terminal forces all ambiguous >> ;; characters to be narrow, even in CJK locales. >> >> I'm not sure MS-Windows Terminal, what happends if a user uses font such >> as "MS Gothic" that has wide ambigous chars? >> Need to call (setopt c-a-c-a-wide t) explicitly? > > Emacs does not control the fonts used by the Windows Terminal, and you > use a GUI session, so what Windows Terminal does is for now not > relevant. The patch I sent, assuming you have rebuilt Emacs after > applying it, is supposed to make it so w32--terminal-is-conhost does > not affect GUI sessions of Emacs, only -nw sessions. Yes, this is not relavant to current gui emacs issue. I want to understand the reason emacs forces to narrow chars even if a user may set font to "MS Gothic" that has wide ambiguous chars. (I'm not for sure MS-Windows Terminal can use "MS Gothic" font or not.) -- TAKAHASHI Yoshio <[email protected]>