[Prev][Next][Index][Thread]

Re: text files and emacs?



   I have several ascii files which contain my books for uni.

   When I try to view them under emacs they are full of control ms.

   I have been unable to work out a way of displaying them without all
   the control chars.  Has anyone any ideas on how to do this?


Here is one method -- this is better than simply replacing control-M
with nothing since it also deletes a control-Z at the end, if any.

Best wishes.


;;; Convert DOS file format to Unix

;; look at 
;; M-x comint-strip-ctrl-m
;;   Command: Strip trailing `^M' characters from the current output group.


;; from: elf@ee.ryerson.ca (Luis Fernandes)
;; 22 May 1997

;;; Usage: M-x dos2unix
;;;
(defun dos2unix ()
  "Convert this entire buffer from MS-DOS text file format to UNIX."
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (replace-regexp "\r$" "" nil)
    (goto-char (1- (point-max)))
    (if (looking-at "\C-z")
        (delete-char 1))))