Article View: comp.emacs
Article #9743skipping CR from CRLF in emacs buffer
From: Philippe Maurisset
Date: Mon, 23 Jun 1997 00:00
Date: Mon, 23 Jun 1997 00:00
54 lines
2204 bytes
2204 bytes
Hello, all
Here is the patch I finaly add into my .emacs in order to
skip the polluting ^M
As it is usefull for me, it may be for others ;)
<---- cut here
;;
;; For C and C++, skip these damned ^M from emacs buffer
;;
;; First : define the right function to do the substitution, and
;; make it accessible for the user (in the case of any other mode
;; entered with such a writable perturbated file) :
(defun skip-cr-from-crlf-in-buffer ()
(interactive)
(replace-string "\C-m\C-j" "\C-j"))
;; Second : execute it each time C or C++ mode is entered, even
;; on a write-protected file (useful when in gdb trace mode, or
;; when using version control as RCS), leaving the buffer
;; apparently unmodified (till a *real* modification).
;; Note that, if buffer is finaly saved, the ^M are effectively
;; skipped from the file :
(add-hook 'c++-mode-hook
'(lambda ()
(let (memo-wpstate))
(setq memo-wpstate buffer-read-only)
(setq buffer-read-only nil)
(skip-cr-from-crlf-in-buffer)
(setq buffer-read-only memo-wpstate)
(not-modified)))
(add-hook 'c-mode-hook
'(lambda ()
(let (memo-wpstate))
(setq memo-wpstate buffer-read-only)
(setq buffer-read-only nil)
(skip-cr-from-crlf-in-buffer)
(setq buffer-read-only memo-wpstate)
(not-modified)))
<---- cut here
Comments are welcome.
Hope this helps,
Philippe.
--
-=-=-=-=-=-=- Philippe Maurisset -=- phil@rd.lectra.fr -=-=-=-=-=-=-
Lectra Systemes - Chemin de Marticot, BP 34 - 33611 CESTAS Cedex - FRANCE
Voice +33 05 57 97 80 00 / Fax +33 05 57 97 82 32
Technical Details
Message-ID:
<5om02s$7av@Sherlock.lectra.fr>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 102b9a,3a2dd011d7680c16,start X-Google-Attributes: gid102b9a,public X-Google-Thread: f5a1a,3a2dd011d7680c16,start X-Google-Attributes: gidf5a1a,public From: phil@rd.lectra.fr (Philippe Maurisset) Subject: skipping CR from CRLF in emacs buffer Date: 1997/06/23 Message-ID: <5om02s$7av@Sherlock.lectra.fr> X-Deja-AN: 252018481 Distribution: world Organization: Lectra Systemes, Cestas, France Keywords: newline, windows, emacs Newsgroups: comp.emacs,fr.comp.applications.emacs