all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Florian Lindner <mailinglists@xgm.de>
To: help-gnu-emacs@gnu.org
Subject: Re: How to get rid of annoying ^M lineendings
Date: Fri, 18 Jul 2014 08:52:15 +0200	[thread overview]
Message-ID: <lqag72$40m$1@ger.gmane.org> (raw)
In-Reply-To: c8aa7fac-5cad-4e90-8152-357de2d76d92@googlegroups.com

scott.althoff@gmail.com wrote:

> Is there a way to execute this every time emacs starts?
> 
> On Wednesday, April 23, 2008 11:39:24 AM UTC-5, Stefan Reichör wrote:
>> Joost Kremers <joostkremers@yahoo.com> writes:
>> 
>> > olgo wrote:
>> >> I keep reading solutions to this problem by means of substituting the
>> >> line endings with a global replace but this is not what I need.
>> >> I need for the files to be kept as they are, with all kinds of line
>> >> endings, but I don't want to see it in the editor.
>> >>
>> >> Thus, my question is:
>> >> Is there a way to tell emacs not to show the ^M character altogether?
>> >
>> > IME this is only a problem when line endings in a file are not
>> > consistent. so my advice would be to make sure each file only has one
>> > kind of line ending, then emacs will simply detect the format correctly
>> > and will tell you in the mode line you're editing a DOS file, and won't
>> > show the ^M characters.
>> 
>> I use the following function to remove the trailing ^M from such files:
>> 
>> (defun xsteve-remove-control-M ()
>>   "Remove ^M at end of line in the whole buffer."
>>   (interactive)
>>   (save-match-data
>>     (save-excursion
>>       (let ((remove-count 0))
>>         (goto-char (point-min))
>>         (while (re-search-forward "
>> $" (point-max) t)
>>           (setq remove-count (+ remove-count 1))
>>           (replace-match "" nil nil))
>>         (message (format "%d ^M removed from buffer." remove-count))))))

For just hiding the ^M I have:

(defun hide-dos-eol ()
  "Do not show ^M in files containing mixed UNIX and DOS line endings."
  (interactive)
  (setq buffer-display-table (make-display-table))
  (aset buffer-display-table ?\^M []))

(add-hook 'prog-mode-hook 'hide-dos-eol)




  parent reply	other threads:[~2014-07-18  6:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-22 13:50 How to get rid of annoying ^M lineendings olgo
2008-04-22 14:13 ` Joost Kremers
2008-04-23 16:39   ` Stefan Reichör
2008-04-23 18:19     ` Drew Adams
2014-07-17 20:51     ` scott.althoff
2014-07-17 22:31       ` Emanuel Berg
2014-07-18  5:53       ` Michael Heerdegen
2014-07-18  6:52       ` Florian Lindner [this message]
2014-07-18  5:44   ` Michael Heerdegen
2008-04-23  4:59 ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='lqag72$40m$1@ger.gmane.org' \
    --to=mailinglists@xgm.de \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.