Subject: bug#25228: 25.1; GNU emacs 25.1: custom-set-faces from init file ~/.emacs ignored

From: martin rudalics <[email-masked]>
Date: Tue, 20 Dec 2016 11:59:52 +0100

> Can you describe how that mechanism is triggered by the offending
 > change?

Which one is "the offending change"?  If you reread the thread, you will
see that there are controversial opinions.  Anyway, here we go.

I use a file /home/martin/temp/default-face.el with the following
contents:

(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
  '(default ((t (:inherit nil :stipple nil :background "grey92" :foreground "black" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 98 :width normal :foundry "unknown" :family "Droid Sans Mono")))))

The ":height 98" entry in this form before the offending change did set
the "height of the default face in 1/10 pt" to 98.  After the offending
change it is set to 113.  I have no idea what a "pt" is (and I have no
idea what an "inch" is).  But from experience I know that the value of
`window-font-height' for the root window of the initial frame is 15 for
a default face height of 98 and 18 for a default face height of 113.

As a consequence of the offending change, the frame character height of
my initial frame is now 18 instead of the desired 15.  In the following
I will try to explain how this happened here.

[Werner - if you read this, please try to repeat it, maybe you get a
completely different behavior.  I gdb one of my current versions of a
GTK build of master, so the line numbers may be off wrt what you have
(unfortunately, debugging the release version freezes GNU/Linux
completely here and I have to turn off the power in order to restart
it).]

I first visit the file xsettings.c in the .src directory and start the
debugger via M-x gdb completing it to

gdb -i=mi /home/martin/emacs-git/quick/obj-gtk/src/emacs

which includes the path of my GTK executable.  Next in xsettings.c I
move to line 611 which reads as

   memset (&oldsettings, 0, sizeof (oldsettings));

and set a breakpoint there.  Then I run the executable via

run -Q --load /home/martin/temp/default-face.el

and wait till the breakpoint is hit.  In the function where I set the
breakpoint (apply_xft_settings) I now want to trigger the setting of the
variable

       changed = true;

I do this by stepping via "n" and find that it happens on line 675
because of oldsettings.dpi != settings->dpi: The old value was
96.281588447653434 while the new value is 96.  As a consequence, on line
701 a

       store_config_changed_event (Qfont_render,
				  XCAR (dpyinfo->name_list_element));

will store an event in my event queue whose execution will eventually
trigger the offending change.  The backtrace till here is:

#0  apply_xft_settings (dpyinfo=0xef1230, settings=0x7fffffffb280) at ../../src/xsettings.c:702
#1  0x000000000056bc31 in read_and_apply_settings (dpyinfo=0xef1230, send_event_p=false) at ../../src/xsettings.c:726
#2  0x000000000056c073 in init_xsettings (dpyinfo=0xef1230) at ../../src/xsettings.c:938
#3  0x000000000056c0ae in xsettings_initialize (dpyinfo=0xef1230) at ../../src/xsettings.c:948
#4  0x00000000005508f6 in x_term_init (display_name=..., xrm_option=0x0, resource_name=0xe38010 "emacs") at ../../src/xterm.c:12617
#5  0x000000000055b6bc in Fx_open_connection (display=..., xrm_string=..., must_succeed=...) at ../../src/xfns.c:5257
#6  0x000000000063500e in Ffuncall (nargs=4, args=0x7fffffffba50) at ../../src/eval.c:2722
#7  0x00000000006829ce in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=0, args=0x7fffffffc458) at ../../src/bytecode.c:639
#8  0x0000000000635993 in funcall_lambda (fun=..., nargs=0, arg_vector=0x7fffffffc458) at ../../src/eval.c:2879
#9  0x0000000000635215 in Ffuncall (nargs=1, args=0x7fffffffc450) at ../../src/eval.c:2764
#10 0x0000000000633c4a in Fapply (nargs=2, args=0x7fffffffc450) at ../../src/eval.c:2296
#11 0x0000000000634e71 in Ffuncall (nargs=3, args=0x7fffffffc448) at ../../src/eval.c:2695
#12 0x00000000006829ce in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=0, args=0x7fffffffcbf0) at ../../src/bytecode.c:639
#13 0x0000000000635993 in funcall_lambda (fun=..., nargs=0, arg_vector=0x7fffffffcbf0) at ../../src/eval.c:2879
#14 0x0000000000635215 in Ffuncall (nargs=1, args=0x7fffffffcbe8) at ../../src/eval.c:2764
#15 0x00000000006829ce in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=0, args=0x7fffffffda88) at ../../src/bytecode.c:639
#16 0x0000000000635993 in funcall_lambda (fun=..., nargs=0, arg_vector=0x7fffffffda88) at ../../src/eval.c:2879
#17 0x0000000000635215 in Ffuncall (nargs=1, args=0x7fffffffda80) at ../../src/eval.c:2764
#18 0x00000000006829ce in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=0, args=0x7fffffffe2c0) at ../../src/bytecode.c:639
#19 0x0000000000635993 in funcall_lambda (fun=..., nargs=0, arg_vector=0x7fffffffe2c0) at ../../src/eval.c:2879
#20 0x00000000006355dd in apply_lambda (fun=..., args=..., count=4) at ../../src/eval.c:2816
#21 0x000000000063391b in eval_sub (form=...) at ../../src/eval.c:2233
#22 0x0000000000632d15 in Feval (form=..., lexical=...) at ../../src/eval.c:2010
#23 0x0000000000582abe in top_level_2 () at ../../src/keyboard.c:1127
#24 0x000000000063126a in internal_condition_case (bfun=0x582aa1 <top_level_2>, handlers=..., hfun=0x5824c2 <cmd_error>) at ../../src/eval.c:1314
#25 0x0000000000582aff in top_level_1 (ignore=...) at ../../src/keyboard.c:1135
#26 0x00000000006307f8 in internal_catch (tag=..., func=0x582ac0 <top_level_1>, arg=...) at ../../src/eval.c:1080
#27 0x00000000005829f9 in command_loop () at ../../src/keyboard.c:1096
#28 0x0000000000581fd6 in recursive_edit_1 () at ../../src/keyboard.c:703
#29 0x00000000005821b5 in Frecursive_edit () at ../../src/keyboard.c:774
#30 0x000000000057ff33 in main (argc=4, argv=0x7fffffffe8a8) at ../../src/emacs.c:1659

Lisp Backtrace:
"x-open-connection" (0xffffba58)
0x13cc630 PVEC_COMPILED
"apply" (0xffffc450)
"window-system-initialization" (0xffffcbf0)
"command-line" (0xffffda88)
"normal-top-level" (0xffffe2c0)
(gdb)

Now I set a breakpoint in the function x_new_font of xterm.c at the
beginning of the line

FRAME_LINE_HEIGHT (f) = font_ascent + font_descent;

which is line 9829 here (yours will surely differ) and continue
debugging via "c".  After hitting the breakpoint I do

(gdb) p font_ascent + font_descent
$11 = 18

This is not the value I wanted via my customizations - I want a value of
15.  So I continue until I get the desired value via

(gdb) p font_ascent + font_descent
$13 = 15

The backtrace till here is

#0  x_new_font (f=0x1423860, font_object=..., fontset=21) at ../../src/xterm.c:9829
#1  0x0000000000430a53 in x_set_font (f=0x1423860, arg=..., oldval=...) at ../../src/frame.c:3749
#2  0x000000000042e809 in x_set_frame_parameters (f=0x1423860, alist=...) at ../../src/frame.c:3342
#3  0x000000000042d1b6 in Fmodify_frame_parameters (frame=..., alist=...) at ../../src/frame.c:2801
#4  0x000000000052fe9a in set_font_frame_param (frame=..., lface=...) at ../../src/xfaces.c:3328
#5  0x000000000052f65b in Finternal_set_lisp_face_attribute (face=..., attr=..., value=..., frame=...) at ../../src/xfaces.c:3142
#6  0x0000000000635051 in Ffuncall (nargs=5, args=0x7fffffff7ca0) at ../../src/eval.c:2726
#7  0x00000000006829ce in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=32, args=0x7fffffff84c8) at ../../src/bytecode.c:639
#8  0x0000000000635993 in funcall_lambda (fun=..., nargs=32, arg_vector=0x7fffffff84b8) at ../../src/eval.c:2879
#9  0x0000000000635215 in Ffuncall (nargs=33, args=0x7fffffff84b0) at ../../src/eval.c:2764
#10 0x0000000000634271 in Fapply (nargs=4, args=0x7fffffff87a0) at ../../src/eval.c:2343
#11 0x0000000000634e71 in Ffuncall (nargs=5, args=0x7fffffff8798) at ../../src/eval.c:2695
#12 0x00000000006829ce in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=3, args=0x7fffffff8f58) at ../../src/bytecode.c:639
#13 0x0000000000635993 in funcall_lambda (fun=..., nargs=3, arg_vector=0x7fffffff8f40) at ../../src/eval.c:2879
#14 0x0000000000635215 in Ffuncall (nargs=4, args=0x7fffffff8f38) at ../../src/eval.c:2764
#15 0x00000000006829ce in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=2, args=0x7fffffff9728) at ../../src/bytecode.c:639
#16 0x0000000000635993 in funcall_lambda (fun=..., nargs=2, arg_vector=0x7fffffff9718) at ../../src/eval.c:2879
#17 0x0000000000635215 in Ffuncall (nargs=3, args=0x7fffffff9710) at ../../src/eval.c:2764
#18 0x00000000006829ce in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=3, args=0x7fffffff9eb8) at ../../src/bytecode.c:639
#19 0x0000000000635993 in funcall_lambda (fun=..., nargs=3, arg_vector=0x7fffffff9ea0) at ../../src/eval.c:2879
#20 0x0000000000635215 in Ffuncall (nargs=4, args=0x7fffffff9e98) at ../../src/eval.c:2764
#21 0x00000000006829ce in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=0, args=0x0) at ../../src/bytecode.c:639
#22 0x0000000000635e3a in funcall_lambda (fun=..., nargs=2, arg_vector=0xa1a5d5) at ../../src/eval.c:2945
#23 0x0000000000635215 in Ffuncall (nargs=3, args=0x7fffffffa850) at ../../src/eval.c:2764
#24 0x0000000000633cc6 in Fapply (nargs=3, args=0x7fffffffa850) at ../../src/eval.c:2300
#25 0x0000000000634e71 in Ffuncall (nargs=4, args=0x7fffffffa848) at ../../src/eval.c:2695
#26 0x00000000006829ce in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=0, args=0x0) at ../../src/bytecode.c:639
#27 0x0000000000635e3a in funcall_lambda (fun=..., nargs=1, arg_vector=0xa1a47d) at ../../src/eval.c:2945
#28 0x00000000006355dd in apply_lambda (fun=..., args=..., count=37) at ../../src/eval.c:2816
#29 0x000000000063391b in eval_sub (form=...) at ../../src/eval.c:2233
#30 0x0000000000669c55 in readevalloop_eager_expand_eval (val=..., macroexpand=...) at ../../src/lread.c:1759
#31 0x000000000066a3ab in readevalloop (readcharfun=..., stream=0x0, sourcename=..., printflag=false, unibyte=..., readfun=..., start=..., end=...) at ../../src/lread.c:1927
#32 0x000000000066a715 in Feval_buffer (buffer=..., printflag=..., filename=..., unibyte=..., do_allow_print=...) at ../../src/lread.c:1993
#33 0x000000000063509f in Ffuncall (nargs=6, args=0x7fffffffb358) at ../../src/eval.c:2731
#34 0x00000000006829ce in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=0, args=0x0) at ../../src/bytecode.c:639
#35 0x0000000000635e3a in funcall_lambda (fun=..., nargs=4, arg_vector=0x9d2c5d) at ../../src/eval.c:2945
#36 0x0000000000635215 in Ffuncall (nargs=5, args=0x7fffffffbb90) at ../../src/eval.c:2764
#37 0x0000000000634a2f in call4 (fn=..., arg1=..., arg2=..., arg3=..., arg4=...) at ../../src/eval.c:2599
#38 0x0000000000668641 in Fload (file=..., noerror=..., nomessage=..., nosuffix=..., must_suffix=...) at ../../src/lread.c:1278
#39 0x000000000063509f in Ffuncall (nargs=4, args=0x7fffffffc000) at ../../src/eval.c:2731
#40 0x00000000006829ce in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=1, args=0x7fffffffcbf8) at ../../src/bytecode.c:639
#41 0x0000000000635993 in funcall_lambda (fun=..., nargs=1, arg_vector=0x7fffffffcbf0) at ../../src/eval.c:2879
#42 0x0000000000635215 in Ffuncall (nargs=2, args=0x7fffffffcbe8) at ../../src/eval.c:2764
#43 0x00000000006829ce in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=0, args=0x7fffffffda88) at ../../src/bytecode.c:639
#44 0x0000000000635993 in funcall_lambda (fun=..., nargs=0, arg_vector=0x7fffffffda88) at ../../src/eval.c:2879
#45 0x0000000000635215 in Ffuncall (nargs=1, args=0x7fffffffda80) at ../../src/eval.c:2764
#46 0x00000000006829ce in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=0, args=0x7fffffffe2c0) at ../../src/bytecode.c:639
#47 0x0000000000635993 in funcall_lambda (fun=..., nargs=0, arg_vector=0x7fffffffe2c0) at ../../src/eval.c:2879
#48 0x00000000006355dd in apply_lambda (fun=..., args=..., count=4) at ../../src/eval.c:2816
#49 0x000000000063391b in eval_sub (form=...) at ../../src/eval.c:2233
#50 0x0000000000632d15 in Feval (form=..., lexical=...) at ../../src/eval.c:2010
#51 0x0000000000582abe in top_level_2 () at ../../src/keyboard.c:1127
#52 0x000000000063126a in internal_condition_case (bfun=0x582aa1 <top_level_2>, handlers=..., hfun=0x5824c2 <cmd_error>) at ../../src/eval.c:1314
#53 0x0000000000582aff in top_level_1 (ignore=...) at ../../src/keyboard.c:1135
#54 0x00000000006307f8 in internal_catch (tag=..., func=0x582ac0 <top_level_1>, arg=...) at ../../src/eval.c:1080
#55 0x00000000005829f9 in command_loop () at ../../src/keyboard.c:1096
#56 0x0000000000581fd6 in recursive_edit_1 () at ../../src/keyboard.c:703
#57 0x00000000005821b5 in Frecursive_edit () at ../../src/keyboard.c:774
#58 0x000000000057ff33 in main (argc=4, argv=0x7fffffffe8a8) at ../../src/emacs.c:1659

Lisp Backtrace:
"internal-set-lisp-face-attribute" (0xffff7ca8)
"set-face-attribute" (0xffff84b8)
"apply" (0xffff87a0)
"face-spec-set-2" (0xffff8f40)
"face-spec-recalc" (0xffff9718)
"face-spec-set" (0xffff9ea0)
"custom-theme-set-faces" (0xffffa858)
"apply" (0xffffa850)
"custom-set-faces" (0xffffae90)
"eval-buffer" (0xffffb360)
"load-with-code-conversion" (0xffffbb98)
"load" (0xffffc008)
"command-line-1" (0xffffcbf0)
"command-line" (0xffffda88)
"normal-top-level" (0xffffe2c0)
(gdb)

So it's easy to see that my `custom-set-faces' got applied and I could
be happy.  However, typing "c" again will, unfortunately, reveal that my
customized settings get overruled by the earlier seen

(gdb) p font_ascent + font_descent
$14 = 18

The associated backtrace is now

#0  x_new_font (f=0x1423860, font_object=..., fontset=2) at ../../src/xterm.c:9829
#1  0x0000000000430a53 in x_set_font (f=0x1423860, arg=..., oldval=...) at ../../src/frame.c:3749
#2  0x000000000042e809 in x_set_frame_parameters (f=0x1423860, alist=...) at ../../src/frame.c:3342
#3  0x000000000042d1b6 in Fmodify_frame_parameters (frame=..., alist=...) at ../../src/frame.c:2801
#4  0x000000000052fe9a in set_font_frame_param (frame=..., lface=...) at ../../src/xfaces.c:3328
#5  0x000000000052f65b in Finternal_set_lisp_face_attribute (face=..., attr=..., value=..., frame=...) at ../../src/xfaces.c:3142
#6  0x0000000000635051 in Ffuncall (nargs=5, args=0x7fffffffb760) at ../../src/eval.c:2726
#7  0x00000000006829ce in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=10, args=0x7fffffffbf90) at ../../src/bytecode.c:639
#8  0x0000000000635993 in funcall_lambda (fun=..., nargs=10, arg_vector=0x7fffffffbf80) at ../../src/eval.c:2879
#9  0x0000000000635215 in Ffuncall (nargs=11, args=0x7fffffffbf78) at ../../src/eval.c:2764
#10 0x00000000006829ce in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=0, args=0x0) at ../../src/bytecode.c:639
#11 0x0000000000635e3a in funcall_lambda (fun=..., nargs=2, arg_vector=0xb4f7c5) at ../../src/eval.c:2945
#12 0x0000000000635215 in Ffuncall (nargs=3, args=0x7fffffffc748) at ../../src/eval.c:2764
#13 0x00000000006829ce in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=0, args=0x0) at ../../src/bytecode.c:639
#14 0x0000000000635e3a in funcall_lambda (fun=..., nargs=1, arg_vector=0xb4f93d) at ../../src/eval.c:2945
#15 0x0000000000635215 in Ffuncall (nargs=2, args=0x7fffffffcfd8) at ../../src/eval.c:2764
#16 0x000000000062afdd in Ffuncall_interactively (nargs=2, args=0x7fffffffcfd8) at ../../src/callint.c:252
#17 0x0000000000634e71 in Ffuncall (nargs=3, args=0x7fffffffcfd0) at ../../src/eval.c:2695
#18 0x000000000062d5a0 in Fcall_interactively (function=..., record_flag=..., keys=...) at ../../src/callint.c:843
#19 0x000000000063500e in Ffuncall (nargs=4, args=0x7fffffffd488) at ../../src/eval.c:2722
#20 0x00000000006829ce in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=4, args=0x7fffffffdce8) at ../../src/bytecode.c:639
#21 0x0000000000635993 in funcall_lambda (fun=..., nargs=4, arg_vector=0x7fffffffdcc8) at ../../src/eval.c:2879
#22 0x0000000000635215 in Ffuncall (nargs=5, args=0x7fffffffdcc0) at ../../src/eval.c:2764
#23 0x0000000000634a2f in call4 (fn=..., arg1=..., arg2=..., arg3=..., arg4=...) at ../../src/eval.c:2599
#24 0x000000000058775d in read_char (commandflag=1, map=..., prev_event=..., used_mouse_menu=0x7fffffffe21f, end_time=0x0) at ../../src/keyboard.c:2854
#25 0x00000000005975a7 in read_key_sequence (keybuf=0x7fffffffe3b0, bufsize=30, prompt=..., dont_downcase_last=false, can_return_switch_frame=true, fix_current_buffer=true, prevent_redisplay=false) at ../../src/keyboard.c:9155
#26 0x0000000000583286 in command_loop_1 () at ../../src/keyboard.c:1376
#27 0x000000000063126a in internal_condition_case (bfun=0x582e50 <command_loop_1>, handlers=..., hfun=0x5824c2 <cmd_error>) at ../../src/eval.c:1314
#28 0x0000000000582a7e in command_loop_2 (ignore=...) at ../../src/keyboard.c:1118
#29 0x00000000006307f8 in internal_catch (tag=..., func=0x582a55 <command_loop_2>, arg=...) at ../../src/eval.c:1080
#30 0x0000000000582a20 in command_loop () at ../../src/keyboard.c:1097
#31 0x0000000000581fd6 in recursive_edit_1 () at ../../src/keyboard.c:703
#32 0x00000000005821b5 in Frecursive_edit () at ../../src/keyboard.c:774
#33 0x000000000057ff33 in main (argc=4, argv=0x7fffffffe8a8) at ../../src/emacs.c:1659

Lisp Backtrace:
"internal-set-lisp-face-attribute" (0xffffb768)
"set-face-attribute" (0xffffbf80)
"font-setting-change-default-font" (0xffffc750)
"dynamic-setting-handle-config-changed-event" (0xffffcfe0)
"funcall-interactively" (0xffffcfd8)
"call-interactively" (0xffffd490)
"command-execute" (0xffffdcc8)
(gdb)

It's easy to spot `dynamic-setting-handle-config-changed-event' as the
source of this.

martin