牌語備忘録 -pygo

あくまでもメモです。なるべくオフィシャルの情報を参照してください。

牌語備忘録 -pygo

Emacs からバックグラウンドの Google Chrome を Applescript で次と前のタブに移動するメモ(MacOS only)

(Emacs24.3, MacOSX10.8)

リロードさせるやつと、スクロールのやつの続き

Applescript

下記リンクのコードそのまま

next-tab-chrome.scpt
tell application "Google Chrome"
	set maxIndex to count tabs of (first window)
	set currentIndex to active tab index of (first window)
	set proposedIndex to currentIndex + 1
	if proposedIndex < 1 then set proposedIndex to maxIndex
	if proposedIndex > maxIndex then set proposedIndex to 1
	set (active tab index of (first window)) to proposedIndex
end tell
previous-tab-chrome.scpt
tell application "Google Chrome"
	set maxIndex to count tabs of (first window)
	set currentIndex to active tab index of (first window)
	set proposedIndex to currentIndex - 1
	if proposedIndex < 1 then set proposedIndex to maxIndex
	if proposedIndex > maxIndex then set proposedIndex to 1
	set (active tab index of (first window)) to proposedIndex
end tell

Emacs lisp

init.el
  (defun next-tab-chrome ()
    (interactive)
    (shell-command "osascript ~/.emacs.d/site-macosx/next-tab-chrome.scpt")
    (message "next-tab-chrome")
    )
  (global-set-key (kbd "<M-s-right>") 'next-tab-chrome)

  (defun previous-tab-chrome ()
    (interactive)
    (shell-command "osascript ~/.emacs.d/site-macosx/previous-tab-chrome.scpt")
    (message "previous-tab-chrome")
    )
  (global-set-key (kbd "<M-s-left>") 'previous-tab-chrome)

こんな感じ