From 7d939adf116e2b71c36da59473b2d4ed50af4c01 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Fri, 25 Nov 2011 09:52:33 -0500 Subject: [PATCH] Add 'yankshort' option. --- common/content/dactyl.js | 5 ++++- common/locale/en-US/options.xml | 11 +++++++++++ common/modules/buffer.jsm | 9 +++++++-- common/modules/options.jsm | 4 +++- pentadactyl/NEWS | 1 + 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/common/content/dactyl.js b/common/content/dactyl.js index 80386310..bd602330 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -1431,7 +1431,10 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { setter: function (value) { let win = document.documentElement; function updateTitle(old, current) { - document.title = document.title.replace(RegExp("(.*)" + util.regexp.escape(old)), "$1" + current); + if (config.browser.updateTitlebar) + config.browser.updateTitlebar(); + else + document.title = document.title.replace(RegExp("(.*)" + util.regexp.escape(old)), "$1" + current); } if (services.has("privateBrowsing")) { diff --git a/common/locale/en-US/options.xml b/common/locale/en-US/options.xml index 5b749ef2..6de3231b 100644 --- a/common/locale/en-US/options.xml +++ b/common/locale/en-US/options.xml @@ -1811,6 +1811,17 @@ + + 'ys' 'yankshort' + 'yankshort' 'ys' + &option.yankshort.type; + &option.yankshort.default; + +

Yank the canonical short URL of a web page where provided.

+
+
+ + diff --git a/common/modules/buffer.jsm b/common/modules/buffer.jsm index 94408494..54ae9443 100644 --- a/common/modules/buffer.jsm +++ b/common/modules/buffer.jsm @@ -1835,8 +1835,9 @@ var Buffer = Module("Buffer", { mappings.add([modes.NORMAL], ["y", ""], "Yank current location to the clipboard", function () { - let link = DOM("link[href][rev=canonical], link[href][rel=shortlink]", buffer.doc); - let url = link.length ? link.attr("href") : buffer.uri.spec; + let { doc, uri } = buffer; + let link = DOM("link[href][rev=canonical], link[href][rel=shortlink]", doc); + let url = link.length && options.get("yankshort").getKey(uri) ? link.attr("href") : uri.spec; dactyl.clipboardWrite(url, true); }); @@ -2329,6 +2330,10 @@ var Buffer = Module("Buffer", { setter: function (value) buffer.contentViewer.authorStyleDisabled = value, getter: function () buffer.contentViewer.authorStyleDisabled }); + + options.add(["yankshort", "ys"], + "Yank the canonical short URL of a web page where provided", + "sitelist", ["youtube.com", "bugzilla.mozilla.org"]); } }); diff --git a/common/modules/options.jsm b/common/modules/options.jsm index 4651ee94..bcbf32f2 100644 --- a/common/modules/options.jsm +++ b/common/modules/options.jsm @@ -336,7 +336,9 @@ var Option = Class("Option", { if (this.type === "string") defaultValue = Commands.quote(defaultValue); - if (isObject(defaultValue)) + if (isArray(defaultValue)) + defaultValue = defaultValue.map(Option.quote).join(","); + else if (isObject(defaultValue)) defaultValue = iter(defaultValue).map(function (val) val.map(Option.quote).join(":")).join(","); if (isArray(defaultValue)) diff --git a/pentadactyl/NEWS b/pentadactyl/NEWS index 7cb8046b..3c981613 100644 --- a/pentadactyl/NEWS +++ b/pentadactyl/NEWS @@ -251,6 +251,7 @@ - Added 'spelllang' option. [b8] - Make 'showmode' a [stringlist] option. [b7] - Added 'wildanchor' option. [b2] + - Added 'yankshort' option. [b8] • Added BookmarkChange, BookmarkRemove autocommands. [b2] • Removed the :source line at the end of files generated by :mkpentadactylrc. [b2]