9

I use several modes that display Unicode characters in my code without changing the underlying file. For example, in Haskell mode, the following code:

foo :: forall a. Eq a => a -> a -> a

gets displayed as

foo ∷ ∀ a. Eq a ⇒ a → a → a

This is implemented with compose-region, which can replace a region with a character without changing the actual buffer text.

When I copy the code, however, it copies the underlying text without the Unicode. Most of the time this is the desired behavior, but sometimes I want to copy the displayed characters instead—I had to type up the second version of my example myself!

How can I copy the result of character substitutions like this rather than the underlying text? (In fact, I'm not sure this is possible at all!)

1
  • 2
    If somebody could swoop in and provide some sort of generic copy-visible function, that would be awesome.
    – nispio
    Commented Oct 15, 2014 at 18:29

1 Answer 1

4

I tried to do this myself and did not find a good solution. It seems like it CAN be done by manually composing the buffer's text based on the composition property and the composition function table.

In the past I have solved this by running emacs in a terminal and and using my mouse to select and copy the text displayed.

Clearly not a good solution, but it works in times of need, you can then paste "visible" text back in by doing an OS paste into the terminal.

1
  • Not ideal, but that's a clever trick I wouldn't have thought of. Commented Oct 15, 2014 at 18:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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