2011-11-20 34 views
13

如果我運行的是emacs --daemon(在.xinitrc或更高版本中),然後是emacsclient -c,則新創建的幀具有黑色光標顏色,而不考慮colortheme或任何其他設置。更準確地說,在我輸入任何東西之前,光標顏色是白色(或其他顏色),但是第一個按鍵變成黑色並且不能通過set-cursor-color進行更改。默認和我的自定義colorthemes都是黑色的,所以它使編輯非常不舒服。無法在emacsclient中更改光標顏色

如果我運行emacsM-x server-start而不是emacs --daemon,則不會出現此問題。但這種方式我需要保持一個emacs「主」框架,而不是順便殺死它,這似乎不是一個很好的解決方案。

我在.emacs.d/init.el以下塊,但它並不能幫助:

(set-cursor-color "red") 
(setq initial-frame-alist '((cursor-color . "red"))) 
(setq default-frame-alist '((cursor-color . "red"))) 
(add-hook 'window-setup-hook '(lambda() (set-cursor-color "red"))) 
(add-hook 'after-make-frame-functions '(lambda (f) (with-selected-frame f (set-cursor-color "red")))) 

如果我跑M-x describe-face RET cursor我得到:

(...) 
Defined in `faces.el'. 

     Family: unspecified 
     Foundry: unspecified 
     Width: unspecified 
     Height: unspecified 
     Weight: unspecified 
     Slant: unspecified 
    Foreground: unspecified 
    Background: black 
    Underline: unspecified 
     Overline: unspecified 
Strike-through: unspecified 
      Box: unspecified 
     Inverse: unspecified 
     Stipple: unspecified 
      Font: unspecified 
     Fontset: unspecified 
     Inherit: unspecified 
+0

關於這個問題的任何消息,你有沒有發現什麼工作到底?我遇到了一個類似的問題,emacsclient不會加載color-theme,但emacs會很高興地應用我的紫色光標。 – kristianlm

回答

5

好吧..這個問題可以解決通過添加

​​

雖然我不明白爲什麼它以前是沒有問題的。

請參閱this論壇主題。

+0

謝謝,我會在下次X重啓時嘗試這個 – modular

7

我相信,在最近的emacsen,使用框架屬性設置光標顏色不是首選的方法。因此,使用set-cursor-colorinitial-frame-alist/default-frame-alist代替,嘗試:

(set-face-background 'cursor "red") 

或者,也許:

(set-face-attribute 'cursor nil :background "red"`) 
+1

謝謝,好點。但對我來說並沒有幫助。 – modular

+0

嗯,奇怪。我會看看我是否可以重現它。 – sanityinc

+1

我也嘗試過,但也沒有成功。我也受到這種奇特行爲的影響。 – plc

0

我也有同樣的問題,很多年了。

在我來說,我做的:

M-x 
set-cursor-color 
"white"<ENTER> 

這對我的作品,但我不得不這樣做,每次,這sux的..

早在我以前工作過我這個解決,但我不沒有我曾經在我的舊工作場所中使用過的init.el,現在我需要再次弄清楚這一點,希望這裏有人會在我面前解決這個問題。

5

Bwahahaha!我認爲過去兩年沒有人發佈過解決方案,因爲你們都是EVIL emacs用戶!

真相被告知,我現在正嘗試使用邪惡模式,我和我剛剛在我的系統上解決了這個問題。把這個在你的.emacs文件琢磨吧:

'(evil-default-cursor (quote (t "white"))) 

我剛打開a bug針對到位桶邪惡庫。

對於我自己,我發現經過6年左右才真正熟練掌握emacs,多重和絃在我的肌腱上很難操作。邪惡模式可能讓我再次使用emacs,這是一件好事。正如Benedict所說(在函數式編程的上下文中),「Some evil is often necessary to get work done.」似乎也可能適用於Emacs。

P.S. 對於任何人都覺得這個答案只是DH0或其他不成熟和不適當的,Emacs和VI用戶之間的大多數舌頭在feud已經肆虐多年。 Emacs有它自己的Church of Emacs,VI有視頻遊戲,World War VI。因此,將Emacs的最成功的VI鍵綁定端口命名爲evil-mode(邪惡在其中包含VI)並不奇怪。我喜歡這兩位編輯,並讚美那些終於在emacs中使用VI keybindings的邪惡開發人員。

+0

謝謝Glen,我已經是EVIL用戶了(儘管我從不使用普通模式/狀態)。我糾正了你的命令(用'setq'替換''')。它似乎對我很好。即使由於某種原因光標再次變黑,我可以重複該命令。 – modular

+0

由於這是唯一適用於我的解決方案,我接受您的答案。雖然對於不是EVIL粉絲的emacs用戶來說有點不公平。 – modular

1

這爲我工作:

(setq evil-default-cursor t) ;; Now evil takes the default cursors 
(set-cursor-color "white") ;; Set it to white 
(set-mouse-color "white") ;; Same