azhuang
azhuang

Reputation: 39

EmacsMacPort (Emacs.app) does not load my own, ~/.emacs in MacOS

I just installed Emacs Mac Port in my MacOS from the below link.

https://github.com/railwaycat/homebrew-emacsmacport

Then I ran the below command to add Emacs.app to Launchpad in MacOS.

ln -s /usr/local/opt/emacs-mac/Emacs.app /Applications

However everytime I click Emacs from Launchpad, it always shows with the default white background:

.emacs does not take effect

However when I ran emacs in iterm2, it shows with a black background: .emacs takes effect in iterm2

Why doesn't Emacs.app use my configured colours the same way as the terminal emacs?

Upvotes: 1

Views: 352

Answers (1)

azhuang
azhuang

Reputation: 39

It is my fault because the below lines within .emacs are only about how to display type, string, comment, and function name in different colors. And it is not related to the background color setting.

So the background color is Black when emacs is run in iterm2. And the background color is White when Emacs.app is run. It gave me the confusion that .emacs is not read/loaded for Eamcs.app.

;; --------------------------------------
;; Colors are applied to the source code.
;; --------------------------------------
(defun my-font-lock-setup ()
  (set-face-foreground font-lock-builtin-face           "magenta")
  (set-face-foreground font-lock-comment-face           "yellow")
  (set-face-foreground font-lock-type-face              "cyan")
  (set-face-foreground font-lock-string-face            "green")
  (set-face-foreground font-lock-keyword-face           "magenta")
  (set-face-foreground font-lock-function-name-face     "magenta")
  (set-face-foreground font-lock-function-name-face     "brightblue")
  (remove-hook 'font-lock-mode-hook 'my-font-lock-setup))

(add-hook 'font-lock-mode-hook 'my-font-lock-setup)

Then after I added the below lines to set the background color and the foreground color, it works as expected. And it confirms .emacs is already read before Emacs.app (aka Emacs GUI) appears to me.

;; ------------------------------------
;; Colors are applied to Emacs GUI.
;; ------------------------------------
(cond (window-system
       (set-mouse-color "white") ;Because of bug?
       (setq default-frame-alist
             '((background-color . "gray5")
               (foreground-color . "white")
               (cursor-color     . "Orchid")
               (mouse-color      . "green")
               (minibuffer       . t)
               (menu-bar-lines   . 1)))
       (setq initial-frame-alist default-frame-alist)))

Upvotes: 2

Related Questions