Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

On the default install of Carbon Emacs on OS X, copying a file from Finder and yanking it into emacs results in just the icon being displayed.

How would I go about customizing it so it instead gives the file path?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

I managed to disable all image yanking (drag and drop still works if I really want an image in there) by overriding a function declared in mac-win.el (uncompiled file not included in default install.)

in my .emacs:

;; prohibit pasting of TIFFs
(defun x-selection-value (type)
  (let ((data-types '(public.file-url
                       public.utf16-plain-text
                       com.apple.traditional-mac-plain-text))
    text)
    (while (and (null text) data-types)
      (setq text (condition-case nil
    	     (x-get-selection type (car data-types))
    	   (error nil)))
      (setq data-types (cdr data-types)))
    (if text
    (remove-text-properties 0 (length text) '(foreign-selection nil) text))
    text))

original was:

(defun x-selection-value (type)
  (let ((data-types '(public.utf16-plain-text
    	      com.apple.traditional-mac-plain-text
    	      public.file-url))
    text tiff-image)
    (while (and (null text) data-types)
      (setq text (condition-case nil
    	     (x-get-selection type (car data-types))
    	   (error nil)))
      (setq data-types (cdr data-types)))
    (if text
    (remove-text-properties 0 (length text) '(foreign-selection nil) text))
    (setq tiff-image (condition-case nil
    		 (x-get-selection type 'public.tiff)
    	       (error nil)))
    (when tiff-image
      (remove-text-properties 0 (length tiff-image)
    		      '(foreign-selection nil) tiff-image)
      (setq text (mac-TIFF-to-string tiff-image text)))
    text))
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.