1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 17:27:58 +01:00

Push location stack on //?/n/N/[/].

This commit is contained in:
Kris Maglione
2011-08-11 03:44:22 -04:00
parent a5c442150b
commit d877fa5fea
4 changed files with 27 additions and 14 deletions

View File

@@ -13,7 +13,7 @@ update(AutoCommand.prototype, {
eventName: Class.memoize(function () this.event.toLowerCase()),
match: function (event, pattern) {
return (!event || this.eventName == event.toLowerCase()) && (!pattern || String(this.filter) === pattern);
return (!event || this.eventName == event.toLowerCase()) && (!pattern || String(this.filter) === String(pattern));
}
});
@@ -43,24 +43,26 @@ var AutoCmdHive = Class("AutoCmdHive", Contexts.Hive, {
},
/**
* Returns all autocommands with a matching *event* and *regexp*.
* Returns all autocommands with a matching *event* and *filter*.
*
* @param {string} event The event name filter.
* @param {string} pattern The URL pattern filter.
* @param {string} filter The URL pattern filter.
* @returns {[AutoCommand]}
*/
get: function (event, pattern) {
return this._store.filter(function (autoCmd) autoCmd.match(event, regexp));
get: function (event, filter) {
filter = filter && String(Group.compileFilter(filter));
return this._store.filter(function (autoCmd) autoCmd.match(event, filter));
},
/**
* Deletes all autocommands with a matching *event* and *regexp*.
* Deletes all autocommands with a matching *event* and *filter*.
*
* @param {string} event The event name filter.
* @param {string} regexp The URL pattern filter.
* @param {string} filter The URL pattern filter.
*/
remove: function (event, regexp) {
this._store = this._store.filter(function (autoCmd) !autoCmd.match(event, regexp));
remove: function (event, filter) {
filter = filter && String(Group.compileFilter(filter));
this._store = this._store.filter(function (autoCmd) !autoCmd.match(event, filter));
},
});
@@ -178,7 +180,7 @@ var AutoCommands = Module("autocommands", {
commands.add(["au[tocmd]"],
"Execute commands automatically on events",
function (args) {
let [event, regexp, cmd] = args;
let [event, filter, cmd] = args;
let events = [];
if (event) {
@@ -193,9 +195,9 @@ var AutoCommands = Module("autocommands", {
if (args.length > 2) { // add new command, possibly removing all others with the same event/pattern
if (args.bang)
args["-group"].remove(event, regexp);
args["-group"].remove(event, filter);
cmd = contexts.bindMacro(args, "-ex", function (params) params);
args["-group"].add(events, regexp, cmd);
args["-group"].add(events, filter, cmd);
}
else {
if (event == "*")
@@ -204,10 +206,10 @@ var AutoCommands = Module("autocommands", {
if (args.bang) {
// TODO: "*" only appears to work in Vim when there is a {group} specified
if (args[0] != "*" || args.length > 1)
args["-group"].remove(event, regexp); // remove all
args["-group"].remove(event, filter); // remove all
}
else
autocommands.list(event, regexp, args.explicitOpts["-group"] ? [args["-group"]] : null); // list all
autocommands.list(event, filter, args.explicitOpts["-group"] ? [args["-group"]] : null); // list all
}
}, {
bang: true,

View File

@@ -832,6 +832,8 @@ var Buffer = Module("buffer", {
findJump: function findJump(arg, count, reverse, offScreen) {
const FUDGE = 10;
marks.push();
let path = options["jumptags"][arg];
dactyl.assert(path, _("error.invalidArgument", arg));

View File

@@ -44,6 +44,10 @@ var Marks = Module("marks", {
params.offset = buffer.scrollPosition;
params.path = util.generateXPath(buffer.findScrollable(0, params.offset.x));
params.timestamp = Date.now() * 1000;
params.equals = function (m) this.location == m.location
&& this.offset.x == m.offset.x
&& this.offset.y == m.offset.y
&& this.path == m.path;
return params;
},
@@ -90,6 +94,8 @@ var Marks = Module("marks", {
return;
let mark = this.add("'");
if (jump && mark.equals(jump.mark))
return;
if (!this.jumping) {
store.jumps[++store.jumpsIndex] = { mark: mark, reason: reason };

View File

@@ -45,6 +45,7 @@ var RangeFinder = Module("rangefinder", {
get options() this.modules.options,
openPrompt: function (mode) {
this.modules.marks.push();
this.commandline;
this.CommandMode(mode).open();
@@ -103,6 +104,7 @@ var RangeFinder = Module("rangefinder", {
},
find: function (pattern, backwards) {
this.modules.marks.push();
let str = this.bootstrap(pattern, backwards);
if (!this.rangeFind.find(str))
this.dactyl.echoerr(_("finder.notFound", pattern),
@@ -112,6 +114,7 @@ var RangeFinder = Module("rangefinder", {
},
findAgain: function (reverse) {
this.modules.marks.push();
if (!this.rangeFind)
this.find(this.lastFindPattern);
else if (!this.rangeFind.find(null, reverse))