Font setting for runemacs and frame

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

Font setting for runemacs and frame

Shuguang Sun-2
The following message is a courtesy copy of an article
that has been posted to gmane.emacs.help as well.

Hi,

I have some font setting in my dot emacs, however, it doesn't work
unless after some frame action.

My font setting
```
(cl-pushnew '(w32 (font . "Consolas-16")
                  (fullscreen . maximized))
            window-system-default-frame-alist)

(defun frame-setting (&optional frame)
  (when (display-graphic-p)
    (message "display-graphic-p"))
  (message "frame-setting call")
  (let ((frame (or frame (selected-frame))))
    (message "frame: %s" frame)
    (if (string-equal system-type "windows-nt")
     (dolist (charset '(kana han cjk-misc bopomofo chinese-gbk gb18030))
          (set-fontset-font nil charset
                              (font-spec :family "Microsoft Yahei")
                              frame 'prepend)))))

;; set the font after make frame
(add-hook 'after-make-frame-functions #'frame-setting)
```

And some hooks in after-init-hook
```
(if (not (daemonp))
    (progn
      (message "frame-setting in non-daemon")
      (frame-setting)))
```

The function-setting actually is called.

In case of
```
emacsclientw.exe --alternate-editor= -n -e "(raise-frame )"
```
it messages: frame-setting call

However the font setting make no effect in case of simply run
runemacs.exe, it messages:

frame-setting in non-daemon
display-graphic-p
frame-setting call
frame: #<frame emacs@RSHMX11052 00000000037b6e90>


Is it due to the window-system-default-frame-alist which might flush all
the font setting?


--
Best Regards
Shuguang Sun



Reply | Threaded
Open this post in threaded view
|

Re: Font setting for runemacs and frame

Eli Zaretskii
> From: Shuguang Sun <[hidden email]>
> Cc: [hidden email]
> Date: Tue, 12 Feb 2019 18:03:44 +0800
>
> However the font setting make no effect in case of simply run
> runemacs.exe, it messages:
>
> frame-setting in non-daemon
> display-graphic-p
> frame-setting call
> frame: #<frame emacs@RSHMX11052 00000000037b6e90>

For runemacs, why don't you just use default-frame-alist?

Reply | Threaded
Open this post in threaded view
|

Re: Font setting for runemacs and frame

Shuguang Sun-2
Eli Zaretskii <[hidden email]> writes:

>
> For runemacs, why don't you just use default-frame-alist?
>
>

I use window-system-default-frame-alist trying to manage one dot.emacs
for both windows box and linux. It seems both default-frame-alist and
window-system-default-frame-alist will flush the font setting.

I need set different font according to the fontset, and it seems neither
default-frame-alist nor window-system-default-frame-alist is able to
make it.


--
Best Regards
Shuguang Sun



Reply | Threaded
Open this post in threaded view
|

Re: Font setting for runemacs and frame

Eli Zaretskii
> From: Shuguang Sun <[hidden email]>
> Cc: [hidden email]
> Date: Wed, 13 Feb 2019 11:27:23 +0800
>
> Eli Zaretskii <[hidden email]> writes:
>
> > For runemacs, why don't you just use default-frame-alist?
>
> I use window-system-default-frame-alist trying to manage one dot.emacs
> for both windows box and linux. It seems both default-frame-alist and
> window-system-default-frame-alist will flush the font setting.

Sorry, I don't think I follow: what do you mean by "flush"?  Can you
show what you tried with default-frame-alist, and describe the
effects?

> I need set different font according to the fontset, and it seems neither
> default-frame-alist nor window-system-default-frame-alist is able to
> make it.

Fontsets are the way to customize fonts more flexibly, so I don't
think I understand what you mean by "different font according to the
fontset".  Again, showing what you do or tried but didn't work, will
help remove any misunderstanding.

I'm asking all these questions because it sounds like you
unnecessarily use very complicated means, where much simpler means
exist that should allow you to do what you want.

Reply | Threaded
Open this post in threaded view
|

Re: Font setting for runemacs and frame

Shuguang Sun-2
Eli Zaretskii <[hidden email]> writes:

>> From: Shuguang Sun <[hidden email]>
>> Cc: [hidden email]
>> Date: Wed, 13 Feb 2019 11:27:23 +0800
>>
>> Eli Zaretskii <[hidden email]> writes:
>>
>> > For runemacs, why don't you just use default-frame-alist?
>>
>> I use window-system-default-frame-alist trying to manage one dot.emacs
>> for both windows box and linux. It seems both default-frame-alist and
>> window-system-default-frame-alist will flush the font setting.
>
> Sorry, I don't think I follow: what do you mean by "flush"?  Can you
> show what you tried with default-frame-alist, and describe the
> effects?
>

