Git Product home page Git Product logo

Comments (43)

pipehat avatar pipehat commented on August 19, 2024

Played a bit with this. The gmail text entry is a body element in an iframe that is editable.

Code like this in textareas.js : findTextAreasIn(thing) picks it up and even basic tagging seems to work and produces an edit button which launches emacs happily. However the text isn't transferred successfully in either direction. Inevitably due to the fact that the existing code is aimed at text areas.

var bodys = thing.getElementsByTagName('body');
for (var i=0; i<bodys.length; i++) {
if (bodys[i].getAttribute("g_editable")) {
    console.log("Found g_editable body element. Tagging...");
    tagTextArea(bodys[i]);
}
else {
    console.log("Ignoring non-g_editable body element");
}
}

from emacs_chrome.

stsquad avatar stsquad commented on August 19, 2024

There is no reason why this couldn't be made more generic. From the edit-server/xmlcomms point of view it cares not, it just needs a unique ID associated with the element in question.

This should be all solvable in textareas.js

BTW you do know Gmail works fine with Edit with Emacs if you turn off the rich text editing. The element in question is then a normal <textarea>.

from emacs_chrome.

pipehat avatar pipehat commented on August 19, 2024

Oh! I didn't know that. That's good enough for me. Thanks!

from emacs_chrome.

rpgoldman avatar rpgoldman commented on August 19, 2024

I'm having an issue here with gmail where I accumulate literally dozens of little "edit" buttons at the bottom of the gmail pane. Is this related to the problem discussed above? Am I perhaps getting an accumulation of old text areas spawning edit buttons, even though they are not visible? Or is it possible that this comes from the "stack of cards" display of a conversation in gmail? Are there text areas which aren't visible, but that still spawn edit buttons?

from emacs_chrome.

stsquad avatar stsquad commented on August 19, 2024

I think it's a different problem to what the previous user was mentioning. However if you can right-click on the element and select inspect element and then see if you can find the textarea it's associated with.

tagTextArea(text) in textareas.js is the function that decides what to tag. It has a few exception for things like textareas that are spellcheck disabled but I'm sure it could be smarter.

There is also a bit of code that attempts to handle "duplicate ids" that it may see. I suppose it could do a better job of cleaning up if there are old textareas that GMail has been adding and removing textareas at will.

from emacs_chrome.

rpgoldman avatar rpgoldman commented on August 19, 2024

When I inspect, I see a large number of entries like this:

Presumably there should be an eta_26 somewhere in the DOM that this refers to, but I can't see it.

from emacs_chrome.

rpgoldman avatar rpgoldman commented on August 19, 2024

Sorry. Should have previewed --- of course the snippet of HTML I pasted in just vanished. D'oh!

from emacs_chrome.

stsquad avatar stsquad commented on August 19, 2024

It's OK I saw the HTML in the email :-)

It very much looks like those are tags left over from text areas that have been removed from the DOM in the course of Gmail updating the page. I guess we can re-scan the whole list of text areas each time a DOM area is changed and see if the text area still exists. It would be nicer if there was some sort of event that fired specifically if the text area is removed from the DOM.

What's your use case to replicate? Do you just send multiple emails i one session?

from emacs_chrome.

rpgoldman avatar rpgoldman commented on August 19, 2024

I will have to get back to you about this. I'm not normally a big gmail user. Just the other day I had to coordinate a very large group, and so was actively using the gmail GUI for a much longer than usual session.

Note that I typically leave Chrome up for days, if not weeks, and leave my google services tabs open that whole time. I did close the Gmail window and reopen it, and the problem went away. I'll see if I can replicate.

from emacs_chrome.

stsquad avatar stsquad commented on August 19, 2024

I've made some clean-ups to what textareas get tagged (to avoid "hidden" textareas getting buttons). I think gmail is still leaving droppings though as the "Reply" box gets replaced when you focus it. It's tricky to see in the inspector as you can't right click the element!

from emacs_chrome.

rosmo avatar rosmo commented on August 19, 2024

Any possibility of support for CodeMirror text editors?

from emacs_chrome.

stsquad avatar stsquad commented on August 19, 2024

