Removing^MIn Emacs
Emacs에서 "^M" 문자 없애기 ¶일반적으로 "^M" 이 생기는 원인은
MS윈도우는 라인 끝을 CR+LF로 나타내고 리눅스는 LF로 나타내서 입니다. 없애는 방법은
C-x RET r (revert-buffer-with-coding-system) 미니버퍼에 아래처럼 나오면 “dos” 입력
Coding system for visited file (default nil): dos아래 메세지 나오면 “yes” 입력 Revert buffer from file 경로/파일명? (yes or no) yes 그리고 영구적으로 "^M"을 없앨려면 위 과정을 하고
C-x RET f (set-buffer-file-coding-system) 미니버퍼에 아래처럼 나오면 “unix” 입력
Coding system for saving file (default nil): unixC-x C-s (save-buffer) 로 버퍼 저장 .emacs 파일에서 쓸 수 있는 예제 키바인딩
(global-set-key [(control x)(?\r)(f7)] '(lambda () (interactive) (revert-buffer-with-coding-system 'dos) ) ) (global-set-key [(control x)(?\r)(f8)] '(lambda () (interactive) (revert-buffer-with-coding-system 'unix) ) ) (global-set-key [(control x)(?\r)(control f7)] '(lambda () (interactive) (set-buffer-file-coding-system 'dos) ) ) (global-set-key [(control x)(?\r)(control f8)] '(lambda () (interactive) (set-buffer-file-coding-system 'unix) ) )(?\r)대신 (return)을 사용하면 기존에 있던 C-x RET 를 prefix command로 사용하는 키바인딩이 작동을 안하게 됩니다. 꼭 (?\r)를 사용하세요. 참고:
메세지 응답을 yes or no 로 입력 안하고 y or n 로 하고 싶으신 분은 .emacs 파일에 아래 내용 넣으세요. (fset 'yes-or-no-p 'y-or-n-p) 파일이 깨져있어서 위 방법이 안 통한다면 아래처럼 강제로 "^M"를 제거하는 방법도 있습니다.
http://nberserk.tistory.com/entry/removing-M-character-in-emacs |
It is a poor judge who cannot award a prize. |










