2012-06-24 41 views
4

我是Emacs的新手,並搞清楚如何啓用輪班點擊選擇。論CUA Mode的EmacsWiki頁面,下面的代碼段概述瞭如何做到這一點:瞭解用於輪班點擊選擇的Emacs CUA模式

;; shift + click select region 
(define-key global-map (kbd "<S-down-mouse-1>") 'ignore) ; turn off font dialog 
(define-key global-map (kbd "<S-mouse-1>") 'mouse-set-point) 
(put 'mouse-set-point 'CUA 'move) 

我不明白,最後一行是如何讓選擇。我已經研究過的定義

put is a built-in function in `C source code'. 

(put SYMBOL PROPNAME VALUE) 

Store SYMBOL's PROPNAME property with value VALUE. 
It can be retrieved with `(get SYMBOL PROPNAME)'. 

鼠標設定點的定義:

mouse-set-point is an interactive compiled Lisp function in 
`mouse.el'. 

It is bound to <S-mouse-1>, <triple-mouse-1>, <double-mouse-1>, 
<mouse-1>. 

(mouse-set-point EVENT) 

Move point to the position clicked on with the mouse. 
This should be bound to a mouse click event type. 

但他們沒有提供任何線索。我找不到任何變量或函數,稱爲移動,並且我還查看了mouse.el,cua-base.el,cua-gmrk.el和cua-rect.el的源代碼。

有人會解釋最後一行是如何工作的,以及我如何能夠自己找到更多信息?謝謝。

+0

答案有幫助嗎? – Specksynder

回答

3

我沒有深入CUA模式,但我明白你在找什麼。 'put'是符號屬性列表的一個函數。在這種情況下,符號是鼠標設置點,並且您將該符號的屬性「CUA」設置爲「移動」值。要回讀符號的屬性值,可以使用函數'get'。您可以在GNU網頁上的Elisp參考手冊中找到更多文檔。

我看着在CUA到CUA屬性引用 - * EL,果然,發現一個在CUA-base.el:(我使用Emacs的23.3.1)

(defun cua--pre-command-handler-1() 
    ;; Cancel prefix key timeout if user enters another key. 
    (when cua--prefix-override-timer 
    (if (timerp cua--prefix-override-timer) 
    (cancel-timer cua--prefix-override-timer)) 
    (setq cua--prefix-override-timer nil)) 

    (cond 
    ;; Only symbol commands can have necessary properties 
    ((not (symbolp this-command)) 
    nil) 

    ;; Handle delete-selection property on non-movement commands 
    ((not (eq (get this-command 'CUA) 'move)) 

我想。你可以從這裏弄清楚房屋的用途。希望這可以幫助。

+0

謝謝,我專門尋找鼠標命令,不知道有一個「這個命令」符號 –