@rosmo: the CodeMirror stuff is not a textarea or a simple DIV. The javascript manipulates a fairly complex set of DOM elements to do the highlighting. For Edit with Emacs to support it we'd a more general plugin system (as mentioned elsewhere in the issues) to un-munge and re-munge the text.

from emacs_chrome.

stsquad avatar stsquad commented on August 19, 2024

@rpgoldman: could you let me know if I can close the "multiple edit icons" issue here? I've pushed some new mutator code to them main branch recently which should make tracking Gmail's changes a lot easier.

from emacs_chrome.

rpgoldman avatar rpgoldman commented on August 19, 2024

I haven't been seeing these icons, but I'm afraid I haven't been using emacs_chrome with the gmail page much, either.

I started reading gmail through Thunderbird (also using emacs as email editor!), so I haven't looked at the page lately.

I just opened up a gmail reply window and now I see no edit buttons at all! So not many, but not working as desired, either! This is with 1.11, not from github.

You needn't keep this open on my account.

from emacs_chrome.

ottopichlhoefer avatar ottopichlhoefer commented on August 19, 2024

By turning off 'Rich formatting' in Gmail I have been happy writing my
Emails in Emacs. The new compose mode in Gmail however causes problems.

While it is possible to turn on 'text only' in the new compose window,
formatting like newline appear as html code when sent to emacs.

Since I am not a programmer I cannot look in to this myself. Maybe there
is no easy solution but I am afraid that once the new feature in Gmail
becomes permanent I will be unable to write my emails in emacs.

from emacs_chrome.

stsquad avatar stsquad commented on August 19, 2024

I can certainly see HTML code around my signature when the edit session starts. However if I leave it alone and just enter text everything seems to be fine. The final email is certainly devoid of HTML when it gets to my mutt session.

I suspect the HTML is there for formatting reasons and stripped by gmail before sending.

What stops you editing the file like that?

from emacs_chrome.

ottopichlhoefer avatar ottopichlhoefer commented on August 19, 2024

Well, if I insert my signature or if I insert a list with orgstruct,
newlines are lost when the text is transferred to Gmail. This looks
rather messy.

from emacs_chrome.

stsquad avatar stsquad commented on August 19, 2024

Do you have longlines enabled or any other special encodings on your edit buffer?

from emacs_chrome.

ottopichlhoefer avatar ottopichlhoefer commented on August 19, 2024

No, the major mode is message-mode and I have also Auto-Fill-mode
Global-Font-Lock-mode and Transient-Mark-mode enabled (among others).

from emacs_chrome.

jaydixit avatar jaydixit commented on August 19, 2024

This extension rocks my world. I also would love it if there were a way to get it to work with Gmail in a Rich Formatting window?

