javascript - Manage firefox tabs in emacs with org-mode -


i find way manage firefox tab in emacs. sounds little crazy. use tree style tabs(firefox addon), moz repl, emacs, org-mode it.

for 10-15 tabs, plan works fine. 20+ tabs, firefox hangs randomly. maybe javascript stack overflow or else? don't know what's wrong code. post import code here. somesone me find bugs?

it's basic firefox chrome code below, can run in firefox without emacs , mozpepl.

i use tree style tabs api tabs , set each tab cetain level. output used in emacs org-mode. tree style tabs api: http://piro.sakura.ne.jp/xul/_treestyletab.html.en#api

the code can run in many ways. recommend "workspace addon". copy code, choose chrome context run it. https://addons.mozilla.org/en-us/firefox/addon/workspace/

// 2 helper function title , url of tab function gettitle(tab) {      var brower = gbrowser.getbrowserfortab(tab)     var url = brower.currenturi.spec     var title = brower.contenttitle     return title } function geturl(tab) {      var brower = gbrowser.getbrowserfortab(tab)     var url = brower.currenturi.spec     var title = brower.contenttitle     return ":properties:\n:url:"+url+"\n:end:\n" }  var l = gbrowser.tabcontainer.childnodes.length //firefox tabs length var str = "" //global string output  //parse tabs. if tab has child, parse it. tab has no child, output. for(i = 0; < l; i++){     level = "*"     tab = gbrowser.tabcontainer.childnodes[i]     if ('treestyletabservice' in window){     if(treestyletabservice.haschildtabs(tab))     {       str = [str, level, " [+] ",  gettitle(tab), "\n", geturl(tab)].join("") //output title , url. level used in org-mode       treeparse(treestyletabservice.getchildtabs(tab), "**") //if tab has child tabs. parse , level     }    str = [str, level, " ",  gettitle(tab), "\n", geturl(tab)].join("") }  function treeparse(tablist,level) //parse list of tabs. if tab has not child, output. if has childs, parse again {     for(i=0 ; < tablist.length;i++) {     tab = tablist[i]     if ('treestyletabservice' in window){         if(treestyletabservice.haschildtabs(tab))         {         str = [str, level, " [+] ",  gettitle(tab), "\n", geturl(tab)].join("")         newlevel = level + "*"         treeparse(treestyletabservice.getchildtabs(tab),newlevel)                }         } }     str = [str, level, " ",  gettitle(tab), "\n", geturl(tab)].join("")     } }  alert(str) //alert view result. can write result file. 

i'm not sure what's causing problem, couldn't reproduce it, see loads of issues code. can't remember how mozrepl works, improved code should give nice org-mode friendly tab output. hope helps you, or whoever stumbles across thread.

var bullet = "*"; // org-mode bullet  // 2 helper function title , url of tab function gettitle(tab) {      var brower = gbrowser.getbrowserfortab(tab);     var url = brower.currenturi.spec;     var title = brower.contenttitle;     return title; }  function geturl(tab) {      var brower = gbrowser.getbrowserfortab(tab);     var url = brower.currenturi.spec;     var title = brower.contenttitle;     return ":properties:\n:url:"+url+"\n:end:\n"; }  // note: factor these string-generation functions out, // make things bit more clear function makeparentnodeoutput(tab, level) {     return (array(level+1).join(bullet) +         " [+] " +         gettitle(tab) +         "\n" +         geturl(tab)); }  function makeleafnodeoutput(tab, level) {     return (array(level+1).join(bullet) +         " " +         gettitle(tab) +         "\n" +         geturl(tab)); }  // note: need handle parsing collection of tabs // in once place, , have function here. function parsetabcollection(tabs, level) {     var currenttab;     var outputstring = "";     for(var = 0; < tabs.length; i++){         currenttab = tabs[i];          // parent node, output node , children         if(treestyletabservice.haschildtabs(currenttab)){             outputstring += makeparentnodeoutput(currenttab, level);             outputstring += parsetabcollection(                 treestyletabservice.getchildtabs(currenttab),                 level + 1             );         } else {             outputstring += makeleafnodeoutput(currenttab, level);         }     }     return outputstring; }  if ('treestyletabservice' in window){     //note: start roottabs only. old version started     // *all* tabs, isn't want     var orgmodeoutput = parsetabcollection(treestyletabservice.roottabs, 1);     alert(orgmodeoutput); } 

i hope helps somehow.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -