父さんは酸素欠乏症(powershell.el)

Syntax Highliting に慣れ過ぎてるのな、われわれは。

さすがに emacs で Syntax Highliting なしの Power Shell スクリプトは読みづらい。powershell-mode はないか。

Xah Leeさんのこの記事により、「Google さん powershell syntax highlighting emacs 検索」で真っ先に見つかる emacswiki の powershell.el ページが、Run PowerShell as a shell within Emacs|MSDN Blogsが元になった Dino Chiesa さんによるもの、で、結構既に有名ってことみたいね。WEBで powershell.el と出てきたら、どうもこれを指すようだ。そして Google さんは期待の答えを返してなくて、これは「M-x shell」ライクな「M-x powershell」。Xah Leeさんの記事ではpowershell-mode.el by Vivek Sharmaも紹介してる。

これとは別に、Joe Schafer の powershell.el も見つかる。どうやら Dino Chiesa の powershell.el と Frédéric Perrin の powershell-mode.el をマージしたもの、のようで。そいつぁありがてぇ、っと。でも Vivek Sharma さんはどこ行った? まぁいいか。

Joe Schafer の powershell.el

1 ;; Package-Requires: ((emacs "24))

てことなので、Meadow3 では使えないと思います。Meadow3 って確か 22 系じゃなかったっけ。

ダウンロードしたら powershell.el 開いて「M-x eval-buffer」すればその場で使えるようになりますな。~/.emacs.d/ の下にでも置くが良かろう。以下部分は 64bit 版 powershell を日常使いにするなら書き換えたらいい:

powershell.el内
775 (defcustom powershell-location-of-exe
776   "c:\\windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe"
777   "A string, providing the location of the Powershell.exe."
778   :group 'powershell)


.emacsに追加
1 ;; add the dir to load path
2 (add-to-list 'load-path "~/.emacs.d/")
3 
4 ;; autoload powershell interactive shell
5 (autoload 'powershell "powershell" "Start a interactive shell of PowerShell." t)
6 
7 ;; powershell-mode
8 (autoload 'powershell-mode "powershell" "A editing mode for Microsoft PowerShell." t)
9 (add-to-list 'auto-mode-alist '("\\.ps1\\'" . powershell-mode)) ; PowerShell script

もとの「powershell.el」「powershell-mode.el」が一つの「powershell.el」になっちゃってるからさ、Xah Leeさんの記事とは違ってるので注意な。

2015-06-23 追記
「~/.emacs.d」ってどこやねん、と思う人は多分 Windows ユーザでしょう。そりゃそうだよね、PowerShell なんだから。むしろ Unix で PowerShell したいのはなんでぢゃ、とならぁな。php-mode.elの方に書いときました。