简体   繁体   English

EmacsMacPort(Emacs.app)无法在MacOS中加载我自己的〜/ .emacs

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

I just installed Emacs Mac Port in my MacOS from the below link. 我只是通过下面的链接在MacOS中安装了Emacs Mac Port。

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

Then I ran the below command to add Emacs.app to Launchpad in MacOS. 然后,我运行以下命令以将Emacs.app添加到MacOS中的Launchpad。

ln -s /usr/local/opt/emacs-mac/Emacs.app /Applications ln -s /usr/local/opt/emacs-mac/Emacs.app /应用程序

However everytime I click Emacs from Launchpad, it always shows with the default white background: 但是,每次我从启动板单击Emacs时,它始终显示为默认的白色背景:

.emacs无效

However when I ran emacs in iterm2, it shows with a black background: 但是,当我在iterm2中运行emacs时,它显示为黑色背景: .emacs在iterm2中生效

Why doesn't Emacs.app use my configured colours the same way as the terminal emacs? 为什么Emacs.app不使用我配置的颜色与终端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. 这是我的错,因为.emacs中的以下行仅与如何以不同的颜色显示类型,字符串,注释和函数名称有关。 And it is not related to the background color setting. 它与背景颜色设置无关。

So the background color is Black when emacs is run in iterm2. 因此,当在iterm2中运行emacs时,背景颜色为黑色 And the background color is White when Emacs.app is run. 运行Emacs.app时,背景颜色为白色 It gave me the confusion that .emacs is not read/loaded for Eamcs.app. 这使我感到困惑,因为无法为Eamcs.app读取/加载.emacs。

;; --------------------------------------
;; 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. 并且它确认.emacs在Emacs.app(又名Emacs GUI)出现之前已经被读取。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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