emacs 에서 replace-regexp 시 한글코드문제

philos66의 이미지

emacs를 사용하다가 다음과 같은 문제가 갑자기 발생했습니다.

참고로 제가 사용하고 있는 emacs는

http://ftp.gnu.org/pub/gnu/emacs/windows/emacs-21.3-fullbin-i386.tar.gz
http://ftp.gnu.org/pub/gnu/emacs/windows/emacs-21.3-leim.tar.gz

이고, 운영체제는 한글 Windows XP 입니다.

저의 .emacs 의 내용은 다음과 같습니다.

;;;; .emacs 설정 파일
 
(set-language-environment "Korean")
(set-default-coding-systems 'euc-kr)
(set-clipboard-coding-system 'euc-kr)
(setq default-buffer-file-coding-system 'euc-kr)
(set-default-font "-outline-HY\261\327\267\241\307\310M-normal-r-normal-normal-16-120-96-96-p-*-ksc5601.1987")
(global-font-lock-mode t)
 
 
(defun call-replace ()
  (interactive)
  (replace-regexp "123" "123한글"))
 
(global-set-key [f2] 'call-replace)

emacs를 열고 나서 *scratch* 버퍼에 '123'을 입력하고 난 후에, F2 키를 누르면 다음과 같은 화면이 뜹니다.

제대로 치환이 된 것 같이 보이지만, '123한글' 이라고 나온 부분을 커서로 드래그 하면
아래의 그림처럼 이상한 글자로 바뀌고, 이 상태에서 C-x C-s 를 눌러 저장하려 하면 다음과 같은 메시지가 나옵니다.

더 이상한 것은 emacs의 미니 버퍼에서

M-x replace-regexp <Ret> 123 <Ret> 123한글 <Ret> 
하면 위의 '123한글'이라고 바뀐 부분을 드래그 해도 이상한 글씨로 깨지지도 않고, C-x C-s 로 저장을 해도 정상적으로 저장이 된다는 것입니다. 도데체 무엇이 잘못된 것일까요?
File attachments: 
첨부파일 크기
Image icon emacs-error-1.jpg18.7 KB
Image icon emacs-error-2.jpg69.92 KB
monpetit의 이미지

운영체제만 같고 다른 건 차이가 좀 있네요. (한글 Windows XP)
위의 현상에 대한 원인은 모르겠지만, 제 컴퓨터에서는 나타나지 않는 현상이군요.
차이점을 열거하면

1. Emacs 버전: GNU Emacs 22.0.50.1 (i386-mingw-nt5.1.2600) of 2006-07-02 on W2ONE
(from http://ourcomments.org/Emacs/EmacsW32.html)
2. 한글폰트: Tahoma (영문폰트: Courier New)
3. 인코딩: UTF-8

이러합니다.
이 세가지 중 어떤 것이 원인인지는 모르겠지만 이리저리 변경해 보시면 답이 나올 것 같네요.

philos66의 이미지

한글 Windows XP 의

제어판-시스템-고급-환경변수-시스템변수 내의

LANG 변수의 값이 1042 라고 되어 있는 것이 문제였네요.

LANG 변수의 값이 왜 1042인지, 어느 프로그램이 위의 같이 설정했는지는
모르겠습니다만(한글 Windows XP가 이 값을 1042로 설정하지 않은 것은
확실합니다. 왜냐하면 예전에는 위와 같은 현상이 일어나지 않다가, 프로그램을
여럿 새로 설치한 최근에야 위와 같은 현상이 일어났기 때문입니다),

위의 시스템 변수를 아예 삭제하고 나니 위의 현상이 사라졌습니다.
저와 같은 문제로 고생하실(?) 분들은 참고하세요!

그리고 위에 저의 질문에 답변해 주신 분께 감사의 마음을 전합니다. ^^

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.