diff options
| author | Chong Yidong | 2012-02-01 16:13:02 +0800 |
|---|---|---|
| committer | Chong Yidong | 2012-02-01 16:13:02 +0800 |
| commit | 9f5626684300af96cca5c2f86c377d93173e4cab (patch) | |
| tree | 5ac60d19d7554db6cac146db5c04cf5503b4199c /lisp | |
| parent | 6035be5240d6a7fb5e39d0ef4d5d2b3b3d0b60b2 (diff) | |
| download | emacs-9f5626684300af96cca5c2f86c377d93173e4cab.tar.gz emacs-9f5626684300af96cca5c2f86c377d93173e4cab.zip | |
Fix dynamic font settings interaction with Custom Themes.
* lisp/dynamic-setting.el (font-setting-change-default-font): Use
set-frame-font.
* lisp/frame.el (set-frame-font): Tweak meaning of third argument.
Fixes: debbugs:9982
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/dynamic-setting.el | 57 | ||||
| -rw-r--r-- | lisp/frame.el | 20 |
3 files changed, 40 insertions, 44 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 1187505be67..152acc03f14 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2012-02-01 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * frame.el (set-frame-font): Tweak meaning of third argument. | ||
| 4 | |||
| 5 | * dynamic-setting.el (font-setting-change-default-font): Use | ||
| 6 | set-frame-font (Bug#9982). | ||
| 7 | |||
| 1 | 2012-02-01 Glenn Morris <rgm@gnu.org> | 8 | 2012-02-01 Glenn Morris <rgm@gnu.org> |
| 2 | 9 | ||
| 3 | * progmodes/compile.el (compilation-internal-error-properties): | 10 | * progmodes/compile.el (compilation-internal-error-properties): |
diff --git a/lisp/dynamic-setting.el b/lisp/dynamic-setting.el index e04af7800fc..e967ddce332 100644 --- a/lisp/dynamic-setting.el +++ b/lisp/dynamic-setting.el | |||
| @@ -42,45 +42,28 @@ If DISPLAY-OR-FRAME is a frame, the display is the one for that frame. | |||
| 42 | 42 | ||
| 43 | If SET-FONT is non-nil, change the font for frames. Otherwise re-apply the | 43 | If SET-FONT is non-nil, change the font for frames. Otherwise re-apply the |
| 44 | current form for the frame (i.e. hinting or somesuch changed)." | 44 | current form for the frame (i.e. hinting or somesuch changed)." |
| 45 | |||
| 46 | (let ((new-font (and (fboundp 'font-get-system-font) | 45 | (let ((new-font (and (fboundp 'font-get-system-font) |
| 47 | (font-get-system-font)))) | 46 | (font-get-system-font))) |
| 48 | (when new-font | 47 | (frame-list (frames-on-display-list display-or-frame))) |
| 49 | ;; Be careful here: when set-face-attribute is called for the | 48 | (when (and new-font (display-graphic-p display-or-frame)) |
| 50 | ;; :font attribute, Emacs tries to guess the best matching font | ||
| 51 | ;; by examining the other face attributes (Bug#2476). | ||
| 52 | |||
| 53 | (clear-font-cache) | 49 | (clear-font-cache) |
| 54 | ;; Set for current frames. Only change font for those that have | 50 | (if set-font |
| 55 | ;; the old font now. If they don't have the old font, the user | 51 | ;; Set the font on all current and future frames, as though |
| 56 | ;; probably changed it. | 52 | ;; the `default' face had been "set for this session": |
| 57 | (dolist (f (frames-on-display-list display-or-frame)) | 53 | (set-frame-font new-font nil frame-list) |
| 58 | (if (display-graphic-p f) | 54 | ;; Just redraw the existing fonts on all frames: |
| 59 | (let* ((frame-font | 55 | (dolist (f frame-list) |
| 60 | (or (font-get (face-attribute 'default :font f | 56 | (let ((frame-font |
| 61 | 'default) :user-spec) | 57 | (or (font-get (face-attribute 'default :font f 'default) |
| 62 | (frame-parameter f 'font-parameter))) | 58 | :user-spec) |
| 63 | (font-to-set | 59 | (frame-parameter f 'font-parameter)))) |
| 64 | (if set-font new-font | 60 | (when frame-font |
| 65 | ;; else set font again, hinting etc. may have changed. | 61 | (set-frame-parameter f 'font-parameter frame-font) |
| 66 | frame-font))) | 62 | (set-face-attribute 'default f |
| 67 | (if font-to-set | 63 | :width 'normal |
| 68 | (progn | 64 | :weight 'normal |
| 69 | (set-frame-parameter f 'font-parameter font-to-set) | 65 | :slant 'normal |
| 70 | (set-face-attribute 'default f | 66 | :font frame-font)))))))) |
| 71 | :width 'normal | ||
| 72 | :weight 'normal | ||
| 73 | :slant 'normal | ||
| 74 | :font font-to-set)))))) | ||
| 75 | |||
| 76 | ;; Set for future frames. | ||
| 77 | (when set-font | ||
| 78 | ;; FIXME: this is not going to play well with Custom themes. | ||
| 79 | (set-face-attribute 'default t :font new-font) | ||
| 80 | (let ((spec (list (list t (face-attr-construct 'default))))) | ||
| 81 | (put 'default 'customized-face spec) | ||
| 82 | (custom-push-theme 'theme-face 'default 'user 'set spec) | ||
| 83 | (put 'default 'face-modified nil)))))) | ||
| 84 | 67 | ||
| 85 | (defun dynamic-setting-handle-config-changed-event (event) | 68 | (defun dynamic-setting-handle-config-changed-event (event) |
| 86 | "Handle config-changed-event on the display in EVENT. | 69 | "Handle config-changed-event on the display in EVENT. |
diff --git a/lisp/frame.el b/lisp/frame.el index cf9c09b24ae..1cd6c0cf181 100644 --- a/lisp/frame.el +++ b/lisp/frame.el | |||
| @@ -1053,7 +1053,7 @@ If FRAME is omitted, describe the currently selected frame." | |||
| 1053 | 1053 | ||
| 1054 | (define-obsolete-function-alias 'set-default-font 'set-frame-font "23.1") | 1054 | (define-obsolete-function-alias 'set-default-font 'set-frame-font "23.1") |
| 1055 | 1055 | ||
| 1056 | (defun set-frame-font (font-name &optional keep-size all-frames) | 1056 | (defun set-frame-font (font-name &optional keep-size frames) |
| 1057 | "Set the default font to FONT-NAME. | 1057 | "Set the default font to FONT-NAME. |
| 1058 | When called interactively, prompt for the name of a font, and use | 1058 | When called interactively, prompt for the name of a font, and use |
| 1059 | that font on the selected frame. | 1059 | that font on the selected frame. |
| @@ -1063,9 +1063,10 @@ fixed. If KEEP-SIZE is non-nil (or with a prefix argument), try | |||
| 1063 | to keep the current frame size fixed (in pixels) by adjusting the | 1063 | to keep the current frame size fixed (in pixels) by adjusting the |
| 1064 | number of lines and columns. | 1064 | number of lines and columns. |
| 1065 | 1065 | ||
| 1066 | If ALL-FRAMES is nil, apply the font to the selected frame only. | 1066 | If FRAMES is nil, apply the font to the selected frame only. |
| 1067 | If ALL-FRAMES is non-nil, apply the font to all frames; in | 1067 | If FRAMES is non-nil, it should be a list of frames to act upon, |
| 1068 | addition, alter the user's Customization settings as though the | 1068 | or t meaning all graphical frames. Also, if FRAME is non-nil, |
| 1069 | alter the user's Customization settings as though the | ||
| 1069 | font-related attributes of the `default' face had been \"set in | 1070 | font-related attributes of the `default' face had been \"set in |
| 1070 | this session\", so that the font is applied to future frames." | 1071 | this session\", so that the font is applied to future frames." |
| 1071 | (interactive | 1072 | (interactive |
| @@ -1079,9 +1080,14 @@ this session\", so that the font is applied to future frames." | |||
| 1079 | (list font current-prefix-arg nil))) | 1080 | (list font current-prefix-arg nil))) |
| 1080 | (when (stringp font-name) | 1081 | (when (stringp font-name) |
| 1081 | (let* ((this-frame (selected-frame)) | 1082 | (let* ((this-frame (selected-frame)) |
| 1082 | (frames (if all-frames (frame-list) (list this-frame))) | 1083 | ;; FRAMES nil means affect the selected frame. |
| 1084 | (frame-list (cond ((null frames) | ||
| 1085 | (list this-frame)) | ||
| 1086 | ((eq frames t) | ||
| 1087 | (frame-list)) | ||
| 1088 | (t frames))) | ||
| 1083 | height width) | 1089 | height width) |
| 1084 | (dolist (f frames) | 1090 | (dolist (f frame-list) |
| 1085 | (when (display-multi-font-p f) | 1091 | (when (display-multi-font-p f) |
| 1086 | (if keep-size | 1092 | (if keep-size |
| 1087 | (setq height (* (frame-parameter f 'height) | 1093 | (setq height (* (frame-parameter f 'height) |
| @@ -1099,7 +1105,7 @@ this session\", so that the font is applied to future frames." | |||
| 1099 | f | 1105 | f |
| 1100 | (list (cons 'height (round height (frame-char-height f))) | 1106 | (list (cons 'height (round height (frame-char-height f))) |
| 1101 | (cons 'width (round width (frame-char-width f)))))))) | 1107 | (cons 'width (round width (frame-char-width f)))))))) |
| 1102 | (when all-frames | 1108 | (when frames |
| 1103 | ;; Alter the user's Custom setting of the `default' face, but | 1109 | ;; Alter the user's Custom setting of the `default' face, but |
| 1104 | ;; only for font-related attributes. | 1110 | ;; only for font-related attributes. |
| 1105 | (let ((specs (cadr (assq 'user (get 'default 'theme-face)))) | 1111 | (let ((specs (cadr (assq 'user (get 'default 'theme-face)))) |