1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 14:08:11 +01:00

saving abbreviations with :mkvimperatorrc works; also added :source! ~/.vimperatorrc.local to :mkv

This commit is contained in:
Martin Stubenschrott
2007-11-02 00:57:13 +00:00
parent baebe6978c
commit 5dac5326a5
3 changed files with 33 additions and 8 deletions

View File

@@ -1311,13 +1311,12 @@ vimperator.Commands = function() //{{{
addDefaultCommand(new vimperator.Command(["mkv[imperatorrc]"],
function(args, special)
{
var filename;
// TODO: "E172: Only one file name allowed"
var filename;
if (args)
filename = args;
else
filename = vimperator.io.expandPath(navigator.platform == "Win32" ? "~/_vimperatorrc" : "~/.vimperatorrc");
filename = (navigator.platform == "Win32") ? "~/_vimperatorrc" : "~/.vimperatorrc";
var file = vimperator.io.getFile(filename);
if (file.exists() && !special)
@@ -1327,6 +1326,7 @@ vimperator.Commands = function() //{{{
}
var line = "\" " + vimperator.version + "\n";
line += "\" Mappings\n";
// TODO: write user maps for all modes when we have mode dependant map support
for (var map in vimperator.mappings.getUserIterator(vimperator.modes.NORMAL))
@@ -1335,6 +1335,7 @@ vimperator.Commands = function() //{{{
line += "map " + map.names[i] + " " + map.rhs + "\n";
}
line += "\n\" Options\n";
for (var option in vimperator.options)
{
// TODO: options should be queried for this info
@@ -1348,7 +1349,13 @@ vimperator.Commands = function() //{{{
}
}
line += "\" vim: set ft=vimperator:";
line += "\n\" Abbreviations\n";
for (var abbrCmd in vimperator.editor.abbreviations)
line += abbrCmd;
// source a user .vimperatorrc file
line += "\nsource! " + filename + ".local\n"
line += "\n\" vim: set ft=vimperator:";
vimperator.io.writeFile(file, line);
},
@@ -1851,7 +1858,7 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["so[urce]"],
function(args)
function(args, special)
{
// FIXME: implement proper filename quoting
//if (/[^\\]\s/.test(args))
@@ -1860,7 +1867,7 @@ vimperator.Commands = function() //{{{
// return;
//}
vimperator.source(args);
vimperator.source(args, special);
},
{
usage: ["so[urce][!] {file}"],

View File

@@ -394,7 +394,18 @@ vimperator.Editor = function() //{{{
}
// Abbreviations {{{
// TODO: won't save into vimperatorrc? with mkvimperatorrc
// FIXME: iabbr foo bar and cabbr foo abc can't exist at the same time.
this.abbreviations = {};
this.abbreviations.__iterator__ = function ()
{
var tmpCmd;
for (var item in abbrev)
{
tmpCmd = (abbrev[item][1] == "!") ? "abbreviate" : abbrev[item][1] + "abbrev";
yield (tmpCmd + " " + item + " " + abbrev[item][0] + "\n");
}
}
// filter is i, c or "!" (insert or command abbreviations or both)
this.listAbbreviations = function(filter, lhs)

View File

@@ -500,8 +500,15 @@ const vimperator = (function() //{{{
try
{
var file = vimperator.io.getFile(filename);
if (!file.exists())
{
if (!silent)
vimperator.echoerr("E484: Can't open file " + filename);
return false;
}
var str = vimperator.io.readFile(filename);
// handle pure javascript files specially
if (/\.js$/.test(filename))
{