Re: [Conkeror] editing Gmail rich formatting message in external editor (text field error)
About a year ago, > Give this a whirl.. Also, to anybody else reading this mailing list, help > in testing would be much appreciated. If I succeeded in not breaking > anything, then I'll patch the program with this change after a short > period of testing. it was reported as working then, but recently I've been getting the same "Element is not a text field." error. In fact, I can't seem to get it working with any text field. -- Nicholas Ochiel t: @nochiel ___ Conkeror mailing list [email protected] https://www.mozdev.org/mailman/listinfo/conkeror
Re: [Conkeror] editing Gmail rich formatting message in external editor (text field error)
On Thu, Dec 30, 2010 at 02:09:11PM -0500, John J. Foerch wrote: > > ... snip ... > > The way that we choose also needs to be configurable, and (I predict) > extensible for the future. I will think on this problem. It will > probably involve replacing edit_field_in_external_editor_extension with > something that can be set to a function, instead of just a single string. > I think I have a workable patch for this. By default, the file extension for the temporary file is gotten from mozilla's mime-service for the mime type of the thing being edited (text/plain for normal input boxes). To preserve users' ability to customize, a user variable is introduced containing a mime-type table (of the sort defined in mime.js) that maps mime type patterns to extensions. Will upload soon. -- John Foerch ___ Conkeror mailing list [email protected] https://www.mozdev.org/mailman/listinfo/conkeror
Re: [Conkeror] editing Gmail rich formatting message in external editor (text field error)
On Thu, Dec 30, 2010 at 11:00:21AM -0600, Benjamin Slade wrote:
> On 30 December 2010 10:47, John J. Foerch wrote:
>
> On Tue, Dec 28, 2010 at 01:38:42PM -0600, Benjamin Slade wrote:
> > Emacs html-helper-mode is nice for editing rich formatted messages.
> However, I
> > don't seem to be summon the external editor in my Gmail messages: I get
> the
> > message "Element is not a text field". Is there a way to add an
> exception for
> > Gmail so that that rich formatted messages can be edited in the external
> > editor? (I was used to be able to do this with Pentadactyl/Vimperator).
>
>
> Give this a whirl.. Also, to anybody else reading this mailing list, help
> in testing would be much appreciated. If I succeeded in not breaking
> anything, then I'll patch the program with this change after a short
> period of testing.
>
>
>
>
> Thanks, John. It seems to work: I'm writing this message via Gmail in my
> external editor.
> I'll keep an eye out to see if it breaks anything.
>
> [off-topic question: does anyone know if there's a way to set up the external
> editor call assignment in such a way that it makes Emacs start in
> html-helper-mode?]
>
> --B.
The direct answer to your question might look something like this:
///in conkeror
edit_field_in_external_editor_extension = "xxx";
;;;in emacs
(defun choose-mode-for-conkeror-external-editing-file (&rest args)
(save-excursion
(goto-char (point-min))
(apply
(cond
((looking-at "\\s-*<") 'html-helper-mode)
(t 'text-mode))
args)))
(add-to-list 'auto-mode-alist '("\\.xxx\\'" .
choose-mode-for-conkeror-external-editing-file))
But I don't think that's the best way to approach this problem. It really
_is_ an on-topic question, because, since we are adding the ability to
externally edit html content to Conkeror, it makes sense that Conkeror
should be smarter about choosing file extensions for external-editor temp
files. We need a way to have Conkeror continue to use "txt" for input
boxes and textareas, but "html" for richedit fields. If Conkeror could do
that, then Emacs is already equipt to do the rest with a much simpler
auto-mode-alist config than I gave above.
The way that we choose also needs to be configurable, and (I predict)
extensible for the future. I will think on this problem. It will
probably involve replacing edit_field_in_external_editor_extension with
something that can be set to a function, instead of just a single string.
--
John Foerch
___
Conkeror mailing list
[email protected]
https://www.mozdev.org/mailman/listinfo/conkeror
Re: [Conkeror] editing Gmail rich formatting message in external editor (text field error)
On 30 December 2010 10:47, John J. Foerch wrote: > On Tue, Dec 28, 2010 at 01:38:42PM -0600, Benjamin Slade wrote: > > Emacs html-helper-mode is nice for editing rich formatted messages. > However, I > > don't seem to be summon the external editor in my Gmail messages: I get > the > > message "Element is not a text field". Is there a way to add an > exception for > > Gmail so that that rich formatted messages can be edited in the external > > editor? (I was used to be able to do this with Pentadactyl/Vimperator). > > > Give this a whirl.. Also, to anybody else reading this mailing list, help > in testing would be much appreciated. If I succeeded in not breaking > anything, then I'll patch the program with this change after a short > period of testing. > > > Thanks, John. It seems to work: I'm writing this message via Gmail in my external editor. I'll keep an eye out to see if it breaks anything. [off-topic question: does anyone know if there's a way to set up the external editor call assignment in such a way that it makes Emacs start in html-helper-mode?] --B. ___ Conkeror mailing list [email protected] https://www.mozdev.org/mailman/listinfo/conkeror
Re: [Conkeror] editing Gmail rich formatting message in external editor (text field error)
On Tue, Dec 28, 2010 at 01:38:42PM -0600, Benjamin Slade wrote:
> Emacs html-helper-mode is nice for editing rich formatted messages. However, I
> don't seem to be summon the external editor in my Gmail messages: I get the
> message "Element is not a text field". Is there a way to add an exception for
> Gmail so that that rich formatted messages can be edited in the external
> editor? (I was used to be able to do this with Pentadactyl/Vimperator).
Give this a whirl.. Also, to anybody else reading this mailing list, help
in testing would be much appreciated. If I succeeded in not breaking
anything, then I'll patch the program with this change after a short
period of testing.
///begin code
function edit_field_in_external_editor (buffer, elem, doc) {
if (! doc) {
if (elem instanceof Ci.nsIDOMHTMLInputElement) {
var type = (elem.getAttribute("type") || "").toLowerCase();
if (type == "hidden" || type == "checkbox" || type == "radio")
throw interactive_error("Element is not a text field.");
} else if (!(elem instanceof Ci.nsIDOMHTMLTextAreaElement))
throw interactive_error("Element is not a text field.");
}
var name = get_filename_for_current_textfield(buffer.document, elem);
var file = get_temporary_file(name);
if (elem instanceof Ci.nsIDOMHTMLInputElement ||
elem instanceof Ci.nsIDOMHTMLTextAreaElement)
{
var content = elem.value;
} else {
content = elem.innerHTML;
}
// Write to file
try {
write_text_file(file, content);
} catch (e) {
file.remove(false);
throw e;
}
// FIXME: decide if we should do this
var old_class = elem.className;
elem.className = "__conkeror_textbox_edited_externally " + old_class;
try {
yield open_file_with_external_editor(file);
content = read_text_file(file);
if (elem instanceof Ci.nsIDOMHTMLInputElement ||
elem instanceof Ci.nsIDOMHTMLTextAreaElement)
{
elem.value = content;
} else {
elem.innerHTML = content;
}
} finally {
elem.className = old_class;
file.remove(false);
}
}
interactive("edit-current-field-in-external-editor",
"Edit the contents of the currently-focused text field in an external
editor.",
function (I) {
var b = I.buffer;
var e = b.focused_element;
var frame = b.focused_frame;
var doc = null;
if (e) {
if (e.getAttribute("contenteditable") == 'true')
doc = e.ownerDocument;
} else if (frame && frame.document.designMode &&
frame.document.designMode == "on") {
doc = frame.document;
e = frame.document.body;
}
yield edit_field_in_external_editor(b, e, doc);
e.blur();
});
///end code
--
John Foerch
___
Conkeror mailing list
[email protected]
https://www.mozdev.org/mailman/listinfo/conkeror