(cl-pushnew '(w32 (font . "Consolas-16"))
            window-system-default-frame-alist)

or

(add-to-list 'default-frame-alist '(font . "Consolas-16"))

To set the default font as Consolas-16 in w32 system.

>> I need set different font according to the fontset, and it seems neither
>> default-frame-alist nor window-system-default-frame-alist is able to
>> make it.
>
> Fontsets are the way to customize fonts more flexibly, so I don't
> think I understand what you mean by "different font according to the
> fontset".  Again, showing what you do or tried but didn't work, will
> help remove any misunderstanding.
>
> I'm asking all these questions because it sounds like you
> unnecessarily use very complicated means, where much simpler means
> exist that should allow you to do what you want.
>
>

To specify font for fontset, cjk etc., I use the code below and actually
make it a function and call it in after-make-frame-functions (new frame
in daemon mode) or call it after-init-hook (intended for runemacs with
`if (not (daemonp))`).

(dolist (charset '(kana han cjk-misc bopomofo chinese-gbk gb18030))
  (set-fontset-font nil charset
                    (font-spec :family "Microsoft Yahei")
                    nil 'prepend))

However with the setting of window-system-default-frame-alist or
default-frame-alist above, it takes no effect until I make a new frame
(after-make-frame-functions). Emacs takes font for the fontsets above
according to Windows font fallbacks, e.g., MS Gothic.


Finally, I find that if I put `(set-frame-font "Consolas-16" nil t)` in
my dot.emacs, the font setting for above fontsets works in runemacs case
without additional frame make action.


--
Best Regards
Shuguang Sun

Reply | Threaded
Open this post in threaded view
|

Re: Font setting for runemacs and frame

Eli Zaretskii
> From: Shuguang Sun <[hidden email]>
> Cc: [hidden email]
> Date: Wed, 13 Feb 2019 13:08:06 +0800
>
> (cl-pushnew '(w32 (font . "Consolas-16"))
>             window-system-default-frame-alist)
>
> or
>
> (add-to-list 'default-frame-alist '(font . "Consolas-16"))
>
> To set the default font as Consolas-16 in w32 system.

This will only work for frames other than the first frame.

> To specify font for fontset, cjk etc., I use the code below and actually
> make it a function and call it in after-make-frame-functions (new frame
> in daemon mode) or call it after-init-hook (intended for runemacs with
> `if (not (daemonp))`).
>
> (dolist (charset '(kana han cjk-misc bopomofo chinese-gbk gb18030))
>   (set-fontset-font nil charset
>                     (font-spec :family "Microsoft Yahei")
>                     nil 'prepend))

Why do you need to call this in a hook?  Why not just at top level of
your .emacs file?

> However with the setting of window-system-default-frame-alist or
> default-frame-alist above, it takes no effect until I make a new frame
> (after-make-frame-functions).

This is documented behavior: to modify the looks ofg the first frame,
you need to set initial-frame-alist in addition to
default-frame-alist.

Reply | Threaded
Open this post in threaded view
|

Re: Font setting for runemacs and frame

Shuguang Sun-2
Eli Zaretskii <[hidden email]> writes:

>> From: Shuguang Sun <[hidden email]>
>> Cc: [hidden email]
>> Date: Wed, 13 Feb 2019 13:08:06 +0800
>>
>> (cl-pushnew '(w32 (font . "Consolas-16"))
>>             window-system-default-frame-alist)
>>
>> or
>>
>> (add-to-list 'default-frame-alist '(font . "Consolas-16"))
>>
>> To set the default font as Consolas-16 in w32 system.
>
> This will only work for frames other than the first frame.
>
>> To specify font for fontset, cjk etc., I use the code below and actually
>> make it a function and call it in after-make-frame-functions (new frame
>> in daemon mode) or call it after-init-hook (intended for runemacs with
>> `if (not (daemonp))`).
>>
>> (dolist (charset '(kana han cjk-misc bopomofo chinese-gbk gb18030))
>>   (set-fontset-font nil charset
>>                     (font-spec :family "Microsoft Yahei")
>>                     nil 'prepend))
>
> Why do you need to call this in a hook?  Why not just at top level of
> your .emacs file?

Years ago, it didn't work for server or daemon, and I tried the hook way.
Now it seems to work well.

>
>> However with the setting of window-system-default-frame-alist or
>> default-frame-alist above, it takes no effect until I make a new frame
>> (after-make-frame-functions).
>
> This is documented behavior: to modify the looks ofg the first frame,
> you need to set initial-frame-alist in addition to
> default-frame-alist.
>
>
Thanks! Now I understand.

--
Best Regards
Shuguang Sun



Reply | Threaded
Open this post in threaded view
|

Re: Font setting for runemacs and frame

Robert Pluim
In reply to this post by Eli Zaretskii
Eli Zaretskii <[hidden email]> writes:

>> However with the setting of window-system-default-frame-alist or
>> default-frame-alist above, it takes no effect until I make a new frame
>> (after-make-frame-functions).
>
> This is documented behavior: to modify the looks ofg the first frame,
> you need to set initial-frame-alist in addition to
> default-frame-alist.

The docstring for 'initial-frame-alist' says:

    Parameters specified here supersede the values given in
    `default-frame-alist'.

which certainly reads to me like 'configure only default-frame-alist
if you want all frames including the initial one to be identical'.

Robert

Reply | Threaded
Open this post in threaded view
|

Re: Font setting for runemacs and frame

Eli Zaretskii
> From: Robert Pluim <[hidden email]>
> Cc: [hidden email]
> Date: Thu, 14 Feb 2019 16:40:44 +0100
>
> > This is documented behavior: to modify the looks ofg the first frame,
> > you need to set initial-frame-alist in addition to
> > default-frame-alist.
>
> The docstring for 'initial-frame-alist' says:
>
>     Parameters specified here supersede the values given in
>     `default-frame-alist'.
>
> which certainly reads to me like 'configure only default-frame-alist
> if you want all frames including the initial one to be identical'.

Oops, I stand corrected.  I guess the problem was that the alist was
set in a hook rather than directly.

Reply | Threaded
Open this post in threaded view
|

Re: Font setting for runemacs and frame

Robert Pluim
Eli Zaretskii <[hidden email]> writes:

>> From: Robert Pluim <[hidden email]>
>> Cc: [hidden email]
>> Date: Thu, 14 Feb 2019 16:40:44 +0100
>>
>> > This is documented behavior: to modify the looks ofg the first frame,
>> > you need to set initial-frame-alist in addition to
>> > default-frame-alist.
>>
>> The docstring for 'initial-frame-alist' says:
>>
>>     Parameters specified here supersede the values given in
>>     `default-frame-alist'.
>>
>> which certainly reads to me like 'configure only default-frame-alist
>> if you want all frames including the initial one to be identical'.
>
> Oops, I stand corrected.  I guess the problem was that the alist was
> set in a hook rather than directly.

I donʼt know. I haven't tested initial-frame-alist vs
default-frame-alist, perhaps the docstring is wrong.

Robert

Reply | Threaded
Open this post in threaded view
|

Re: Font setting for runemacs and frame

Robert Pluim
Robert Pluim <[hidden email]> writes:

> I donʼt know. I haven't tested initial-frame-alist vs
> default-frame-alist, perhaps the docstring is wrong.

The docstring is correct: default-frame-alist applies to the initial
frame in the absence of an initial-frame-alist setting (in normal
startup mode, Iʼve not tested daemon mode).

Robert

Reply | Threaded
Open this post in threaded view
|

Re: Font setting for runemacs and frame

Shuguang Sun-2
In reply to this post by Eli Zaretskii
Eli Zaretskii <[hidden email]> writes:

>> From: Shuguang Sun <[hidden email]>
>> Cc: [hidden email]
>> Date: Wed, 13 Feb 2019 13:08:06 +0800
>>
>> (cl-pushnew '(w32 (font . "Consolas-16"))
>>             window-system-default-frame-alist)
>>
>> or
>>
>> (add-to-list 'default-frame-alist '(font . "Consolas-16"))
>>
>> To set the default font as Consolas-16 in w32 system.
>
> This will only work for frames other than the first frame.
>
>> To specify font for fontset, cjk etc., I use the code below and actually
>> make it a function and call it in after-make-frame-functions (new frame
>> in daemon mode) or call it after-init-hook (intended for runemacs with
>> `if (not (daemonp))`).
>>
>> (dolist (charset '(kana han cjk-misc bopomofo chinese-gbk gb18030))
>>   (set-fontset-font nil charset
>>                     (font-spec :family "Microsoft Yahei")
>>                     nil 'prepend))
>
> Why do you need to call this in a hook?  Why not just at top level of
> your .emacs file?
>

Sorry for wrong information in last message. Actually the font setting
code above doesn't work in daemon.

runemacs --daemon
OR
 ./emacsclientw.exe --alternate-editor= -n -e "(raise-frame )" &

Then a popup window with:
```
A fatal error has occurred!

....

(type "gdb -p <emacs-PID>" and "continue" inside GDB before clicking YES.)
```

The GDB information:
```
# gdb -p 157284
GNU gdb (GDB) 7.12.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-msys".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
Traceback (most recent call last):
  File "<string>", line 3, in <module>
ImportError: No module named libstdcxx.v6.printers
/etc/gdbinit:6: Error in sourced command file:
Error while executing Python code.
Attaching to process 157284
[New Thread 157284.0x26ed8]
[New Thread 157284.0x3374]
[New Thread 157284.0x702c]
Reading symbols from /c/Users/suns18/emacs/bin/emacsclientw...done.
(gdb) continue
Continuing.
[Thread 157284.0x702c exited with code 0]

Thread 1 received signal SIGINT, Interrupt.
[Switching to Thread 157284.0x26ed8]
0x000000010041440f in ?? ()
(gdb)
Continuing.
[Inferior 1 (process 157284) exited with code 02]
(gdb)
(gdb) q
[1]+  Interrupt               ./emacsclientw.exe --alternate-editor= -n -e "(raise-frame )"
```


Backtrace:
000000040018a4e4
00000004000a86f1
00000004000c0316
00000004000c0f94
00000004001def84
00007ffb7240639e
00007ffb72419ff5
00007ffb723a51c0
00007ffb72419076
00000004001bfd4f
00000004001bfdce
0000000400122af3
00000004001213ba
0000000400157318
0000000400123cec
0000000400121338
0000000400157318
0000000400159bb6
000000040012379d
00000004001478af
00000004001480df
0000000400122af3
00000004001213ba
0000000400157318
0000000400123cec
0000000400121338
0000000400157318
0000000400123cec
0000000400121338
0000000400157318
0000000400123cec
00000004001231ba
00000004001234eb
0000000400125253
0000000400120585
00000004000a9945
00000004001204f3
00000004000a8c82
00000004000adf58
00000004000ae29d
00000004001ef085
000000040000139d
0000000400001503
00007ffb7008277c
00007ffb723c0c49


>> However with the setting of window-system-default-frame-alist or
>> default-frame-alist above, it takes no effect until I make a new frame
>> (after-make-frame-functions).
>
> This is documented behavior: to modify the looks ofg the first frame,
> you need to set initial-frame-alist in addition to
> default-frame-alist.
>
>

--
Best Regards
Shuguang Sun



Reply | Threaded
Open this post in threaded view
|

Re: Font setting for runemacs and frame

Eli Zaretskii
> From: Shuguang Sun <[hidden email]>
> Cc: [hidden email]
> Date: Fri, 15 Feb 2019 18:01:24 +0800
>
> runemacs --daemon
> OR
>  ./emacsclientw.exe --alternate-editor= -n -e "(raise-frame )" &
>
> Then a popup window with:
> ```
> A fatal error has occurred!

Please submit a bug report about this with all the relevant
information, especially your font customizations.  Preferably, please
include with the bug report a minimal .emacs file that still
reproduces the problem for you.

> Reading symbols from /c/Users/suns18/emacs/bin/emacsclientw...done.
> (gdb) continue

You've attached GDB to the wrong process: the problem happens in
Emacs, not in emacsclientw.

Also, why did you end your emacsclientw command with a "&"?  This is a
Unix thing, not a Windows thing.  Which shell are you using, and how
does it interpret the trailing "&"?

Reply | Threaded
Open this post in threaded view
|

next new frame's height after initial frame (Was: Font setting for runemacs and frame)

Van L
In reply to this post by Eli Zaretskii


>
>>> However with the setting of window-system-default-frame-alist or
>>> default-frame-alist above, it takes no effect until I make a new frame
>>> (after-make-frame-functions).
>>
>> This is documented behavior: to modify the looks ofg the first frame,
>> you need to set initial-frame-alist in addition to
>> default-frame-alist.
>>

On 26.1; NetBSD-8, a problem I have is setting the next new frame's
height to 25 after the initial frame. I get a default height of 4.

The settings I have include:

   c) Default Frame Alist: (height 25)
   d) Initial Frame Alist: (height 25)
   e) Pop Up Frame Alist: (height 25)
   f) Special Display Frame Alist: (height 14)
   a) window-safe-min-height: 1
   b) Window Min Height: 4

If I set either a) or b) directly I confuse the Minibuffer Frame's display.

Is the problem due to app default for X's resources?

How to make it do
the right thing?

--
© 2019 Van L
gpg using EEF2 37E9 3840 0D5D 9183  251E 9830 384E 9683 B835
"What's so strange when you know that you're a Wizard at 3?" -Joni Mitchell