Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix application of menu-bar-mode etc. by X resources.

* lisp/startup.el (x-apply-session-resources): New function.

* lisp/term/ns-win.el (ns-initialize-window-system):
* lisp/term/w32-win.el (w32-initialize-window-system):
* lisp/term/x-win.el (x-initialize-window-system): Use it to properly
set menu-bar-mode and other vars from X resources, even if the initial
frame is not a window-system frame (Bug#2299).
  • Loading branch information...
commit 0931fac9b8f5ca4bdf269971389df608dbf1eddb 1 parent 169d7c0
Chong Yidong authored
8 lisp/ChangeLog
... ... @@ -1,5 +1,13 @@
1 1 2012-04-27 Chong Yidong <cyd@gnu.org>
2 2
  3 + * startup.el (x-apply-session-resources): New function.
  4 +
  5 + * term/ns-win.el (ns-initialize-window-system):
  6 + * term/w32-win.el (w32-initialize-window-system):
  7 + * term/x-win.el (x-initialize-window-system): Use it to properly
  8 + set menu-bar-mode and other vars from X resources, even if the
  9 + initial frame is not a window-system frame (Bug#2299).
  10 +
3 11 * subr.el (read-key): Avoid running filter function when setting
4 12 up temporary tool bar entries (Bug#9922).
5 13
54 lisp/startup.el
@@ -905,33 +905,12 @@ Amongst another things, it parses the command-line arguments."
905 905
906 906 (run-hooks 'before-init-hook)
907 907
908   - ;; Under X, this creates the X frame and deletes the terminal frame.
  908 + ;; Under X, create the X frame and delete the terminal frame.
909 909 (unless (daemonp)
910   -
911   - ;; If X resources are available, use them to initialize the values
912   - ;; of `tool-bar-mode' and `menu-bar-mode', as well as the value of
913   - ;; `no-blinking-cursor' and the `cursor' face.
914   - (cond
915   - ((or noninteractive emacs-basic-display)
916   - (setq menu-bar-mode nil
917   - tool-bar-mode nil
918   - no-blinking-cursor t))
919   - ((memq initial-window-system '(x w32 ns))
920   - (let ((no-vals '("no" "off" "false" "0")))
921   - (if (member (x-get-resource "menuBar" "MenuBar") no-vals)
922   - (setq menu-bar-mode nil))
923   - (if (member (x-get-resource "toolBar" "ToolBar") no-vals)
924   - (setq tool-bar-mode nil))
925   - (if (member (x-get-resource "cursorBlink" "CursorBlink")
926   - no-vals)
927   - (setq no-blinking-cursor t)))
928   - ;; If the cursorColor X resource exists, alter the `cursor' face
929   - ;; spec, but mark it as changed outside of Customize.
930   - (let ((color (x-get-resource "cursorColor" "Foreground")))
931   - (when color
932   - (put 'cursor 'theme-face
933   - `((changed ((t :background ,color)))))
934   - (put 'cursor 'face-modified t)))))
  910 + (if (or noninteractive emacs-basic-display)
  911 + (setq menu-bar-mode nil
  912 + tool-bar-mode nil
  913 + no-blinking-cursor t))
935 914 (frame-initialize))
936 915
937 916 (when (fboundp 'x-create-frame)
@@ -1266,6 +1245,29 @@ the `--debug-init' option to view a complete error backtrace."
1266 1245 (with-no-warnings
1267 1246 (emacs-session-restore x-session-previous-id))))
1268 1247
  1248 +(defun x-apply-session-resources ()
  1249 + "Apply X resources which specify initial values for Emacs variables.
  1250 +This is called from a window-system initialization function, such
  1251 +as `x-initialize-window-system' for X, either at startup (prior
  1252 +to reading the init file), or afterwards when the user first
  1253 +opens a graphical frame.
  1254 +
  1255 +This can set the values of `menu-bar-mode', `tool-bar-mode', and
  1256 +`no-blinking-cursor', as well as the `cursor' face. Changed
  1257 +settings will be marked as \"CHANGED outside of Customize\"."
  1258 + (let ((no-vals '("no" "off" "false" "0"))
  1259 + (settings '(("menuBar" "MenuBar" menu-bar-mode nil)
  1260 + ("toolBar" "ToolBar" tool-bar-mode nil)
  1261 + ("cursorBlink" "CursorBlink" no-blinking-cursor t))))
  1262 + (dolist (x settings)
  1263 + (if (member (x-get-resource (nth 0 x) (nth 1 x)) no-vals)
  1264 + (set (nth 2 x) (nth 3 x)))))
  1265 + (let ((color (x-get-resource "cursorColor" "Foreground")))
  1266 + (when color
  1267 + (put 'cursor 'theme-face
  1268 + `((changed ((t :background ,color)))))
  1269 + (put 'cursor 'face-modified t))))
  1270 +
1269 1271 (defcustom initial-scratch-message (purecopy "\
1270 1272 ;; This buffer is for notes you don't want to save, and for Lisp evaluation.
1271 1273 ;; If you want to create a file, visit that file with C-x C-f,
1  lisp/term/ns-win.el
@@ -923,6 +923,7 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
923 923 ;; http://lists.gnu.org/archive/html/emacs-devel/2011-06/msg00505.html
924 924 (ns-set-resource nil "ApplePressAndHoldEnabled" "NO")
925 925
  926 + (x-apply-session-resources)
926 927 (setq ns-initialized t))
927 928
928 929 (add-to-list 'handle-args-function-alist '(ns . x-handle-args))
1  lisp/term/w32-win.el
@@ -309,6 +309,7 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
309 309
310 310 ;; Set to a system sound if you want a fancy bell.
311 311 (set-message-beep 'ok)
  312 + (x-apply-session-resources)
312 313 (setq w32-initialized t))
313 314
314 315 (add-to-list 'handle-args-function-alist '(w32 . x-handle-args))
1  lisp/term/x-win.el
@@ -1445,6 +1445,7 @@ Request data types in the order specified by `x-select-request-type'."
1445 1445 ;; :help "Paste (yank) text most recently cut/copied")
1446 1446 ;; nil))
1447 1447
  1448 + (x-apply-session-resources)
1448 1449 (setq x-initialized t))
1449 1450
1450 1451 (add-to-list 'handle-args-function-alist '(x . x-handle-args))

0 comments on commit 0931fac

Please sign in to comment.
Something went wrong with that request. Please try again.