Hi, Björn and others,
There are kinda four things here, and all jumbled up, I'm afraid.
1.
We discussed adding a 'New Window With' submenu a while ago, and I was
reminded of it once again when asked to test the recent MacVim for the
scrolling bug and I couldn't easily do it because my default options
hide scrollbars.
And I thought I'd do something about it apart from just whinge. I
included a 'Vim defaults' and 'Vi defaults' which are basically
'-N -u NONE' and '-u NONE' which are both used fairly regularly on the
Vim mailing list. I also included a 'MacVim defaults' so you can bypass
all your own config, but get MacVim's menus, etc. It works by doing
essentially '-u $VIM/vimrc -U $VIM/gvimrc --noplugin'. To make this a
bit more certain to avoid loading user files, I needed to tweak MacVim's
gvimrc, too.
This should make testing easier, as well as debugging users' Vim
problems.
It's hard to know what here is really necessary, though. Perhaps some
further discussion is in order. It may be that the MacVim defaults is
'good enough' and we don't need the others (and therefore the submenu).
2.
While I was at it, I was looking at other things that might be useful to
set at Vim startup. Ideally there would be a 'New Window With
Arguments...' kind of thing, but I don't have the skills for that, so I
was looking around to see if there was anything else startup-related
that I *could* do. There were a few candidates:
- Debug mode: doesn't work as prompting is done before the GUI starts
- Easy mode: if people want this, they want something other than Vim...
- Readonly mode: easily settable inside Vim so not worth the clutter
- Servername: more useful from a script than the GUI, and I don't have
the skills to do it anyway
- Load a session (or other Vim script): potentially quite handy
So I implemented session load and save commands in the File menu. They
seem to work.
3.
Then I thought it would be nice to be able to double-click a session to
source it rather than use the menu command. So I wrote a little plugin
to do that. It picks up anything that looks like a session file, though,
so could be insecure; for that reason, I made it prompt the user. I
think this is probably a better solution than adding the Open Session
command, though I think the Save Session command is still quite handy.
For now, though, I've just left both in.
Perhaps we can discuss what people think is best for this, too? I think
some kind of session loading and saving in the menus/from the Finder
would definitely be good.
4.
Also note, when I was editing the menus, I saw there was an Interface
Builder minimum OS version option set to 10.5 rather than 10.4, so I
changed it. That might be why the diff is so large. I don't know.
Anyway, it comes with my usual disclaimer: I know neither Objective C
nor Cocoa, so I really have no idea what I'm doing...but...I seem to
have hacked my way through and it seems to work OK. It's attached.
Ben.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_mac" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
diff -r 46ecc5f2a8a4 runtime/doc/gui_mac.txt
--- a/runtime/doc/gui_mac.txt Mon Oct 13 20:05:02 2008 +1100
+++ b/runtime/doc/gui_mac.txt Sat Nov 15 15:18:26 2008 +1100
@@ -451,6 +451,7 @@
Action Description ~
fileOpen: Show "File Open" dialog
+fileOpenSession: Show "File Open Session" dialog
findNext: Search forward using the "Find Pasteboard"
findPrevious: Search backward using the "Find Pasteboard"
fontSizeDown: Decrease font size
@@ -458,6 +459,9 @@
hide: Hide MacVim
miniaturizeAll: Minimize all windows to the dock
newWindow: Open a new (empty) window
+newWindowMacVim: Open a new (empty) window with MacVim defaults
+newWindowVim: Open a new (empty) window with Vim defaults
+newWindowVi: Open a new (empty) window with Vi defaults
orderFrontCharacterPalette: Show the the "Special Characters" dialog
orderFrontFontPanel: Show the Font panel
orderFrontPreferencePanel: Show the Preferences panel
diff -r 46ecc5f2a8a4 runtime/plugin/sessionSource.vim
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/runtime/plugin/sessionSource.vim Sat Nov 15 15:18:26 2008 +1100
@@ -0,0 +1,26 @@
+" Vim plugin for automatically sourcing sessions
+" Maintainer: Ben Schmidt <[EMAIL PROTECTED]>
+" Last Change: 2008 Nov 15
+
+" Exit quickly when:
+" - this plugin was already loaded
+" - when 'compatible' is set
+if exists("loaded_sessionsource") || &cp
+ finish
+endif
+let loaded_sessionsource = 1
+
+augroup sessionsource
+ au!
+ au FileType vim call s:SessionSource()
+augroup END
+
+func! s:SessionSource()
+ if getline('.') == "let SessionLoad = 1"
+ if confirm(expand('%')." looks like a Vim session. Source it?",
+ \ "&Yes\n&No") == 1
+ source %
+ endif
+ endif
+endfunc
+
diff -r 46ecc5f2a8a4 src/MacVim/Actions.plist
--- a/src/MacVim/Actions.plist Mon Oct 13 20:05:02 2008 +1100
+++ b/src/MacVim/Actions.plist Sat Nov 15 15:18:26 2008 +1100
@@ -18,6 +18,8 @@
<string></string>
<key>fileOpen:</key>
<string></string>
+ <key>fileOpenSession:</key>
+ <string></string>
<key>findNext:</key>
<string></string>
<key>findPrevious:</key>
@@ -33,6 +35,12 @@
<key>miniaturizeAll:</key>
<string></string>
<key>newWindow:</key>
+ <string></string>
+ <key>newWindowMacVim:</key>
+ <string></string>
+ <key>newWindowVim:</key>
+ <string></string>
+ <key>newWindowVi:</key>
<string></string>
<key>openWebsite:</key>
<string></string>
diff -r 46ecc5f2a8a4 src/MacVim/English.lproj/MainMenu.nib/classes.nib
--- a/src/MacVim/English.lproj/MainMenu.nib/classes.nib Mon Oct 13 20:05:02 2008 +1100
+++ b/src/MacVim/English.lproj/MainMenu.nib/classes.nib Sat Nov 15 15:18:26 2008 +1100
@@ -1,120 +1,54 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>IBClasses</key>
- <array>
- <dict>
- <key>ACTIONS</key>
- <dict>
- <key>fileOpen</key>
- <string>id</string>
- <key>fontSizeDown</key>
- <string>id</string>
- <key>fontSizeUp</key>
- <string>id</string>
- <key>forceNewWindow</key>
- <string>id</string>
- <key>newWindow</key>
- <string>id</string>
- <key>newWindowAndActivate</key>
- <string>id</string>
- <key>openWebsite</key>
- <string>id</string>
- <key>orderFrontPreferencePanel</key>
- <string>id</string>
- <key>selectNextWindow</key>
- <string>id</string>
- <key>selectPreviousWindow</key>
- <string>id</string>
- <key>showHelp</key>
- <string>id</string>
- <key>showVimHelp</key>
- <string>id</string>
- <key>zoomAll</key>
- <string>id</string>
- </dict>
- <key>CLASS</key>
- <string>MMAppController</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>SUPERCLASS</key>
- <string>NSObject</string>
- </dict>
- <dict>
- <key>CLASS</key>
- <string>RBSplitView</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>OUTLETS</key>
- <dict>
- <key>delegate</key>
- <string>id</string>
- </dict>
- <key>SUPERCLASS</key>
- <string>RBSplitSubview</string>
- </dict>
- <dict>
- <key>CLASS</key>
- <string>RBSplitSubview</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>SUPERCLASS</key>
- <string>NSView</string>
- </dict>
- <dict>
- <key>CLASS</key>
- <string>NSMenu</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>SUPERCLASS</key>
- <string>NSObject</string>
- </dict>
- <dict>
- <key>ACTIONS</key>
- <dict>
- <key>_cycleWindows</key>
- <string>id</string>
- <key>_cycleWindowsBackwards</key>
- <string>id</string>
- <key>addNewTab</key>
- <string>id</string>
- </dict>
- <key>CLASS</key>
- <string>FirstResponder</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>SUPERCLASS</key>
- <string>NSObject</string>
- </dict>
- <dict>
- <key>ACTIONS</key>
- <dict>
- <key>didAdjustSubviews</key>
- <string>RBSplitView</string>
- <key>willAdjustSubviews</key>
- <string>RBSplitView</string>
- </dict>
- <key>CLASS</key>
- <string>NSObject</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- </dict>
- <dict>
- <key>ACTIONS</key>
- <dict>
- <key>checkForUpdates</key>
- <string>id</string>
- </dict>
- <key>CLASS</key>
- <string>SUUpdater</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>SUPERCLASS</key>
- <string>NSObject</string>
- </dict>
- </array>
- <key>IBVersion</key>
- <string>1</string>
-</dict>
-</plist>
+{
+ IBClasses = (
+ {
+ ACTIONS = {"_cycleWindows" = id; "_cycleWindowsBackwards" = id; addNewTab = id; };
+ CLASS = FirstResponder;
+ LANGUAGE = ObjC;
+ SUPERCLASS = NSObject;
+ },
+ {
+ ACTIONS = {
+ fileOpen = id;
+ fileOpenSession = id;
+ fontSizeDown = id;
+ fontSizeUp = id;
+ forceNewWindow = id;
+ newWindow = id;
+ newWindowAndActivate = id;
+ newWindowMacVim = id;
+ newWindowVi = id;
+ newWindowVim = id;
+ openWebsite = id;
+ orderFrontPreferencePanel = id;
+ selectNextWindow = id;
+ selectPreviousWindow = id;
+ showHelp = id;
+ showVimHelp = id;
+ zoomAll = id;
+ };
+ CLASS = MMAppController;
+ LANGUAGE = ObjC;
+ SUPERCLASS = NSObject;
+ },
+ {CLASS = NSMenu; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
+ {
+ ACTIONS = {didAdjustSubviews = RBSplitView; willAdjustSubviews = RBSplitView; };
+ CLASS = NSObject;
+ LANGUAGE = ObjC;
+ },
+ {CLASS = RBSplitSubview; LANGUAGE = ObjC; SUPERCLASS = NSView; },
+ {
+ CLASS = RBSplitView;
+ LANGUAGE = ObjC;
+ OUTLETS = {delegate = id; };
+ SUPERCLASS = RBSplitSubview;
+ },
+ {
+ ACTIONS = {checkForUpdates = id; };
+ CLASS = SUUpdater;
+ LANGUAGE = ObjC;
+ SUPERCLASS = NSObject;
+ }
+ );
+ IBVersion = 1;
+}
\ No newline at end of file
diff -r 46ecc5f2a8a4 src/MacVim/English.lproj/MainMenu.nib/info.nib
--- a/src/MacVim/English.lproj/MainMenu.nib/info.nib Mon Oct 13 20:05:02 2008 +1100
+++ b/src/MacVim/English.lproj/MainMenu.nib/info.nib Sat Nov 15 15:18:26 2008 +1100
@@ -1,17 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
+ <key>IBDocumentLocation</key>
+ <string>128 409 356 240 0 0 1152 698 </string>
+ <key>IBEditorPositions</key>
+ <dict>
+ <key>29</key>
+ <string>128 654 281 44 0 0 1152 698 </string>
+ </dict>
<key>IBFramework Version</key>
- <string>629</string>
+ <string>489.0</string>
<key>IBLastKnownRelativeProjectPath</key>
<string>../../MacVim.xcodeproj</string>
<key>IBOldestOS</key>
- <integer>5</integer>
+ <integer>4</integer>
<key>IBOpenObjects</key>
- <array/>
+ <array>
+ <integer>29</integer>
+ </array>
<key>IBSystem Version</key>
- <string>9E17</string>
+ <string>8P2137</string>
<key>targetFramework</key>
<string>IBCocoaFramework</string>
</dict>
diff -r 46ecc5f2a8a4 src/MacVim/English.lproj/MainMenu.nib/keyedobjects.nib
Binary file src/MacVim/English.lproj/MainMenu.nib/keyedobjects.nib has changed
diff -r 46ecc5f2a8a4 src/MacVim/MMAppController.h
--- a/src/MacVim/MMAppController.h Mon Oct 13 20:05:02 2008 +1100
+++ b/src/MacVim/MMAppController.h Sat Nov 15 15:18:26 2008 +1100
@@ -56,7 +56,11 @@
- (IBAction)newWindow:(id)sender;
- (IBAction)newWindowAndActivate:(id)sender;
+- (IBAction)newWindowMacVim:(id)sender;
+- (IBAction)newWindowVim:(id)sender;
+- (IBAction)newWindowVi:(id)sender;
- (IBAction)fileOpen:(id)sender;
+- (IBAction)fileOpenSession:(id)sender;
- (IBAction)selectNextWindow:(id)sender;
- (IBAction)selectPreviousWindow:(id)sender;
- (IBAction)orderFrontPreferencePanel:(id)sender;
diff -r 46ecc5f2a8a4 src/MacVim/MMAppController.m
--- a/src/MacVim/MMAppController.m Mon Oct 13 20:05:02 2008 +1100
+++ b/src/MacVim/MMAppController.m Sat Nov 15 15:18:26 2008 +1100
@@ -928,6 +928,29 @@
}
}
+- (IBAction)newWindowMacVim:(id)sender
+{
+ NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
+ NSString *vimrcPath = [bundlePath
+ stringByAppendingString:@"/Contents/Resources/vim/vimrc"];
+ NSString *gvimrcPath = [bundlePath
+ stringByAppendingString:@"/Contents/Resources/vim/gvimrc"];
+ [self launchVimProcessWithArguments:[NSArray arrayWithObjects:
+ @"-u", vimrcPath, @"-U", gvimrcPath, @"--noplugin", nil]];
+}
+
+- (IBAction)newWindowVim:(id)sender
+{
+ [self launchVimProcessWithArguments:[NSArray arrayWithObjects:
+ @"-N", @"-u", @"NONE", nil]];
+}
+
+- (IBAction)newWindowVi:(id)sender
+{
+ [self launchVimProcessWithArguments:[NSArray arrayWithObjects:
+ @"-u", @"NONE", nil]];
+}
+
- (IBAction)newWindowAndActivate:(id)sender
{
[self activateWhenNextWindowOpens];
@@ -951,6 +974,26 @@
int result = [panel runModalForDirectory:dir file:nil types:nil];
if (NSOKButton == result)
[self application:NSApp openFiles:[panel filenames]];
+}
+
+- (IBAction)fileOpenSession:(id)sender
+{
+ NSString *dir = nil;
+ BOOL trackPwd = [[NSUserDefaults standardUserDefaults]
+ boolForKey:MMDialogsTrackPwdKey];
+ if (trackPwd) {
+ MMVimController *vc = [self keyVimController];
+ if (vc) dir = [[vc vimState] objectForKey:@"pwd"];
+ }
+
+ NSOpenPanel *panel = [NSOpenPanel openPanel];
+ [panel setAllowsMultipleSelection:NO];
+ [panel setAccessoryView:openPanelAccessoryView()];
+
+ int result = [panel runModalForDirectory:dir file:nil types:nil];
+ if (NSOKButton == result)
+ [self launchVimProcessWithArguments:[NSArray arrayWithObjects:
+ @"-S", [[panel filenames] objectAtIndex:0], nil]];
}
- (IBAction)selectNextWindow:(id)sender
diff -r 46ecc5f2a8a4 src/MacVim/gvimrc
--- a/src/MacVim/gvimrc Mon Oct 13 20:05:02 2008 +1100
+++ b/src/MacVim/gvimrc Sat Nov 15 15:18:26 2008 +1100
@@ -18,12 +18,22 @@
"
if !exists("syntax_on")
- syntax on
+ if &loadplugins
+ syntax on
+ else
+ source $VIMRUNTIME/filetype.vim
+ syntax on
+ endif
endif
if !exists("colors_name")
+ if &loadplugins
" Use the macvim color scheme by default
colorscheme macvim
+ else
+ source $VIMRUNTIME/colors/macvim.vim
+ doautocmd ColorScheme macvim
+ endif
endif
@@ -48,14 +58,20 @@
aunmenu File.Save-Exit
an <silent> 10.290 File.New\ Window <Nop>
+an <silent> 10.292 File.New\ Window\ With.MacVim\ Defaults <Nop>
+an <silent> 10.292 File.New\ Window\ With.Vim\ Defaults <Nop>
+an <silent> 10.292 File.New\ Window\ With.Vi\ Defaults <Nop>
+an <silent> 10.292 File.New\ Window\ With.Debug\ Mode <Nop>
an 10.295 File.New\ Tab :tabnew<CR>
an <silent> 10.310 File.Open\.\.\. <Nop>
+an <silent> 10.315 File.Open\ Session\.\.\. <Nop>
an <silent> 10.325 File.Open\ Recent <Nop>
an 10.328 File.-SEP0- <Nop>
an <silent> 10.330 File.Close\ Window<Tab>:qa :conf qa<CR>
an <silent> 10.332 File.Close :conf q<CR>
an <silent> 10.341 File.Save\ All :browse conf wa<CR>
an 10.350 File.Save\ As\.\.\.<Tab>:sav :browse confirm saveas<CR>
+an 10.360 File.Save\ Session\ As\.\.\.<Tab>:mksession :browse confirm mksession<CR>
" Edit menu
@@ -209,8 +225,13 @@
"
macm File.New\ Window key=<D-n> action=newWindow:
+macm File.New\ Window\ With.MacVim\ Defaults action=newWindowMacVim:
+macm File.New\ Window\ With.Vim\ Defaults action=newWindowVim:
+macm File.New\ Window\ With.Vi\ Defaults action=newWindowVi:
+macm File.New\ Window\ With.Debug\ Mode action=newWindowDebug:
macm File.New\ Tab key=<D-t>
macm File.Open\.\.\. key=<D-o> action=fileOpen:
+macm File.Open\ Session\.\.\. key=<D-o> action=fileOpenSession:
macm File.Open\ Tab\.\.\. key=<D-T>
macm File.Open\ Recent action=recentFilesDummy:
macm File.Close\ Window key=<D-W>