From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan =?iso-8859-1?Q?Reich=F6r?= Newsgroups: gmane.emacs.help Subject: Re: How to get rid of annoying ^M lineendings Date: Wed, 23 Apr 2008 18:39:24 +0200 Organization: www.TeraNews.com Message-ID: <877ieoa5kz.fsf@xsteve.at> References: <227a76ea-99a0-44cd-bb5f-e6c7b328e347@e67g2000hsa.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1208968919 15210 80.91.229.12 (23 Apr 2008 16:41:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 23 Apr 2008 16:41:59 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Apr 23 18:42:34 2008 connect(): Connection refused Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Joi3F-0005w8-J9 for geh-help-gnu-emacs@m.gmane.org; Wed, 23 Apr 2008 18:42:33 +0200 Original-Received: from localhost ([127.0.0.1]:34318 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Joi2Z-0008M9-Tp for geh-help-gnu-emacs@m.gmane.org; Wed, 23 Apr 2008 12:41:51 -0400 Original-Path: shelby.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!nntpserver.com!zeus.nntpserver.com!pfilter-v0.1!news.teranews.com!not-for-mail Original-Newsgroups: gnu.emacs.help Cancel-Lock: sha1:2/gZbyOwFyqjLv1lTCNBLR2Ds9E= Original-X-Complaints-To: abuse@teranews.com Original-Lines: 34 Original-NNTP-Posting-Date: Wed, 23 Apr 2008 12:39:24 -0400 Original-Xref: shelby.stanford.edu gnu.emacs.help:158135 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:53501 Archived-At: Joost Kremers 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)))))) Stefan. ** Posted from http://www.teranews.com **