Getting rid of backslash at the end of wrapped lines (for copy-paste)

给你一囗甜甜゛ 提交于 2019-12-01 17:37:29

问题


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)

回答1:


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.



来源:https://stackoverflow.com/questions/17003230/getting-rid-of-backslash-at-the-end-of-wrapped-lines-for-copy-paste

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!