Thank you very much! This will save me a lot of time recovering.
I have only made two modifications to your script to make it operate
as intended: keys in the second row appear to be bound for rotation
functions, but Key 83 (uppercase S) is free, also there was a missing
'molecule number' argument (imol) in the write-pdb-file function.
Here is the modified version of your script:
---
(define (quick-save)
(map (lambda (imol)
(write-pdb-file imol (string-append (strip-extension (strip-
path(molecule-name imol))) "-temporary.pdb")))
(model-molecule-list))
(save-state))
;; now map quick-save on to the S key:
(define graphics-general-key-press-hook
(lambda (key)
(cond
((= key 83) ; S
(quick-save)))))
---
I agree with the concern with frivolous overwriting of input files.
One way to avoid this would be to save to a temporary file by
modifying write-pdb-file like this:
(write-pdb-file imol (string-append (strip-extension (strip-
path(molecule-name imol))) "-temp.pdb")
However, this new filename does not get reflected in the open molecule
list, therefore, and does not get saved in the state file. Would it
be possible to have the new filename be updated in the open molecule
list before (save-state)? Just as when one saves coordinates through
the proper File->menu item.
Thanks again,
Vladimir
P.S. as far as a crash recipe, I'll try to come up with one. I am
running Coot on OS X Leopard, and the current X11 version occasionally
freezes Coot (I haven't yet figured out how to recover from the
freeze). Btw, much of the time Coot works well in Leopard!
On Feb 28, 2008, at 3:26 AM, Paul Emsley wrote:
> Vladimir Vigdorovich wrote:
>> Hello all,
>> I am trying to add a menu item to allow me to save current state and
>> coordinates in one step. The purpose is to prevent the user (me)
>> from
>> losing his/her place in the pdb/mtz files and quickly (without
>> dialogs)
>> saving current changes in case of a crash. Anyone with scheme
>> experience:
>> please help (for I have no scheme experience)!
>> Below is what I have so far. What I would like to change is to
>> have the
>> script apply this to all loaded molecules (not just molecule 0).
>> Also, the
>> filenames would have to be the same as filenames of the original
>> files.
>
> As Jürgen says, Coot will back up your modifications for you (into
> coot-backup). As it stands, Coot doesn't backup the very last
> change. It also will not save the state file.
>
> I disapprove of overwriting the input files, but here is what you
> asked for (I bind it to the Q key, which is quicker than using a
> menu item).
>
> Paul.
>
> And p.s. if you have a recipe to crash Coot, I'd be very interested
> to know how you do it!
>
>
> ---
>
> (define (quick-save)
> (save-state)
> (map (lambda (imol) (write-pdb-file (molecule-name imol)))
> (model-molecule-list)))
>
>
> ;; now map quick-save on to the Q key:
> (define graphics-general-key-press-hook
> (lambda (key)
> (cond
> ((= key 113) ; Q
> (quick-save)))))
>
>
>
|