Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to set master document persistant #27

Closed
sebastiaanfranken opened this issue Dec 25, 2019 · 4 comments
Closed

Add ability to set master document persistant #27

sebastiaanfranken opened this issue Dec 25, 2019 · 4 comments

Comments

@sebastiaanfranken
Copy link

I use multi-document setups on a daily basis, and thus every project I work on has a master document (with the use of '\input'). For every folder/project I open I have to redo this step each and every time.

Can this be set persistant somehow? My Python isn't super, but I'll check if I can do anything to help

@sebastiaanfranken
Copy link
Author

sebastiaanfranken commented Dec 25, 2019

I've gotten it to save my master document, very very crudely. Here's how I've done it, apologies for the inline code and no pull request, I'm not at my main machine so no SSH keys here

def populate_from_disk(self):
    try: filehandle = open(self.pathname + '/workspace.pickle', 'rb')
    except IOError: pass
    else:
        try: data = pickle.load(filehandle)
        except EOFError:
            return
        else:
            for item in sorted(data['open_documents'].values(), key=lambda val: val['last_activated']):
                self.create_document_from_filename(item['filename'])
            for item in data['recently_opened_documents'].values():
                self.update_recently_opened_document(item['filename'], item['date'], notify=False)
    self.add_change_code('update_recently_opened_documents', self.recently_opened_documents)

    if data['master_document'] is not None:
        document = LaTeXDocument(self.pathname)
        document.set_filename(data['master_document'])
        self.set_one_document_master(document)

def save_to_disk(self):
    try: filehandle = open(self.pathname + '/workspace.pickle', 'wb')
    except IOError: pass
    else:
        open_documents = dict()
        for document in self.open_documents:
            filename = document.get_filename()
            if filename != None:
                open_documents[filename] = {
                    'filename': filename,
                    'last_activated': document.get_last_activated()
                }
        data = {
            'open_documents': open_documents,
            'recently_opened_documents': self.recently_opened_documents
        }

        if self.master_document is not None:
            data['master_document'] = self.master_document.filename

        pickle.dump(data, filehandle)

In workspace/workspace.py. The only thing it doesn't do is apply the state when you open Seltzer again, which is... annoying

@cvfosammmm
Copy link
Owner

cvfosammmm commented Dec 25, 2019

Thanks for the request. I can implement it myself, no problem.

I think just making the master document persistent has a downside: one can forget that they set it and Setzer will behave seemingly weirdly. But that might be worth it.

Also I think this calls for a more general solution: naming lists of files as "projects" and loading them all at once (including master state).

@sebastiaanfranken
Copy link
Author

I was thinking the same thing. Being able to define a "project" would be the best solution I think. Sadly the Python code is beyond my knowledge (but it's very nice, and I can learn a lot from it so thanks!) so I doubt I'll be able to do much.

@cvfosammmm
Copy link
Owner

This is now fixed in the latest flathub update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants