osx

2010-09-27 19 views
6

पर एपैक 23.1.1 को कॉन्फ़िगर करने के बजाय emacs को ड्रैग और ड्रॉप करने के लिए कैसे कॉन्फ़िगर करें ताकि emacs विंडो पर ड्रैग और ड्रॉप फ़ाइल को फ़ाइल को चालू करने के बजाय फ़ाइल को नए बफर में खुलता है बफ़र?osx

उत्तर

4

आप कोशिश कर सकते हैं:

(global-set-key [ns-drag-file] 'ns-find-file) 

यह Emacs 23.2.1 पर मेरे लिए काम करता

+1

लगभग, लेकिन काफी नहीं। इसे मेरे ~/.emacs में जोड़ें, उसी बफर में खुलने से रोकने के लिए, लेकिन मैं इसे एक ही विंडो में एक अद्वितीय बफर में खोलना चाहता हूं। –

+2

'(setq ns-pop-up-frames nil) 'मेरे लिए काम किया। – worldsayshi

+0

[संबंधित] (http://stackoverflow.com/questions/1850292/emacs-23-1-and-mac-os-x-problem-with-files-drag-and-drop) – worldsayshi

2

मै अपने .emacs में उपयोग करें:

; Upon drag-and-drop: Find the file, w/shift insert filename; w/meta insert file contents 
; note that the emacs window must be selected (CMD-TAB) for the modifiers to register 
(define-key global-map [M-ns-drag-file] 'ns-insert-file) 
(define-key global-map [S-ns-drag-file] 'ns-insert-filename) 
(define-key global-map [ns-drag-file] 'ns-find-file-in-frame) 

(defun ns-insert-filename() 
    "Insert contents of first element of `ns-input-file' at point." 
    (interactive) 
    (let ((f (pop ns-input-file))) 
    (insert f)) 
    (if ns-input-file      ; any more? Separate by " " 
     (insert " "))) 

(defun ns-find-file-in-frame() 
    "Do a `find-file' with the `ns-input-file' as argument; staying in frame." 
    (interactive) 
    (let ((ns-pop-up-frames nil)) 
    (ns-find-file))) 
+0

बहुत बढ़िया! ये बहुत अच्छा काम करते हैं - बहुत बहुत धन्यवाद! यदि गंतव्य शेल बफर है, तो क्या एनएस-ड्रैग-फ़ाइल का डिफ़ॉल्ट व्यवहार बदलना संभव है? विशेष रूप से, अगर मैं एक खोल में खींचता हूं, तो यह पूर्ण पथ पेस्ट करने के लिए प्राकृतिक लगता है। लेकिन वैसे भी, सिर्फ उत्सुक है। शिफ्ट को पकड़ना काफी आसान है। – DavidR

2

रहा का उपयोग करें:

(if (fboundp 'ns-find-file) 
    (global-set-key [ns-drag-file] 'ns-find-file)) 

यह (जो मूल रूप से वही है अन्य उत्तरों में दिया गया) सुनिश्चित करता है कि एक नया बफर बनाया गया है। if भाग यह सुनिश्चित करता है कि कोड गैर-मैक वातावरण में भी काम करेगा।

(setq ns-pop-up-frames nil) 

यह सुनिश्चित करता है कि नया बफर मौजूदा विंडो में प्रदर्शित होता है, ताकि एक नया Emacs फ्रेम खोला न जाए। (मैंने एक टिप्पणी में देखा कि आपको इसके साथ परेशानी थी।)

+0

आह, सही! यह वास्तव में मुझे परेशान कर रहा था, लेकिन अब मेरे नए मैक्टॉप में पूर्णता emacs है, धन्यवाद! – CodexArcanum