[TxMt] feature request: autosave
Mats Persson
mats at imediatec.co.uk
Fri Jan 14 15:35:00 UTC 2005
On 14 Jan 2005, at 08:59, Paul Nordstrom August wrote:
> somehow one of my old .php files was encoded as a BBEdit document so
> when I double-clicked BB opened up... what a shock! Like travelling
> back in time. Honestly I wondered if it had booted Classic up, the
> menu looked so old :)
Yes, Paul, I too just worked in BBEdit and hated it. v8.0.3 (looks as
bad as 7 really) and it was SLOW when I was typing text into the
document, and that's on an iMac G5 so it wasn't on some slow old banger
either. TM ROCKS !!
> Just about the only thing I miss (because I screwed up a bunch o' code
> today ;) is the autosave feature where each file is backed up before
> each change. Can we please have that in TM for us klutzes?
I tried that feature in BB a long time ago and found it very badly
executed to be honest, so I wouldn't really advocate for something like
that in TM. In my mind it's sort of putting a 32bhp diesel engine in a
Ferrari.
I'm a bit uncertain about what it is you really would like. Either you
want a straight copy of BBEdit's implementation where you can choose to
have a backup file in the same directory or else a copy of your file in
another directory.
Either way, I think I know a better alternative solution to the whole
request that we can 'easily' implement quickly; only needs a little bit
of learning from you; and a bit of assistance from the more clever guys
on the ML. Yes, Allan et al, that's you guys. (I've been thinking about
it for a while and been planning to do something like it myself, just
haven't got around to it yet due to a TM bug that Allan seems to have
sorted out today)
Before I go on, let me make it clear that I hate having extra files in
the working copy such as .bak files etc, so my solution below only
addresses a secondary repository, but you can make it work with a new
file in same dir as your TM_FILE if you want.
I just did a test where pressing Cmd+S also triggers a Command with the
same trigger, so if you create a command that does what you want to do
with each save, then that command will also be executed at the same
time.
On to The concept:
Create a new command that saves the file on execution, with Cmd+S as
the trigger, and then in the command do something like this: (NEEDS
WORK)
1. Set path to where your file repos is: /Users/<name>/TMBackups/ and
set the name of the current project if you are working on several.
2. Get hold of the short TM_FILE_PATH. (remove /Volumes/... from it)
3. Create a LogEntry variable that holds the divider text and file
content: (something like this)
LogEntry="
===== version saved: <datetime> by <UserName> =========
<file content>
==================================================
"
3b. Allan, what's the TM_VAR for the whole document content? or can I
get to it other than [ echo `cat $TM_FILE_NAME > $TM_BACKUP_FILE `] ??
3c. How do you retain the Newline/ CR in this when you redirect it
into a new file ?? Losing them in my test command.
4. Then use a simple Unix redirect command that appends the entry to
the logfile: echo "$LogEntry" >> $BackUpLogFile
OK, so what do you get out of this in the end. Well, you get sort of a
log of all changes in an individual file in a single backup file for
that file with dividers that sets the date etc info as you wish to have
it and the code as it was at that time. Each file in your project would
have it's own backup log file in the BackUp repos.
If you don't want a single log file but multiple files, well then that
can be done just as easy, although I think it's pointless to be honest,
because you will have to open loads of files to see what changes you
have made. In my version your last saved version is always at the
bottom of the backup file. Now this is NOT as good as you using CVS or
SVN, but I'm working on solving that problem as well on each save.
Give us (me) your spec's and I'll see what we can do about it.
This command based workaround would only require Allan's mind for only
a few minutes to implement (I'm sure) versus something that will take
longer time to implement, and would not have a much better result. (at
least in my mind)
I hope the above is ample illustration of how BBEdit can't compare to
TM, and how we all need to "Think Different(ly)" about TM, since many
things can be achieved with Commands and a bit of Unix knowledge.
On 14 Jan 2005, at 10:36, Allan Odgaard wrote:
> With a flattering introduction like yours, I can't possibly turn that
> request down ;)
Please note my flattery and requests above and below ;-)
> So should I do it *nix style and append ~ to the backup-files, or a
> prefix like .backup?
> When saving the new file there are two options, rename the old and
> write the new, or copy the old (into the backup) and overwrite the
> new. While the first seems to be the obvious solution, it will give
> the “new” file a new inode, which will break hardlinks. Aliases should
> still work because they use the path before the inode, so maybe it's
> okay (just thinking out load here)...
Allan, Although I may have misunderstood some parts of your thinking
there, it seems to me that you are complicating the whole thing. A
couple of 'simple' commands that uses TM & Unix power will do that job
well.
Allan, IF you'd like a challenge, then please consider binding Commands
with Menu choices as well. So that using either the menu or the
keyboard shortcut executes the Command. Also, could you please make it
so that we can remove a trigger from a command and leave it empty. Now
it captures any key stroke you do, and the (x) button don't work.
Kind regards,
Mats
----
"TextMate, coding with an incredible sense of joy and ease"
- www.macromates.com -
More information about the textmate
mailing list