問題意識
僕はhowm形式でメモを取っている(参考:moe | メモの方法論)。howmファイルの一行目をコメントにするスクリプトを利用して、以下のようにタイトルを表示している。
このメモの中から、^[W]でファイル検索をすることがあるのだが、その結果は次のようになる。
00_INDEX.TXTで紐づけたコメントは、当然ListFileでは反映されない。 タイトルが表示されない分視認性は低いが、そもそもあまり検索することもないし、特に不便だとも思ってなかったので、ずっと放置していた。
X_jinfc
最近気付いたのだが、X_jinfcを使えばこの問題を解決することができる。X_jinfcを使うと、ダイアログ完了時にコマンドを実行することができる。
以下をScriptフォルダに保存。これはhowmファイルからタイトルを取得するスクリプト。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//!*script | |
// howmファイル一行目2文字~30字を返すスクリプト | |
// 第一引数:howmファイルのパス | |
// 例 *linemessage %*script(%0Script\gethowmtitle.js,%R) | |
// 引数がなければ終了 | |
if (PPx.Arguments.Length < 1){ | |
PPx.SetPopLineMessage("引数が正しくありません。"); | |
PPx.Quit(); | |
} | |
const file = PPx.Arguments.Item(0); | |
const fso = PPx.CreateObject("Scripting.FileSystemObject"); | |
const name = PPx.Extract('%*name(C,'+file+')'); | |
const ext = PPx.Extract('%*name(T,'+file+')'); | |
if (ext=="howm") { | |
const data = fso.OpenTextFile(file, 1); | |
const str = data.ReadLine().slice( 2,30 ); | |
data.Close(); | |
PPx.result = str; | |
} else { | |
PPx.result = name; | |
} |
以下を編集して取込。
X_jinfc = {
whereiscompcmd = *ifmatch "/D:\\work\\memo/",%1 %: *comment all extract,%(%*script(%0Script\gethowmtitle.js,%FCD)%)
}
これで、D:\work\memo以下で^[W]による検索をした場合、howmファイルから自動でタイトルを取得し、それをコメントにしてくれる。
一番上の「.」「..」がコメント表示になってなくて気になる場合は、以下をScriptフォルダに追加で保存してから
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//!*script | |
// 「.」「..」にコメントを付ける | |
for (var i = 0; i < PPx.EntryAllCount; i++) { | |
if (PPx.Entry(i).Name == "." && PPx.Entry(i).Comment == ""){ | |
PPx.Entry(i).Comment = "."; | |
} else if (PPx.Entry(i).Name == ".." && PPx.Entry(i).Comment == ""){ | |
PPx.Entry(i).Comment = ".."; | |
} | |
} |
以下を編集して取込すればいい。
X_jinfc = {
whereiscompcmd = *ifmatch "/D:\\work\\memo/",%1 %: *comment all extract,%(%*script(%0Script\gethowmtitle.js,%FCD)%) %: *script %0Script\dotcomment.js
}
0 件のコメント:
コメントを投稿