cosmopolitan icon indicating copy to clipboard operation
cosmopolitan copied to clipboard

Redbean: edit zip file on emacs

Open renatoathaydes opened this issue 1 year ago • 4 comments

Hi @jart ! I really love Redbean, thanks for creating it! I've used something similar (though definitely not actually portable) to create my smart home system!

Anyway, I wanted to be able to edit the redbean zip in emacs, but for some reason emacs is not recognizing it as a zip file. Normally, emacs will open a buffer for zip files in "archive mode" which means it lets you see the contents of the zip and edit files in it as if it were normal files... but this is not possible with redbean.

I realize this is probably a problem with emacs, not Redbean! But I thought that it would be appropriate to ask you if you know what may be the issue given your extensive knowledge. If I knew the root cause of the problem, I could try to provide a patch to the emacs project myself, but unfortunately I just don't have any idea how to get started on this.

Thanks for any assistance you may provide.

renatoathaydes avatar Nov 05 '23 17:11 renatoathaydes

Judging by the code in arc-mode.el, it searches for a ZIP signature from the beginning, but it should be done from the end of the file, so it finds something that looks like a signature (but is not) and likely bails out too soon. I don't think anything can be done here short of fixing it in emacs code. At least the updates themselves are done by external programs, so if the location of the zip is fixed, then modifications may work.

pkulchenko avatar Nov 05 '23 17:11 pkulchenko

Well, just telling me where the function is that determines this already helps :) I will see if I can patch this to look at the end of the file as well.

renatoathaydes avatar Nov 05 '23 19:11 renatoathaydes

I did some research... the zip file format is just problematic... I don't blame emacs for doing the "simple" thing. See https://stackoverflow.com/questions/8593904/how-to-find-the-position-of-central-directory-in-a-zip-file

renatoathaydes avatar Nov 05 '23 21:11 renatoathaydes

I agree that it's not ideal, but there are some methods (search-backward and search-backward-regexp) that you can probably use to cobble something together similar to what's done in archive-zip-summarize to find the start of the actual zip.

pkulchenko avatar Nov 05 '23 21:11 pkulchenko