From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: scott.althoff@gmail.com Newsgroups: gmane.emacs.help Subject: Re: How to get rid of annoying ^M lineendings Date: Thu, 17 Jul 2014 13:51:29 -0700 (PDT) Message-ID: References: <227a76ea-99a0-44cd-bb5f-e6c7b328e347@e67g2000hsa.googlegroups.com> <877ieoa5kz.fsf@xsteve.at> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1405658041 16273 80.91.229.3 (18 Jul 2014 04:34:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 18 Jul 2014 04:34:01 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jul 18 06:33:56 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1X7zrn-0003pX-0R for geh-help-gnu-emacs@m.gmane.org; Fri, 18 Jul 2014 06:33:55 +0200 Original-Received: from localhost ([::1]:47895 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7zrm-0004DO-KI for geh-help-gnu-emacs@m.gmane.org; Fri, 18 Jul 2014 00:33:54 -0400 X-Received: by 10.182.130.169 with SMTP id of9mr20662795obb.27.1405630290357; Thu, 17 Jul 2014 13:51:30 -0700 (PDT) X-Received: by 10.182.112.230 with SMTP id it6mr31249obb.35.1405630290218; Thu, 17 Jul 2014 13:51:30 -0700 (PDT) Original-Path: usenet.stanford.edu!h18no1780179igc.0!news-out.google.com!bp9ni941igb.0!nntp.google.com!h18no3272464igc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help In-Reply-To: <877ieoa5kz.fsf@xsteve.at> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=204.154.128.175; posting-account=s0UfLgoAAAAPqOk72aRE3G0X_UGCxj_n Original-NNTP-Posting-Host: 204.154.128.175 User-Agent: G2/1.0 Injection-Date: Thu, 17 Jul 2014 20:51:30 +0000 Original-Xref: usenet.stanford.edu gnu.emacs.help:206458 X-Mailman-Approved-At: Fri, 18 Jul 2014 00:33:37 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:98736 Archived-At: Is there a way to execute this every time emacs starts? On Wednesday, April 23, 2008 11:39:24 AM UTC-5, Stefan Reich=F6r wrote: > Joost Kremers writes: >=20 > > 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 consiste= nt. > > 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 tel= l > > you in the mode line you're editing a DOS file, and won't show the ^M > > characters. >=20 > I use the following function to remove the trailing ^M from such files: >=20 > (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)))))) >=20 >=20 > Stefan. > ** Posted from http://www.teranews.com **