Emacsのファイル拡張子の認識

Emacsのファイル拡張子の認識

Emacsに新しいファイル拡張子を認識させるにはどうすればよいですか?たとえば、ファイルがあり、.cEmacsで開くと、Cの正しい構文強調が表示されますが、.bobファイル形式(Cであることがわかっています)がある場合、Emacsに次のように解釈するようにどのように指示しますか?ファイル方法は.c

ベストアンサー1

これの説明は次のとおりです。Emacs初心者ガイド

ラインで

(setq auto-mode-alist (cons '("README" . text-mode) auto-mode-alist))

READMEというファイルを開くと、emacsに「テキストモード」に入るように指示します。

そして

(setq auto-mode-alist (cons '("\\.html$" . html-helper-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.htm$" . html-helper-mode) auto-mode-alist))

ファイル名が*.htmlまたは*.htmの場合、emacsに「html-helper-mode」と入力するように指示します。

存在するスタックオーバーフロー*.emacs ファイルを lisp.code で強調表示する例があります。

(setq auto-mode-alist 
      (append '((".*\\.emacs\\'" . lisp-mode))
              auto-mode-alist))

おすすめ記事