Tex-Edit Plus を Mail.app と併用します。

 ApplescriptTex-Edit Plus を Mail.app と併用するための2つのアップルスクリプトです:

  • Tex-Edit Plus 書類内で選択されたテキストを新規メールメッセージ内で開くためのアップルスクリプト
  • Mail.app のメッセージ内のテキストを Tex-Edit Plus の新規書類内で開くためのアップルスクリプト


使用方法:

1)Tex-Edit Plus 内のスクリプトの場合

  1. Tex-Edit Plus の書類内でテキストを選択します。
  2. Tex-Edit Plus のスクリプトメニューからアップルスクリプトを選択します(キーボードショートカットでアップルスクリプトを実行させることもできます)。
  3. 選択テキストは Mail.app の新規メッセージ内で開かれます。


2)Mail.app 内のスクリプトの場合

  1. Maill.app 内でメッセージを選択します。
  2. アップルスクリプトを実行します(システムの「スクリプトメニュー」に追加すると便利です)。
  3. 選択されたメッセージ内のテキストは Tex-Edit Plus


スクリプトの作成方法

  1. 下記のテキストをアップルのスクリプトエディタアプリケーションの新規書類へコピーします。
  2. スクリプトエディタのファイルメニューの「保存...」コマンドを選択します。
  3. 表示される保存ダイアログでアプリケーション名を入力して、保存場所を選択します。
  4. 保存ダイアログの「フォーマット」ポップアップメニューから「スクリプト」オプションを選択します。
  5. 保存ダイアログの「オプション」セクションの「実行専用」チェックボックスを選択します。
  6. 保存ダイアログの「保存」ボタンをクリックします。


Tex-Edit Plus 書類内で選択されたテキストを新規メールメッセージ内で開きます

tell application "Tex-Edit Plus"
	if exists front window then
		tell front window
			if selection is "" then
				set x to contents
			else
				set x to selection
			end if
		end tell
	end if
end tell

tell application "Mail"
	activate
	set newMessage to make new outgoing message with properties {content:x & return & return}
	tell newMessage
		set visible to true
	end tell
end tell


Mail.app のメッセージ内のテキストを Tex-Edit Plus の新規書類内で開きます

tell application "Mail"
	if selection is not {} then
		set fMessage to selection
		if (count items of fMessage) is 1 then
			tell first item of fMessage
				set {cont, sndr, dat, subj} to {content, sender, date sent, subject}
			end tell
		else
			display dialog "メールメッセージを選択して下さい。" buttons {"キャンセル"} default button 1 giving up after 15
		end if
	else
		display dialog "Mail 内のメッセージは選択されていません。" buttons {"キャンセル"} default button 1 giving up after 15
	end if
end tell

tell application "Tex-Edit Plus"
	
	make new window with properties {contents:cont}
	tell window 1
		replace window 1 looking for "^l" replacing with "^c"
		block format contents with leading line "-------------------" with trailing line "-------------------" with line header ""
		select insertion point before first character
	end tell
	select contents of window 1
	set font of selection to default font
	set size of selection to default size
	select insertion point after selection
	
end tell



参考1:

Tex-Edit Plus を起動する時に「Scripts」フォルダに入っているコンパイル済みスクリプトは全て「スクリプト」メニュー内で表示されます。「Scripts」フォルダは Tex-Edit Plus アプリケーションと同じフォルダに入っていないとこの機能は無効になります。また、「Scripts」フォルダの名前を変更するとこの機能は無効になります。AppleScripts for Tex-Edit Archive のホームページから多数の Tex-Edit Plus 用アップルスクリプトをダウンロードすることもできます。

Tex-Edit Plus のスクリプトメニュー内のアップルスクリプトのキーボードショートカット設定(※すべて半角ローマ字で設定します)

  • コマンド:スクリプト名の最後に「_」(1つ)を追加します(例:私のスクリプト_0)。
  • シフト+コマンド:「__」(2つ)を追加します(例:私のスクリプト__0)。
  • ファンクションキー:「_」(1つ)+ F キーを追加します(例:私のスクリプト__F5)。
  • コマンド+ファンクションキー:「__」(2つ)+ F キーを追加します(例:私のスクリプト__F5)。
  • シフト+コマンド+ファンクションキー:「___」(3つ)+ F キーを追加します(例:私のスクリプト___F5)。


参考2:

システムのスクリプトメニューとは

スクリプトメニューを使用して、ファインダーのメニューバーからアップルスクリプトを起動することができます。スクリプトメニューでさまざまなスクリプトに簡単にアクセスできます。

スクリプトメニューへ自分のスクリプトを自由に追加することもできます。

スクリプトメニューについて詳しくは、Mac OS X の「AppleScript ヘルプ」を参照するか、アップルスクリプトのウェブサイトにアクセスしてください。

スクリプトメニューを表示する

  1. 「AppleScript ユーティリティ」を使用してスクリプトメニューを表示するには:
  2. 「アプリケーション/AppleScript」にある「AppleScript ユーティリティ」を開きます。
  3. 「メニューバーにスクリプトメニューを表示」チェックボックスにチェックマークを付けます。


スクリプトメニューにスクリプトを追加する

スクリプトメニューは、動的に構築され、簡単にカスタマイズできます。スクリプトは、「~/ライブラリ/Scripts」内に格納されます。(「Scripts」フォルダは、ホームフォルダの「ライブラリ」フォルダ内にあります。)

スクリプトメニューにさらにスクリプトを追加する場合は、スクリプトまたは多数のスクリプトを含むフォルダを「~/ライブラリ/Scripts」フォルダに追加します。これで、追加したスクリプトがスクリプトメニューに表示されます。

スクリプトメニューにスクリプトを追加するには:

  1. ファインダーのメニューバーでスクリプトメニューをクリックします。
  2. 「スクリプトフォルダを開く」を選択します。
  3. 追加したいスクリプトまたはフォルダを選択します。


「Scripts」フォルダ内にフォルダを追加すると、サブメニューが自動的に作成されます。