MOF ファイルを編集するための major mode です。
今のところ以下のことができます。
NetInstaller でインストールした場合は 3 以降を、
NetInstaller + ni-autoload
を使っている人は 4 以降で OK です。
アーカイブをダウンロードします。
<URL:http://miyamuko.s56.xrea.com/xyzzy/archives/mof-mode.zip>
拡張子が mof また mfl のファイルを開いたときに自動的に mof-mode になるように ~/.xyzzy または $XYZZY/site-lisp/siteinit.l に以下のコードを追加します。
;; mof-mode (require "mof-mode") (pushnew '("\\.\\(mof\\|mfl\\)$" . mof-mode) *auto-mode-alist* :test 'equal)
設定を反映させるには xyzzy を再起動してください。
※siteinit.l に記述した場合には再ダンプが必要です。
インデントします。
Qualifier 宣言を複数行にわたって書く場合は次のようにインデントします。
Qualifier Key : boolean = false, Scope(property, reference), Flavor(DisableOverride);
現在のバッファを構文チェックします。
構文チェック用のコマンドは *mof-lint-command* で変更できます。
現在のバッファをコンパイルする。
コンパイル用のコマンドは *mof-compiler-command* で変更できます。
#pragma include
でインクルードしているファイルを開きます。
カレントディレクトリを探し、見つからない場合は include ディレクトリを順に探します。 include ディレクトリは *mof-include-directory-list* で追加できます。
mof-find-include-file-dialog
を使えば include
しているファイルの一覧をダイアログから選択し開くことができます。
現在の Namespace をツールチップで表示します。
#pragma namespace
がない場合は default namespace (\\root\cimv2) を表示します。
Values と ValueMap Qualifier 上で実行すると、 対応する値をツールチップで表示します。
例
ValueMap { "0", "1", "2", "3" }, Values { "Deployable", "Installable", "Executable", "Running" }
"2"
の上で実行すると Installable
をツールチップで表示します。
Values と ValueMap Qualifier 上で実行すると、対応する値の先頭に移動します。
例
ValueMap { "0", "1", "2" }, Values { "Pentium(R) III Processor with Intel(R) SpeedStep(TM) " "Technology", "Pentium(R) 4", "Intel(R) Xeon(TM)" },
"0"
に上で実行すると "Pentium(R) III Processor..."
の先頭に移動します。
連続する文字列もちゃんと考慮してます。
一時バッファを作成して Values と ValueMap の対応を表示します。 Qualifier の中で実行してください。
ValueMap { "0", "1", "2", "3", "4" }, Values { "Deployable", "Installable", "Executable", "Running" }
実行例
0 => Deployable 1 => Installable 2 => Executable 3 => Running 4 => nil
ValueMap を自動生成しカーソル位置に挿入します。Qualifier の中で実行してください。
使用前
Values { "Deployable", "Installable", "Executable", "Running" }
使用後
ValueMap { "0", "1", "2", "3" }, Values { "Deployable", "Installable", "Executable", "Running" }
連番は 0 から始まります。0 以外ではじめたい場合はソースでもいじってください。
65 桁を超える場合勝手に改行します。 fold する桁数をかえたい場合、前置引数で指定します。
C-u 70 C-c v m
mof-completion ()
補完します。キー設定を変える場合は以下を .xyzzy に追加します。
;; 補完キーの設定を Ctrl + . にする(デフォルト M-TAB) (add-hook '*mof-mode-hook* '(lambda () (local-set-key #\C-. 'mof-completion)))
mof-define-command (symbol command &key opts before-hook after-hook key name output dir)
バッファのファイル名を引数に実行する外部コマンドを定義します。
作成するコマンドのシンボルを指定します。
関数名とかメニューのタグ名だったりします。
バインドするキーを指定します。
ショートカットキーを指定しない場合は nil を指定します。
メニューの項目名を指定します。
メニューに追加しない場合は nil を指定します。
コマンドの実行結果を出力するバッファ名を指定します。
省略時は *mof-command-buffer-name* です。
コマンド実行時のディレクトリを指定します。
省略時はコマンドが置いてあるディレクトリです。 で、それも取れない場合は mof ファイルがあるディレクトリです。
コマンドの実行後に実行するフックを指定します。
フックは引数を一つとります。wait の値によって変わります。
例
;; wbemservices のコマンドを定義 (環境変数 WBEM_HOME を設定する必要があります。) ;; mof2html を実行し HTML を生成してブラウザで開く (mof-define-command 'ed::mof-to-html (merge-pathnames "bin/mof2html.bat" (si:getenv "WBEM_HOME")) :name "JWS mof2html" :wait t :after-hook '(lambda (exit) (when (zerop exit) (shell-execute (merge-pathnames "bin/xml/index.html" (si:getenv "WBEM_HOME")))))) ;; mof2bean を実行し Java ファイルを生成してファイラで開く (mof-define-command 'ed::mof-to-bean (merge-pathnames "bin/mof2bean.bat" (si:getenv "WBEM_HOME")) :opts (list "user" "pass" (merge-pathnames "bin/bean.txt" (si:getenv "WBEM_HOME"))) :name "JWS mof2bean" :wait t :after-hook '(lambda (exit) (when (zerop exit) (multiple-value-bind (files ok) (filer (merge-pathnames "bin/bean" (si:getenv "WBEM_HOME")) t) (when ok (find-file files)))))) ;; mofcomp する。コマンドの終了は待たない。 (mof-define-command 'ed::mof-compile-jws (merge-pathnames "bin/mofcomp.bat" (si:getenv "WBEM_HOME")) :key #\F6 :opts '("-u" "user" "-p" "pass") :name "JWS mofcomp" :before-hook '(lambda () (yes-or-no-p "本当に mofcomp するの?")))
*mof-comment-column*
indent-for-comment
で挿入するコメントの開始位置。
デフォルト値は 60 です。
0 10 20 30 40 50 60 class Win32_Sample // ←これを挿入する位置
*mof-indent-level*
*mof-qualifier-offset*
*mof-compile-command*
*mof-lint-command*
*mof-command-buffer-name*
*mof-include-directory-list*
mof-find-include-file
でファイルを探すディレクトリを指定します。
;; Include ディレクトリを追加 (pushnew "D:/CIM_V28Prelim-MOFs/" *mof-include-directory-list*)
MOF のコーディングスタイル集です。 デフォルトは DMTF - CIM Schema v2.8 です。
.xyzzy
;; CIM Schema v2.8 のインデントスタイル (setf *mof-indent-level* 3) (setf *mof-qualifier-offset* 3)
style
// comment [abstract] class Win32_LogicalDisk { // comment [read] string DriveLetter; }
.xyzzy
;; CIM Schema v2.7 のインデントスタイル (setf *mof-indent-level* 4) (setf *mof-qualifier-offset* 4)
style
// comment [abstract] class Win32_LogicalDisk { // comment [read] string DriveLetter; }
.xyzzy
(setf *mof-indent-level* 4) (setf *mof-qualifier-offset* 0)
style
// comment [abstract] class Win32_LogicalDisk { // comment [read] string DriveLetter; }
.xyzzy
(setf *mof-indent-level* 8) (setf *mof-qualifier-offset* -4)
style
// comment [abstract] class Win32_LogicalDisk { // comment [read] string DriveLetter; }
mof-mode は修正 BSD ライセンスに基づいて利用可能です。
Copyright (C) 2003-2004 MIYAMUKO Katsuyuki. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1 Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer as the first lines of this file unmodified. 2 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.