Created
May 7, 2017 07:10
-
-
Save smallst/c838d0000e413bf5ff6b0b9ab902dc43 to your computer and use it in GitHub Desktop.
use `my-moz-setup` for selecting refresh tab when save web files in firefox with mozrepl
This file contains hidden or 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
(defun my-ivy-list (retstring) | |
"firefox pages" | |
(interactive) | |
(let (collection) | |
(unless recentf-mode (recentf-mode 1)) | |
(setq collection (split-string retstring "\n" t)) | |
(ivy-read "pages:" collection :action (lambda (x) | |
(comint-send-string (inferior-moz-process) (concat "refreshtab=repl.tabs[" (number-to-string (cl-position x (split-string retstring "\n" t) :test 'equal)) "];")))))) | |
(defun my-moz-setup () | |
(interactive) | |
(comint-send-string (inferior-moz-process) "var refreshtab;") | |
(set-process-filter (get-buffer-process "*MozRepl*") 'moz-controller-repl-filter) | |
(comint-send-string (inferior-moz-process) "repl.show_tab();") | |
(sleep-for 0.1) | |
(my-ivy-list moz-controller-repl-output)) | |
This file contains hidden or 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
var startedAt = new Date(); | |
if(this._workContext instanceof Ci.nsIDOMWindow) | |
var window = this._workContext; | |
else | |
throw new Error('Not in a window.'); | |
var tabContainer; | |
var tabs; | |
function show_tab() { | |
tabContainer = window.getBrowser().tabContainer; | |
tabs = tabContainer.childNodes; | |
let numTabs = tabs.length; | |
let startIndex = tabContainer.selectedIndex; | |
let output = ""; | |
for (let i = 0; i < numTabs; i++) { | |
output = output +tabs[i].label+"\n"; | |
} | |
this.print(output); | |
} | |
function switch_tab (tab) { | |
tabContainer = window.getBrowser().tabContainer; | |
tabContainer.selectedItem = tab; | |
/* let tabs = tabContainer.childNodes; | |
let numTabs = tabs.length; | |
let startIndex = tabContainer.selectedIndex; | |
let testIndex; | |
for (let i = 0; i < numTabs; i++) { | |
testIndex= (startIndex +i) % numTabs; | |
if (tabs[testIndex].label.match(new RegExp(title))) { | |
tabContainer.selectedItem = tabs[testIndex]; | |
break; | |
} | |
}*/ | |
} | |
function semanticselecttab(url) { | |
repl.whereAmI(); | |
var numTabs=gBrowser.browsers.length; | |
for(i=0; i<numTabs-1; i++) { | |
if(gBrowser.browsers[i].contentDocument.location.href.indexOf(url)>=0) { | |
gBrowser.tabContainer.selectedIndex=i; | |
break; | |
} | |
} | |
} | |
function next_tab(title_re) { | |
var tabContainer = window.getBrowser().tabContainer; | |
var tabs = tabContainer.childNodes; | |
var numTabs = tabs.length; | |
var startIndex = tabContainer.selectedIndex; | |
var testIndex; | |
for (i = 0; i < numTabs - 1; i++) { | |
testIndex = (startIndex + i + 1) % numTabs; | |
if (tabs[testIndex].label.match(title_re)) { | |
tabContainer.selectedItem = tabs[testIndex]; | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment