Skip to content

Instantly share code, notes, and snippets.

@satyr
Created March 4, 2009 17:33
Show Gist options
  • Save satyr/73913 to your computer and use it in GitHub Desktop.
Save satyr/73913 to your computer and use it in GitHub Desktop.
Sets the maximum number of suggestions.
const PMaxSugg = 'extensions.ubiquity.maxSuggestions', {prefs} = Application;
Components.utils.import('resource://ubiquity/modules/parser/parser.js');
NLParser.MAX_SUGGESTIONS = Math.max(prefs.getValue(PMaxSugg, 5), 1);
CmdUtils.CreateCommand({
name: 'max-suggestions',
icon: 'chrome://ubiquity/skin/icons/favicon.ico',
takes: {'1+': {_name: '1+',
suggest: function(n, h, c, s)(
/^[1-9]\d*$/.test(n)
? [CmdUtils.makeSugg(0, 0, n > 0 ? n | 0 : NLParser.MAX_SUGGESTIONS, s)]
: []),
}},
description: 'Sets the maximum number of suggestions.',
help: PMaxSugg.link('about:config'),
execute: function({data: n}){
if(!n) return;
prefs.setValue(PMaxSugg, NLParser.MAX_SUGGESTIONS = n);
displayMessage({icon: this.icon, title: this.name, text: n});
},
preview: function(pbl, {summary}){
pbl.innerHTML = NLParser.MAX_SUGGESTIONS +' \u2192 '+ summary.bold();
},
previewDelay: 0,
author: 'satyr'.link('http://d.hatena.ne.jp/murky-satyr'), license: 'MIT',
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment