Question

Emacs in text-mode puts a \ character (backslash) at the end of a wrapped line.

I would like to not have that displayed, so I can copy-paste from such a window into another one, without getting the \ in the pasted text.

I'm sure there is an easy solution for this, but I couldn't find it (neither online, nor in the emacs manual). The closest seems to be Disable little arrows on far end of line.


Distilled from all the replies and links therein, this is what I ended up using for emacs (22.1.1) included in Mac OS X 10.8.3. It works great. Thanks again for all the help!

;; copy to Mac clipboard (for copying text the wrapped '\' lines                                                       
(defun copy-to-mac-clipboard ()
  "Copy currently selected region to Mac clipboard (useful for wrapped '\\' lines)"
  (interactive)
  (if (> (- (region-end) (region-beginning)) 0)
      (progn
        (shell-command-on-region (region-beginning) (region-end) "pbcopy")
        (message "region copied to Mac clipboard (%d chars)" (- (region-end) (region-beginning)))
        (if (and transient-mark-mode mark-active)
           (deactivate-mark)))
    (progn
      (message "no region active"))
    ))

;; put this next to M-w, which is kill-ring-save (copy to emacs clipboard)                                             
(global-set-key "\M-e" 'copy-to-mac-clipboard)
Was it helpful?

Solution

These \ (and $) thingies are placed in what we call "the fringe". And sadly, Emacs does not currently let you control the fringe when running in text mode. I think the answer pointed out by Angus is "the best we have" so far.

OTOH, for your specific problem, other than running Emacs in GUI mode, you might be able to let Emacs communicate directly with your desktop's clipboard (rather than let the terminal emulator), which then solves this problem as well as letting you copy text even if it's not displayed.

There is the xclip.el package for that under X11, and someone has posted a patch (not yet integrated) to make it work under Mac OS X as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top