Hello,

On Sun, Sep 4, 2011 at 17:41, John J. Foerch <[email protected]> wrote:
> On Sun, Sep 04, 2011 at 04:28:15PM +0200, Riccardo Murri wrote:
>> On Sun, Sep 4, 2011 at 4:19 PM, John J. Foerch <[email protected]> 
>> wrote:
>> > On Sun, Sep 04, 2011 at 11:58:33AM +0200, Riccardo Murri wrote:
>> >> Is there any way of making the conkeror/editor connection more robust?
>> >>
>> > There is a danger of memory leaks in keeping the necessary DOM references
>> > in memory during external editing.  That's why in the initial version of
>> > this feature, we keep it simple and do the entire operation in the input
>> > sequence cycle, so we have a guarantee of proper cleanup if something goes
>> > wrong.  I'm redesigning this in a branch I'm working on though, and the
>> > redesign will address the memory leak problem.
>>
>> Thanks for addressing this already!  (And for all your work on
>> Conkeror, that goes without saying.)
>>
>> In the meanwhile, is there a way to make the editor filenames
>> generated from Conkeror follow a recognizable pattern?  (e.g.,
>> prefix them with "conkeror-edit-")  That way, I could hook Emacs into
>> taking appropriate action, for instance pushing the whole buffer into the
>> kill-ring on a "C-x #" keypress.
>
> Yes.  You can control the extension via the mime-type table,
> external_editor_extension_overrides, and the base name by overriding the
> function external_editor_make_base_filename.
>
> For example:
>
> external_editor_extension_overrides.set("text/plain", "foo");
>
> var old_external_editor_make_base_filename =
>    (old_external_editor_make_base_filename ||
>     external_editor_make_base_filename)
> function external_editor_make_base_filename (elem, top_doc) {
>    return "conkeror-edit-"+old_external_editor_make_base_filename(elem, 
> top_doc);
> }
>

sorry for resurrecting an old post, but I thought I'd share the little
Emacs code
that I use as companion of the above, in case it might be useful to others:

    ;; save buffer contents to register `o` before closing it, so we can
    ;; still recover the text if something goes wrong in the communication
    ;; with Conkeror
    (defadvice server-edit (before conkeror-edit-save-to-register)
      "Save buffer contents to register `o' before running normal
`server-edit' action."
      (if (string-match "^conkeror-edit-"
                        (file-name-nondirectory buffer-file-name))
        (copy-to-register ?o (point-min) (point-max))))
    (ad-activate 'server-edit)

Actually, I've found out that it's more convenient to just save the
buffer contents unconditionally, so it also works for other programs,
not just Conkeror:

    (defadvice server-edit (before server-edit-save-to-register)
      "Save buffer contents to register `o' before running normal
`server-edit' action."
      (copy-to-register ?o (point-min) (point-max)))
    (ad-activate 'server-edit)

Cheers,
Riccardo
_______________________________________________
Conkeror mailing list
[email protected]
https://www.mozdev.org/mailman/listinfo/conkeror

Reply via email to