简体   繁体   中英

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无效

However when I ran emacs in iterm2, it shows with a black background: .emacs在iterm2中生效

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

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)))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM