2009-09-14 75 views
5

根據Emacs的信息頁面,這裏是你如何能iswitchb模式:爲什麼我以這種方式啓動iswitchb模式?

要啓用Iswitchb模式,類型M-x iswitchb-mode,或自定義 變量iswitchb-modet

所以我把下面的在我的.emacs中:

(setq iswitchb-mode t) 

但是,這似乎並不奏效。搜索Emacs的維基之後,我發現我需要使用此:

(iswitchb-mode 1) 

有人能解釋爲什麼我需要啓用它這樣?我希望更好地理解elisp,而不僅僅是複製和粘貼來自地方的東西。

回答

8

通常,一個模式將同時定義一個變量和一個具有相同名稱的函數。該函數會在調用變量時正確設置變量,但它是打開模式的函數,而不僅僅是變量(只跟蹤模式的狀態)。

在你的具體情況下,你被告知告訴定製變量,但你只需設置它。不同之處在於,當變量的值發生變化時,自定義知道要做些什麼,而`setq'對此一無所知。如果你看看這個變量(C-h v iswitchb-mode)的幫助,你會得到:

iswitchb-mode is a variable defined in `iswitchb.el'. 
Its value is t 

Documentation: 
Non-nil if Iswitchb mode is enabled. 
See the command `iswitchb-mode' for a description of this minor mode. 
Setting this variable directly does not take effect; 
either customize it (see the info node `Easy Customization') 
or call the function `iswitchb-mode'. 

You can customize this variable. 
+0

謝謝。我不知道關於elisp的所有這一切。 –

+0

不幸的是,推導(除了變量的描述)並不那麼容易。 iswitchb(以及大多數次要模式)使用宏'define-minor-mode'來處理構建模式,打開和關閉模式,定製變量,鍵盤映射等的實際機制,因此您必須深入研究函數定義'define-minor-mode'本身來收集這些東西是如何放在一起的。 –

相關問題