Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
View
@@ -1,5 +1,13 @@
2012-04-27 Chong Yidong <cyd@gnu.org>
+ * startup.el (x-apply-session-resources): New function.
+
+ * term/ns-win.el (ns-initialize-window-system):
+ * term/w32-win.el (w32-initialize-window-system):
+ * 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).
+
* subr.el (read-key): Avoid running filter function when setting
up temporary tool bar entries (Bug#9922).
54 lisp/startup.el
View
@@ -905,33 +905,12 @@ Amongst another things, it parses the command-line arguments."
(run-hooks 'before-init-hook)
- ;; Under X, this creates the X frame and deletes the terminal frame.
+ ;; Under X, create the X frame and delete the terminal frame.
(unless (daemonp)
-
- ;; If X resources are available, use them to initialize the values
- ;; of `tool-bar-mode' and `menu-bar-mode', as well as the value of
- ;; `no-blinking-cursor' and the `cursor' face.
- (cond
- ((or noninteractive emacs-basic-display)
- (setq menu-bar-mode nil
- tool-bar-mode nil
- no-blinking-cursor t))
- ((memq initial-window-system '(x w32 ns))
- (let ((no-vals '("no" "off" "false" "0")))
- (if (member (x-get-resource "menuBar" "MenuBar") no-vals)
- (setq menu-bar-mode nil))
- (if (member (x-get-resource "toolBar" "ToolBar") no-vals)
- (setq tool-bar-mode nil))
- (if (member (x-get-resource "cursorBlink" "CursorBlink")
- no-vals)
- (setq no-blinking-cursor t)))
- ;; If the cursorColor X resource exists, alter the `cursor' face
- ;; spec, but mark it as changed outside of Customize.
- (let ((color (x-get-resource "cursorColor" "Foreground")))
- (when color
- (put 'cursor 'theme-face
- `((changed ((t :background ,color)))))
- (put 'cursor 'face-modified t)))))
+ (if (or noninteractive emacs-basic-display)
+ (setq menu-bar-mode nil
+ tool-bar-mode nil
+ no-blinking-cursor t))
(frame-initialize))
(when (fboundp 'x-create-frame)
@@ -1266,6 +1245,29 @@ the `--debug-init' option to view a complete error backtrace."
(with-no-warnings
(emacs-session-restore x-session-previous-id))))
+(defun x-apply-session-resources ()
+ "Apply X resources which specify initial values for Emacs variables.
+This is called from a window-system initialization function, such
+as `x-initialize-window-system' for X, either at startup (prior
+to reading the init file), or afterwards when the user first
+opens a graphical frame.
+
+This can set the values of `menu-bar-mode', `tool-bar-mode', and
+`no-blinking-cursor', as well as the `cursor' face. Changed
+settings will be marked as \"CHANGED outside of Customize\"."
+ (let ((no-vals '("no" "off" "false" "0"))
+ (settings '(("menuBar" "MenuBar" menu-bar-mode nil)
+ ("toolBar" "ToolBar" tool-bar-mode nil)
+ ("cursorBlink" "CursorBlink" no-blinking-cursor t))))
+ (dolist (x settings)
+ (if (member (x-get-resource (nth 0 x) (nth 1 x)) no-vals)
+ (set (nth 2 x) (nth 3 x)))))
+ (let ((color (x-get-resource "cursorColor" "Foreground")))
+ (when color
+ (put 'cursor 'theme-face
+ `((changed ((t :background ,color)))))
+ (put 'cursor 'face-modified t))))
+
(defcustom initial-scratch-message (purecopy "\
;; This buffer is for notes you don't want to save, and for Lisp evaluation.
;; If you want to create a file, visit that file with C-x C-f,
1  lisp/term/ns-win.el
View
@@ -923,6 +923,7 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
;; http://lists.gnu.org/archive/html/emacs-devel/2011-06/msg00505.html
(ns-set-resource nil "ApplePressAndHoldEnabled" "NO")
+ (x-apply-session-resources)
(setq ns-initialized t))
(add-to-list 'handle-args-function-alist '(ns . x-handle-args))
1  lisp/term/w32-win.el
View
@@ -309,6 +309,7 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
;; Set to a system sound if you want a fancy bell.
(set-message-beep 'ok)
+ (x-apply-session-resources)
(setq w32-initialized t))
(add-to-list 'handle-args-function-alist '(w32 . x-handle-args))
1  lisp/term/x-win.el
View
@@ -1445,6 +1445,7 @@ Request data types in the order specified by `x-select-request-type'."
;; :help "Paste (yank) text most recently cut/copied")
;; nil))
+ (x-apply-session-resources)
(setq x-initialized t))
(add-to-list 'handle-args-function-alist '(x . x-handle-args))
Please sign in to comment.
Something went wrong with that request. Please try again.