(I use Markdown Here to apply rich formatting after I've entered text, and such a feature would prevent me from having to switch back and forth between Plain Text and Rich Formatting.)

Is this possible? Is anyone working on this? Thanks!

from emacs_chrome.

stsquad avatar stsquad commented on August 19, 2024

I was looking for the Rich Formatting option to check your request and I couldn't find it. I think as long as the div has the editable field set it should Just Work (tm). The new gmail composer just seems to have a tick box for plain text and I can certainly edit the text fine with EwE.

from emacs_chrome.

jaydixit avatar jaydixit commented on August 19, 2024

Thanks for the quick response! I really appc that. Switching to the new
compose on gmail did the trick, it's working now. Except for one thing:
When I C-C C-C to send the text buffer back to Gmail, all my line breaks
are missing. Do you know a solution to this?

Thanks again!

jaydixit.com
fol­low @jaydixit https://twitter.com/jaydixit/
Jay Dixit

On Mon, Mar 11, 2013 at 10:48 AM, Alex Bennée [email protected]:

I was looking for the Rich Formatting option to check your request and I
couldn't find it. I think as long as the div has the editable field set it
should Just Work (tm). The new gmail composer just seems to have a tick box
for plain text and I can certainly edit the text fine with EwE.


Reply to this email directly or view it on GitHubhttps://github.com//issues/20#issuecomment-14717073
.

from emacs_chrome.

stsquad avatar stsquad commented on August 19, 2024

I'm not sure if it's a problem at our end (edit-server.el) and when it applies/clears buffer encoding before sending it back or the fact the HTML widget eats up white-space and uses
's instead.

from emacs_chrome.

stsquad avatar stsquad commented on August 19, 2024

OK it looks like Gmail is swallowing stuff up. You can try something like this:

(defun ajb-encode-newlines-for-gmail ()
  "Replace all occurrences of newlines with <br> in current buffer"
  (goto-char (point-min))
  (while (search-forward "\^J" nil t)
    (replace-match "<br>" nil t)))

(add-hook 'edit-server-done-hook 'ajb-encode-newlines-for-gmail)

Obviously this is a work around for gmail so you may only want to fire this hook on gmail messages.

from emacs_chrome.

jaydixit avatar jaydixit commented on August 19, 2024

Wow, thank you so much.

I added those lines to my .emacs, restarted Emacs and everything... but no
difference. Is there something else I have to do? I'm typing paragraphs,
then when I'm done I'm invoking C-c C-c.

Thanks again.

Best,
Jay

jaydixit.com
fol­low @jaydixit https://twitter.com/jaydixit/
Jay Dixit

On Wed, Mar 13, 2013 at 8:28 AM, Alex Bennée [email protected]:

OK it looks like Gmail is swallowing stuff up. You can try something like
this:

(defun ajb-encode-newlines-for-gmail ()
"Replace all occurrences of newlines with
in current buffer"
(goto-char (point-min))
(while (search-forward "^J" nil t)
(replace-match "
" nil t)))

(add-hook 'edit-server-done-hook 'ajb-encode-newlines-for-gmail)

Obviously this is a work around for gmail so you may only want to fire
this hook on gmail messages.


Reply to this email directly or view it on GitHubhttps://github.com//issues/20#issuecomment-14838315
.

from emacs_chrome.

stsquad avatar stsquad commented on August 19, 2024

Can you check the hook is properly installed? C-h v edit-server-done-hook

from emacs_chrome.

jaydixit avatar jaydixit commented on August 19, 2024

Sure! Here you go. Here's what I get.

C-h v edit-server-done-hook

edit-server-done-hook is a variable defined in `edit-server.el'.
Its value is (ajb-encode-newlines-for-gmail)

...

However, when I do this:

M-x ajb-encode-newlines-for-gmail [no match]

I get this:

wrong type argument, command-p, ajb-encode-newlines-for-gmail

...

my .emacs file does contain these lines:

(defun ajb-encode-newlines-for-gmail ()
"Replace all occurrences of newlines with
in current buffer"
(goto-char (point-min))
(while (search-forward "^J" nil t)
(replace-match "
" nil t)))

(add-hook 'edit-server-done-hook 'ajb-encode-newlines-for-gmail)

Thanks again!

jaydixit.com
fol­low @jaydixit https://twitter.com/jaydixit/
Jay Dixit

On Thu, Mar 14, 2013 at 8:26 AM, Alex Bennée [email protected]:

Can you check the hook is properly installed? C-h v edit-server-done-hook


Reply to this email directly or view it on GitHubhttps://github.com//issues/20#issuecomment-14899275
.

from emacs_chrome.

stsquad avatar stsquad commented on August 19, 2024

You seem to be missing the leading escape \ in the regex.

from emacs_chrome.

jaydixit avatar jaydixit commented on August 19, 2024

Ah, thank you! But now I get the following error:

Debugger entered--Lisp error: (args-out-of-range 32)
replace-match("
" nil t)
(while (search-forward "\n" nil t) (replace-match "
" nil t))
ajb-encode-newlines-for-gmail()
run-hooks(edit-server-done-hook)
(save-restriction (widen) (buffer-disable-undo) (dolist (format
buffer-file-format) (format-encode-region ... ... format)) (run-hooks
(quote edit-server-done-hook)) (edit-server-send-response proc t nokill)
(edit-server-log proc "sent response to browser"))
(if abort (with-current-buffer procbuf (run-hooks ...)
(edit-server-send-response proc t)) (save-restriction (widen)
(buffer-disable-undo) (dolist ... ...) (run-hooks ...)
(edit-server-send-response proc t nokill) (edit-server-log proc "sent
response to browser")))
(let ((buffer ...) (proc edit-server-proc) (procbuf ...)) (if abort
(with-current-buffer procbuf ... ...) (save-restriction ... ... ... ... ...
...)) (when edit-server-frame (delete-frame edit-server-frame)) (unless
nokill (kill-buffer buffer)) (edit-server-kill-client proc))
(if (eq (process-status edit-server-proc) (quote closed)) nil (let (...
... ...) (if abort ... ...) (when edit-server-frame ...) (unless nokill
...) (edit-server-kill-client proc)))
(unless (eq (process-status edit-server-proc) (quote closed)) (let (...
... ...) (if abort ... ...) (when edit-server-frame ...) (unless nokill
...) (edit-server-kill-client proc)))
edit-server-done(nil)
call-interactively(edit-server-done nil nil)

jaydixit.com
fol­low @jaydixit https://twitter.com/jaydixit/
Jay Dixit

On Fri, Mar 15, 2013 at 9:12 AM, Alex Bennée [email protected]:

You seem to be missing the leading escape \ in the regex.


Reply to this email directly or view it on GitHubhttps://github.com//issues/20#issuecomment-14959587
.

from emacs_chrome.

stsquad avatar stsquad commented on August 19, 2024

Hmm something is not right because it's working fine here. scratches head

from emacs_chrome.

jaydixit avatar jaydixit commented on August 19, 2024

Hmm, too bad. I'm not a coder so I have no idea. Let me know if anything
occurs to you.

Anyway, thanks again, and thanks for an amazing extension!

jaydixit.com
fol­low @jaydixit https://twitter.com/jaydixit/
Jay Dixit

On Fri, Mar 15, 2013 at 12:34 PM, Alex Bennée [email protected]:

Hmm something is not right because it's working fine here. *scratches head
*


Reply to this email directly or view it on GitHubhttps://github.com//issues/20#issuecomment-14971002
.

from emacs_chrome.

stsquad avatar stsquad commented on August 19, 2024

I'm a little stuck. Maybe you can get some help from #emacs on IRC to help you debug what's going on?

from emacs_chrome.

jaydixit avatar jaydixit commented on August 19, 2024

Thanks, I will do that. Meanwhile, I was searching around trying to find a
solution and I found this:
http://stackoverflow.com/questions/5889041/sendmail-with-text-formatting-for-email-gmail?rq=1

Does that shed any light?

jaydixit.com
fol­low @jaydixit https://twitter.com/jaydixit/
Jay Dixit

On Mon, Mar 18, 2013 at 4:32 AM, Alex Bennée [email protected]:

I'm a little stuck. Maybe you can get some help from #emacs on IRC to help
you debug what's going on?


Reply to this email directly or view it on GitHubhttps://github.com//issues/20#issuecomment-15043630
.

from emacs_chrome.

frobtech avatar frobtech commented on August 19, 2024

I only care about plain-text mode, but that got harder with a recent GMail
change. I wrote some elisp that works pretty well. I'm pasting the file
in here since I can't find a way to do an attachment, or any plain old
mailing list where I should post this.

;;; edit-server-htmlize.el --- (de)HTMLization hooks for edit-server.el

;;; Copyright (C) 2013 Roland McGrath

;; Author: Roland McGrath [email protected]
;; Maintainer: Roland McGrath [email protected]
;; Version: 0.1

;; This file is not part of GNU Emacs.

;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.

;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see http://www.gnu.org/licenses/.

;;; Commentary:

;; This is intended for use with edit-server.el and the corresponding
;; "Edit with Emacs" extension for the Chromium/Google Chrome Web browser.
;; See https://github.com/stsquad/emacs_chrome
;;
;; This provides some simple functions for deHTMLizing and reHTMLizing
;; "plain text" as encoded by e.g. GMail composition boxes.

;;; Code:

;; (add-hook 'edit-server-start-hook 'edit-server-maybe-dehtmlize-buffer)
;; (add-hook 'edit-server-done-hook 'edit-server-maybe-htmlize-buffer)

(require 'edit-server)
(require 'html2text)

(defconst edit-server-htmlize-entity-alist
'(("<" . "<")
(">" . ">")
("&" . "&"))
"Alist of strings that cannot safely appear inside an HTML

 element.
This maps a string to its HTML entity string.")

(defconst edit-server-htmlize-regexp
(mapconcat (lambda (pair) (concat "(" (regexp-quote (car pair)) ")"))
edit-server-htmlize-entity-alist
"|"))
(defconst edit-server-htmlize-replacements
(apply 'vector (mapcar 'cdr edit-server-htmlize-entity-alist)))

(defun edit-server-htmlize-replace (regexp replacements)
(save-match-data
(while (re-search-forward regexp nil t)
(let ((i 0))
(while (and (< i (length replacements))
(null (match-beginning (1+ i))))
(setq i (1+ i)))
(replace-match (aref replacements i) t t)))))

(defun edit-server-htmlize-buffer ()
"Do a simple HTMLification of the buffer as plain text.
This produces HTML intended to reproduce the original plain text contents
of the buffer."
(interactive)
(save-excursion
(goto-char (point-min))
(insert "

")
(edit-server-htmlize-replace edit-server-htmlize-regexp
edit-server-htmlize-replacements)
(goto-char (point-max))
(insert "
")))

;; XXX Modified from 23.3.1's gnus/html2text.el html2text,
;; which wants to eat
and refill paragraphs.
(defun edit-server-dehtmlize-buffer ()
"Convert HTML to plain text in the current buffer.
This differs from [html2text] in that it doesn't refill paragraphs,
but only turns
tags into line breaks."
(interactive)
(save-excursion
(let ((case-fold-search t)
(buffer-read-only nil))
(html2text-replace-string "
" "\n" (point-min) (point-max))
(html2text-remove-tags html2text-remove-tag-list)
(html2text-format-tags)
(html2text-remove-tags html2text-remove-tag-list2)
(edit-server-html2text-substitute)
(html2text-format-single-elements))))

(defconst edit-server-html2text-substitute-regexp
(mapconcat (lambda (pair) (concat "(" (regexp-quote (car pair)) ")"))
html2text-replace-list
"|"))
(defconst edit-server-html2text-substitute-replacements
(apply 'vector (mapcar 'cdr html2text-replace-list)))

;; XXX Replacement for 23.3.1's gnus/html2text.el html2text-substitute,
;; which is confounded by "&lt;" and the like.
(defun edit-server-html2text-substitute ()
"See the variable `html2text-replace-list' for documentation."
(interactive)
(goto-char (point-min))
(edit-server-htmlize-replace edit-server-html2text-substitute-regexp
edit-server-html2text-substitute-replacements))

;;;###autoload
(defvar edit-server-htmlize-url-regexp
(concat "^" (regexp-quote "mail.google.com/mail/"))
"*Regexp matching edit-server-url' in a buffer that should be HTMLized. Seeedit-server-maybe-htmlize-buffer'.")

;;;###autoload
(defun edit-server-maybe-htmlize-buffer ()
"Possibly HTMLize the current buffer of plain text.
This calls edit-server-htmlize-buffer' ifedit-server-url'
matches `edit-server-htmlize-url-regexp'.

This is intended for use on `edit-server-done-hook'."
(interactive)
(if (string-match edit-server-htmlize-url-regexp edit-server-url)
(edit-server-htmlize-buffer)))

;;;###autoload
(defun edit-server-maybe-dehtmlize-buffer ()
"Possibly deHTMLize the current buffer into plain text.
This calls edit-server-dehtmlize-buffer' ifedit-server-url'
matches `edit-server-htmlize-url-regexp'.

This is intended for use on `edit-server-start-hook'."
(interactive)
(if (string-match edit-server-htmlize-url-regexp edit-server-url)
(edit-server-dehtmlize-buffer)))

(provide 'edit-server-htmlize)

;;; edit-server-htmlize.el ends here

from emacs_chrome.

jaydixit avatar jaydixit commented on August 19, 2024

Wow, this is awesome!

edit-server-htmlize seems to work except for one thing: When I have two
line breaks in a row, to separate paragraphs from each other, they get read
back into the gmail window as single line breaks. Is there a solution for
this?

jaydixit.com
fol­low @jaydixit https://twitter.com/jaydixit/
Jay Dixit

On Mon, Mar 18, 2013 at 5:53 PM, Roland McGrath [email protected]:

I only care about plain-text mode, but that got harder with a recent GMail
change. I wrote some elisp that works pretty well. I'm pasting the file
in here since I can't find a way to do an attachment, or any plain old
mailing list where I should post this.

;;; edit-server-htmlize.el --- (de)HTMLization hooks for edit-server.el

;;; Copyright (C) 2013 Roland McGrath

;; Author: Roland McGrath [email protected]
;; Maintainer: Roland McGrath [email protected]
;; Version: 0.1

;; This file is not part of GNU Emacs.

;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.

;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see http://www.gnu.org/licenses/.

;;; Commentary:

;; This is intended for use with edit-server.el and the corresponding
;; "Edit with Emacs" extension for the Chromium/Google Chrome Web browser.
;; See https://github.com/stsquad/emacs_chrome
;;
;; This provides some simple functions for deHTMLizing and reHTMLizing
;; "plain text" as encoded by e.g. GMail composition boxes.

;;; Code:

;; (add-hook 'edit-server-start-hook 'edit-server-maybe-dehtmlize-buffer)
;; (add-hook 'edit-server-done-hook 'edit-server-maybe-htmlize-buffer)

(require 'edit-server)
(require 'html2text)

(defconst edit-server-htmlize-entity-alist
'(("<" . "<")
(">" . ">")
("&" . "&"))
"Alist of strings that cannot safely appear inside an HTML

element.

This maps a string to its HTML entity string.")

(defconst edit-server-htmlize-regexp

(mapconcat (lambda (pair) (concat "(" (regexp-quote (car pair)) ")"))

         edit-server-htmlize-entity-alist

         "\|"))

(defconst edit-server-htmlize-replacements

(apply 'vector (mapcar 'cdr edit-server-htmlize-entity-alist)))

(defun edit-server-htmlize-replace (regexp replacements)

(save-match-data

(while (re-search-forward regexp nil t)

  (let ((i 0))

    (while (and (< i (length replacements))

                (null (match-beginning (1+ i))))

      (setq i (1+ i)))

    (replace-match (aref replacements i) t t)))))

(defun edit-server-htmlize-buffer ()

"Do a simple HTMLification of the buffer as plain text.

This produces HTML intended to reproduce the original plain text contents

of the buffer."

(interactive)

(save-excursion

(goto-char (point-min))

(insert "

")

(edit-server-htmlize-replace edit-server-htmlize-regexp

                             edit-server-htmlize-replacements)

(goto-char (point-max))

(insert "

")))

;; XXX Modified from 23.3.1's gnus/html2text.el html2text,
;; which wants to eat
and refill paragraphs.
(defun edit-server-dehtmlize-buffer ()
"Convert HTML to plain text in the current buffer.
This differs from [html2text] in that it doesn't refill paragraphs,
but only turns
tags into line breaks."
(interactive)
(save-excursion
(let ((case-fold-search t)
(buffer-read-only nil))
(html2text-replace-string "
" "\n" (point-min) (point-max))
(html2text-remove-tags html2text-remove-tag-list)
(html2text-format-tags)
(html2text-remove-tags html2text-remove-tag-list2)
(edit-server-html2text-substitute)
(html2text-format-single-elements))))

(defconst edit-server-html2text-substitute-regexp
(mapconcat (lambda (pair) (concat "(" (regexp-quote (car pair)) ")"))
html2text-replace-list
"|"))
(defconst edit-server-html2text-substitute-replacements
(apply 'vector (mapcar 'cdr html2text-replace-list)))

;; XXX Replacement for 23.3.1's gnus/html2text.el html2text-substitute,
;; which is confounded by "<" and the like.
(defun edit-server-html2text-substitute ()
"See the variable `html2text-replace-list' for documentation."
(interactive)
(goto-char (point-min))
(edit-server-htmlize-replace edit-server-html2text-substitute-regexp
edit-server-html2text-substitute-replacements))

;;;###autoload
(defvar edit-server-htmlize-url-regexp
(concat "^" (regexp-quote "mail.google.com/mail/"))
"*Regexp matching edit-server-url' in a buffer that should be HTMLized.
Seeedit-server-maybe-htmlize-buffer'.")

;;;###autoload
(defun edit-server-maybe-htmlize-buffer ()
"Possibly HTMLize the current buffer of plain text.
This calls edit-server-htmlize-buffer' ifedit-server-url'
matches `edit-server-htmlize-url-regexp'.

This is intended for use on `edit-server-done-hook'."
(interactive)
(if (string-match edit-server-htmlize-url-regexp edit-server-url)
(edit-server-htmlize-buffer)))

;;;###autoload
(defun edit-server-maybe-dehtmlize-buffer ()
"Possibly deHTMLize the current buffer into plain text.
This calls edit-server-dehtmlize-buffer' ifedit-server-url'
matches `edit-server-htmlize-url-regexp'.

This is intended for use on `edit-server-start-hook'."
(interactive)
(if (string-match edit-server-htmlize-url-regexp edit-server-url)
(edit-server-dehtmlize-buffer)))

(provide 'edit-server-htmlize)

;;; edit-server-htmlize.el ends here


Reply to this email directly or view it on GitHubhttps://github.com//issues/20#issuecomment-15084475
.

from emacs_chrome.

frobtech avatar frobtech commented on August 19, 2024

edit-server-htmlize seems to work except for one thing: When I have two
line breaks in a row, to separate paragraphs from each other, they get read
back into the gmail window as single line breaks. Is there a solution for
this?

I don't see that. Can you try removing the hooks and then just running
M-x edit-server-dehtmlize-buffer and M-x edit-server-htmlize-buffer by
hand to see the HTML before and after? Then send me all three states
of the buffer.

Thanks,
Roland

from emacs_chrome.

jaydixit avatar jaydixit commented on August 19, 2024

Ah, I see what the problem was. I needed to add this...

(require 'edit-server-htmlize)

...to my .emacs file.

It's working now! You guys are awesome! This works perfectly!

Out of curiosity, does anyone know how I might be able to use Emacs to
write email messages in Markdown, then dump it back into a Gmail window
WHILE applying a specified CSS stylesheet? Kind of like this markdown-here
extension does:
https://github.com/adam-p/markdown-here

It seems like this extension won't work in conjunction
with edit-server-htmlize, because if I understand correctly, the text that
edit-server-htmlize produces is already in HTML format, and markdown-here
will only work if you're converting from plain text. Am I right?

jaydixit.com
fol­low @jaydixit https://twitter.com/jaydixit/
Jay Dixit

On Mon, Mar 18, 2013 at 6:12 PM, Roland McGrath [email protected]:

edit-server-htmlize seems to work except for one thing: When I have two
line breaks in a row, to separate paragraphs from each other, they get
read
back into the gmail window as single line breaks. Is there a solution for
this?

I don't see that. Can you try removing the hooks and then just running
M-x edit-server-dehtmlize-buffer and M-x edit-server-htmlize-buffer by
hand to see the HTML before and after? Then send me all three states
of the buffer.

Thanks,
Roland


Reply to this email directly or view it on GitHubhttps://github.com//issues/20#issuecomment-15085445
.

from emacs_chrome.

stsquad avatar stsquad commented on August 19, 2024

@jaydixit yeah, you'll need to to be careful about what hooks you put in for which sites. However I suggest the various approaches to hooks are best talked about on the Emacs Wiki: http://www.emacswiki.org/emacs/Edit_with_Emacs

from emacs_chrome.

stsquad avatar stsquad commented on August 19, 2024

@frobtech that's awesome. I don't suppose you could send a pull request to add that to the servers directory. It certainly sounds like it should be packaged up as part of Edit with Emacs.

from emacs_chrome.

stsquad avatar stsquad commented on August 19, 2024

Closing this issue as fixed. Use of edit-server-htmlize is documented in the code.

from emacs_chrome.

aspiers avatar aspiers commented on August 19, 2024

I see that edit-server-htmlize now lives at https://github.com/frobtech/edit-server-htmlize

from emacs_chrome.

stsquad avatar stsquad commented on August 19, 2024

@aspiers yeah after some discussion with @frobtech we decided it would be easier to keep it in it's own repo so Roland can manage any incoming patches. I shall be pushing a submission to MELPA soon now the ELPA tags have been merged.

from emacs_chrome.

aspiers avatar aspiers commented on August 19, 2024

I documented it in the emacswiki.

from emacs_chrome.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.