From 11d7df59268c0338ddb91e1d329c65684f2381ad Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Tue, 5 Jun 2012 12:35:50 +0900 Subject: [PATCH 01/11] fix vl alias --- bashrc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bashrc b/bashrc index 3cc0540..3e7c92b 100755 --- a/bashrc +++ b/bashrc @@ -81,7 +81,6 @@ iswindows && alias grep="grep -n" # alias la="ls -A" # alias lla="ls -Al" # alias less="" -# alias vl=/usr/share/vim/vimcurrent/macros/less.sh alias em="emacs -nw" null type vim && alias vi=vim alias pstree="LANG=C pstree" @@ -122,6 +121,12 @@ alias aptin="apt-get install" alias aptsearch="apt-cache search" alias aptshow="apt-cache show" +for f in /usr/share/vim/vimcurrent/macros/less.sh \ + /usr/share/vim/vim73/macros/less.sh +do + test -f $f && alias vl=$f && break +done + alias yt=yaourt null type pacman-color && { alias pacman=pacman-color From 2985b76579c307e6b498e004d1fdee3780a68c33 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Wed, 6 Jun 2012 10:23:09 +0900 Subject: [PATCH 02/11] fix --- bashrc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bashrc b/bashrc index 3e7c92b..c665d30 100755 --- a/bashrc +++ b/bashrc @@ -451,7 +451,7 @@ ip-address(){ __my_prompt_function(){ # used by PS1 # remove __try_exec from function - local lastreturn=$ + local lastreturn=$? if test "${TERM}" == dumb then local c1= @@ -460,7 +460,7 @@ __my_prompt_function(){ # used by PS1 local cdef= else local c1="\e[1;31m" # color for PWD - local c2="\e[36m" # color for user + local c2="\e[36m" # color for user local c3="\e[1;30m" # color for OLDPWD local c4="\e[1;32m" # color for :: local cdef="\e[0m" @@ -491,8 +491,8 @@ __my_prompt_function(){ # used by PS1 printf "${c4}::${cdef} [${c1}${pwd}${cdef}<${c3}${oldpwd}${cdef}]${git}${svn}${battery}${ip}\n" printf "${c4}::${cdef} ${c2}${USER}@${HOSTNAME}${cdef} ${date}\n" printf "${c4}::${cdef} shlv:${SHLVL} dirs:${dirs} last:${lastreturn} " - } + _PS1="\e[32m:: \e[0m[\e[31m\w/\e[0m]\n\ \e[32m:: \e[36m\u@\H \e[0m\d \t bash \v\n\ \e[32m:: \e[0mshlv:${SHLVL} hist:\! last:\$? \$ " From 629acecab017a2ed846adba76d249d8f826d9460 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Wed, 6 Jun 2012 12:42:51 +0900 Subject: [PATCH 03/11] show user.name when git rep dir --- bashrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bashrc b/bashrc index 577ebde..d1ec774 100755 --- a/bashrc +++ b/bashrc @@ -474,7 +474,7 @@ __my_prompt_function(){ # used by PS1 local pwd=$(echo "${PWD}/" | sed -e "s#${HOME}#~#") local oldpwd=$(echo "${OLDPWD}/" | sed -e "s#${HOME}#~#") local jobnum=$(jobs | wc -l) # a strange job exists... - local git=$(__try_exec __git_ps1 [GIT:%s]) + local git="$(__try_exec __git_ps1 "[GIT:$(__try_exec git config --get user.name):%s]")" local date=$(LANG=C __try_exec date +"%a, %d %b %Y %T %z") local dirs=$(dirs | wc -l) fi From 87a3c3aedc73a359c8995b92ae06974955292511 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Thu, 7 Jun 2012 16:12:26 +0900 Subject: [PATCH 04/11] commentout echo-closed-tabs --- _keysnail.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/_keysnail.js b/_keysnail.js index 8358374..a3ca893 100644 --- a/_keysnail.js +++ b/_keysnail.js @@ -435,16 +435,16 @@ ext.add("list-closed-tabs", function () { }); }, "List closed tabs"); -ext.add("echo-closed-tabs", function () { - var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); - var json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON); - // var closedTabs = [[tab.image || fav, tab.title, tab.url] for each (tab in json.decode(ss.getClosedTabData(window)))]; - var lasttab = json.decode(ss.getClosedTabData(window))[0]; - dump = "" - for (var i in lasttab) { dump += lasttab[i] + "\n"; } - confirm(dump); - -}, "List closed tabs"); +// ext.add("echo-closed-tabs", function () { +// var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); +// var json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON); +// // var closedTabs = [[tab.image || fav, tab.title, tab.url] for each (tab in json.decode(ss.getClosedTabData(window)))]; +// var lasttab = json.decode(ss.getClosedTabData(window))[0]; +// dump = "" +// for (var i in lasttab) { dump += lasttab[i] + "\n"; } +// confirm(dump); + +// }, "List closed tabs"); /////////////////////////////// // http://malblue.tumblr.com/post/349001250/tips-japanese-keysnail-github From 7e4a1e6064a3ab0cc210313c7a86109e4a37bf96 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Thu, 7 Jun 2012 16:15:47 +0900 Subject: [PATCH 05/11] translate message --- _keysnail.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_keysnail.js b/_keysnail.js index a3ca893..0e823e8 100644 --- a/_keysnail.js +++ b/_keysnail.js @@ -424,7 +424,7 @@ ext.add("list-closed-tabs", function () { var closedTabs = [[tab.image || fav, tab.title, tab.url] for each (tab in json.decode(ss.getClosedTabData(window)))]; if (!closedTabs.length) - return void display.echoStatusBar("最近閉じたタブが見つかりませんでした", 2000); + return void display.echoStatusBar("No recently closed tab.", 2000); prompt.selector( { From bd77da83772e6f66aff8536efa7a07aa3b1397b2 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Thu, 7 Jun 2012 18:10:09 +0900 Subject: [PATCH 06/11] add ext list-url --- _keysnail.js | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/_keysnail.js b/_keysnail.js index 0e823e8..d6ead22 100644 --- a/_keysnail.js +++ b/_keysnail.js @@ -158,6 +158,33 @@ plugins.options["twitter_client.use_jmp"] = true; //////////////////////////////////////////// // my ext +ext.add("list-url", function(){ + var urls = []; + var aa = window.content.document.getElementsByTagName("a"); + var text = ""; + for (var i = 0; i < aa.length ; i++) { + if (aa[i].text == "" && aa[i].childNodes[0].nodeName == "IMG"){ + text = "img: " + aa[i].childNodes[0].getAttribute("alt"); + }else{ + text = aa[i].text; + } + urls.push([text, aa[i].href]); + } + + prompt.selector( + { + message : "Select URL", + collection : urls, + width : [35, 65], + header : ["text", "url"], + callback : function (i) { + if (i >= 0) + openUILinkIn(urls[i][1], "tab"); // or current tabshifted window + } + } + ); +}, "list url"); + ext.add("bookmark-delicious", function(){ if (window.loadURI) { loadURI("javascript:(function(){f='http://www.delicious.com/save?url='+encodeURIComponent(window.location.href)+'&title='+encodeURIComponent(document.title)+'¬es='+encodeURIComponent(''+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text))+'&v=6&';a=function(){if(!window.open(f+'noui=1&jump=doclose','deliciousuiv6','location=1,links=0,scrollbars=0,toolbar=0,width=550,height=585'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()"); @@ -297,7 +324,7 @@ ext.add("restart-firefox-add-menu", function(){ const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; var cmdelm = document.createElementNS(XUL_NS, "command"); - cmdelm.setAttribute("id", "my_cmd_restartFirefoxKs") + cmdelm.setAttribute("id", "my_cmd_restartFirefoxKs"); cmdelm.setAttribute("oncommand", "ext.exec('restart-firefox');"); var commandset = document.getElementById("mainCommandSet"); // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem")); @@ -305,7 +332,7 @@ ext.add("restart-firefox-add-menu", function(){ var menuelm = document.createElementNS(XUL_NS, "menuitem"); menuelm.setAttribute("label", "Restart Firefox"); - menuelm.setAttribute("id", "my_menu_restartFirefoxKs") + menuelm.setAttribute("id", "my_menu_restartFirefoxKs"); menuelm.setAttribute("command", "my_cmd_restartFirefoxKs"); var menu = document.getElementById("menu_FilePopup"); // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem")); From 8ac0ad6821ac4670678c8f9f2b0ad84d86f05322 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Thu, 7 Jun 2012 18:33:53 +0900 Subject: [PATCH 07/11] use alt text if available --- _keysnail.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/_keysnail.js b/_keysnail.js index d6ead22..b1ab414 100644 --- a/_keysnail.js +++ b/_keysnail.js @@ -162,9 +162,17 @@ ext.add("list-url", function(){ var urls = []; var aa = window.content.document.getElementsByTagName("a"); var text = ""; + var alt = ""; for (var i = 0; i < aa.length ; i++) { - if (aa[i].text == "" && aa[i].childNodes[0].nodeName == "IMG"){ - text = "img: " + aa[i].childNodes[0].getAttribute("alt"); + if(aa[i].href == ""){ continue; } + + if (aa[i].text == "" && aa[i].hasChildNodes() && aa[i].childNodes[0].nodeType == Node.ELEMENT_NODE){ + alt = aa[i].childNodes[0].getAttribute("alt"); + if (alt != null){ + text = aa[i].childNodes[0].nodeName + ": " + alt; + }else{ + text = ""; + } }else{ text = aa[i].text; } From 2fb8db1c88240aa4beccd3495f3a79c7d8d31f7a Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Thu, 7 Jun 2012 18:51:58 +0900 Subject: [PATCH 08/11] use decodeURIComponent for easy read --- _keysnail.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/_keysnail.js b/_keysnail.js index b1ab414..e47e109 100644 --- a/_keysnail.js +++ b/_keysnail.js @@ -168,15 +168,11 @@ ext.add("list-url", function(){ if (aa[i].text == "" && aa[i].hasChildNodes() && aa[i].childNodes[0].nodeType == Node.ELEMENT_NODE){ alt = aa[i].childNodes[0].getAttribute("alt"); - if (alt != null){ - text = aa[i].childNodes[0].nodeName + ": " + alt; - }else{ - text = ""; - } + text = " " + aa[i].childNodes[0].nodeName + (alt ? ": " + alt : ""); }else{ text = aa[i].text; } - urls.push([text, aa[i].href]); + urls.push([text, decodeURIComponent(aa[i].href)]); } prompt.selector( From 9a7aa10a3113fc618fe310dfaff33484b04039c9 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Thu, 7 Jun 2012 19:19:08 +0900 Subject: [PATCH 09/11] rewrite delicious bookmarklet into normal code --- _keysnail.js | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/_keysnail.js b/_keysnail.js index e47e109..69fb8e8 100644 --- a/_keysnail.js +++ b/_keysnail.js @@ -175,23 +175,39 @@ ext.add("list-url", function(){ urls.push([text, decodeURIComponent(aa[i].href)]); } - prompt.selector( - { - message : "Select URL", - collection : urls, - width : [35, 65], - header : ["text", "url"], - callback : function (i) { - if (i >= 0) - openUILinkIn(urls[i][1], "tab"); // or current tabshifted window + if(urls.length == 0){ + display.echoStatusBar("No url found."); + }else{ + prompt.selector( + { + message : "Select URL", + collection : urls, + width : [35, 65], + header : ["text", "url"], + callback : function (i) { + if (i >= 0) + openUILinkIn(urls[i][1], "tab"); // or current tabshifted window + } } - } - ); + ); + } }, "list url"); ext.add("bookmark-delicious", function(){ - if (window.loadURI) { - loadURI("javascript:(function(){f='http://www.delicious.com/save?url='+encodeURIComponent(window.location.href)+'&title='+encodeURIComponent(document.title)+'¬es='+encodeURIComponent(''+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text))+'&v=6&';a=function(){if(!window.open(f+'noui=1&jump=doclose','deliciousuiv6','location=1,links=0,scrollbars=0,toolbar=0,width=550,height=585'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()"); + f= 'http://www.delicious.com/save?url=' + encodeURIComponent(window.location.href) + + '&title=' + encodeURIComponent(document.title) + + '¬es=' + encodeURIComponent('' + (window.getSelection ? + window.getSelection() : document.getSelection ? + document.getSelection() : document.selection.createRange().text)) + '&v=6&'; + a = function(){ + if(! window.open(f + 'noui=1&jump=doclose', 'deliciousuiv6', 'location=1,links=0,scrollbars=0,toolbar=0,width=710,height=660')){ + location.href = f + 'jump=yes'; + }; + } + if(/Firefox/.test(navigator.userAgent)){ + setTimeout(a,0); + }else{ + a(); } }, "bookmark delicious"); From a1e1c43033c1a4963ae23ef2bd500a5946e1b7f2 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Thu, 7 Jun 2012 21:20:43 +0900 Subject: [PATCH 10/11] put proper semicolon --- _keysnail.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_keysnail.js b/_keysnail.js index 69fb8e8..aca3962 100644 --- a/_keysnail.js +++ b/_keysnail.js @@ -202,8 +202,8 @@ ext.add("bookmark-delicious", function(){ a = function(){ if(! window.open(f + 'noui=1&jump=doclose', 'deliciousuiv6', 'location=1,links=0,scrollbars=0,toolbar=0,width=710,height=660')){ location.href = f + 'jump=yes'; - }; - } + } + }; if(/Firefox/.test(navigator.userAgent)){ setTimeout(a,0); }else{ From 969606952f4134c00531ecf25d85eea59b19c3d9 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Thu, 7 Jun 2012 21:30:41 +0900 Subject: [PATCH 11/11] fix my-dired-xx-line --- emacs.el | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/emacs.el b/emacs.el index b188889..8cf5763 100644 --- a/emacs.el +++ b/emacs.el @@ -1010,7 +1010,7 @@ Return nil if library unfound and failed to download, otherwise the path where t (progn (message "calculating du...") (shell-command (concat "du -hsD " - f))) + (shell-quote-argument f)))) (shell-command (concat "file " f))))) @@ -1032,8 +1032,8 @@ Return nil if library unfound and failed to download, otherwise the path where t (dired-previous-line 1) (when (eq (line-number-at-pos) 2) - (goto-line (- (line-number-at-pos (point-max)) - 1)) + (goto-char (point-max)) + (forward-line -1) (dired-move-to-filename)) (my-dired-previous-line (- arg 1)) )) @@ -1046,7 +1046,8 @@ Return nil if library unfound and failed to download, otherwise the path where t (dired-next-line 1) (when (eq (point) (point-max)) - (goto-line 3) + (goto-char (point-min)) + (forward-line 2) (dired-move-to-filename)) (my-dired-next-line (- arg 1)) ))