1
1

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.

LightTableでショートカットキーで任意のコード実行

Posted at

LightTableには:eval.customという任意のコードを実行できる機能があります。

例えばUser keymapに

"ctrl-e" [(:eval.custom "(macroexpand-1 '__SELECTION__)")]

と設定しておくと、ctrl-eで選択中のコードのマクロ展開ができます。
__SELECTION__は選択中のコードで置き換えられます。

実行結果はデフォルトではエディタ内にインラインで表示されます。
出力先を変えたい場合は2番目の引数のマップで:result-typeを指定します。

"ctrl-e" [(:eval.custom "(macroexpand-1 '__SELECTION__)" {:result-type :statusbar})]

:result-typeには以下のものが指定できます。

概要
:inline エディタ内にインライン表示(デフォルト)
:statusbar ステータスバーに表示
:silent 表示しない
:replace 選択中のコードを実行結果で置き換え

また、その他のオプションとして以下も指定できるようです。(試してませんが)

オプション 概要
:verbatim 実行結果にpr-strを適用するか否か(true/falseを指定)
:ns 実行するネームスペースを文字列で指定
:class 表示部分に適用するCSSクラスを文字列で指定

 
また、:eval.customの他にも:editor.watch.custom-watch-selectionでWatchのカスタマイズもできるようです。
詳細はこのページを参照してください。

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?