Emacs

2010-08-25 14 views
5

में कुंजी मैपिंग के लिए दो विधियां मुझे लगता है कि emacs में कुंजी सेट करने के दो तरीके हैं: गोल्बल-सेट-कुंजी और परिभाषित-कुंजी। क्या वे वही हैं? या क्या दो दृष्टिकोणों के बीच कोई पेशेवर/विपक्ष है?Emacs

(global-set-key (kbd "C-c C-f") 'my-find-file) 
(define-key global-map 
    "\C-ck" 'hello) 

उत्तर

6

वहाँ प्रभावी ढंग से है कोई फर्क नहीं है, अगर आप global-set-key की परिभाषा को देखो आप देखेंगे:

(define-key (current-global-map) key command) 

यह संभव है कि (current-global-map) एक कीमैप कि global-key-map की तुलना में अलग है, लेकिन असामान्य है वापस आ जाएगी।

अब, define-key एक कीमैप का तर्क लेता है, यह स्पष्ट रूप से सरल global-set-key से अधिक लचीला है। कीमैप्स पर विवरण के लिए info pages देखें।

2

अंतर यह है कि (global-set-key) या (local-set-key) आपके लिए वैश्विक/स्थानीय मानचित्र ढूंढें ((define-key) पर कॉल करने से पहले)।

संपादित आप (global-set-key)

(global-set-key key command) 

Give key a global binding as command. 
command is the command definition to use; usually it is 
a symbol naming an interactively-callable function. 
key is a key sequence; noninteractively, it is a string or vector 
of characters or event types, and non-ASCII characters with codes 
above 127 (such as ISO Latin-1) can be included if you use a vector. 

के लिए और (define-key)

(define-key keymap key def) 

In keymap, define key sequence key as def. 
keymap is a keymap. 

key is a string or a vector of symbols and characters meaning a 
sequence of keystrokes and events. Non-ASCII characters with codes 
above 127 (such as ISO Latin-1) can be included if you use a vector. 
Using [t] for key creates a default definition, which applies to any 
event type that has no other definition in this keymap. 
के लिए M-x describe-function उपयोग कर सकते हैं