Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .