4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Emacsから外部プロセスを実行するときのコーディングシステムをカレントバッファに合わせる

Posted at

調べもしないでちょこっと書いただけのものなので、まっとうな方法があったらぜひ教えてくださいませ。

プロジェクトによって、いろいろなコーディングシステムのファイルを扱うのですが、 gtags なんかを使った時に文字化けするんでカレントバッファのファイルコーディングシステムに合わせてしまうマクロ(defadviceするだけ)を書いてみました。

(defmacro my-adapt-coding-system-with-current-buffer (target-function)
  `(defadvice ,target-function
     (around my-adapt-coding-system-with-current-buffer activate)
     (let ((coding-system-for-read buffer-file-coding-system)
	   (coding-system-for-write buffer-file-coding-system)
	   (coding-system-require-warning t))
       ad-do-it)))

(my-adapt-coding-system-with-current-buffer gtags-find-tag)
(my-adapt-coding-system-with-current-buffer gtags-find-with-idutils)
(my-adapt-coding-system-with-current-buffer gtags-find-with-grep)
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?