* [feature proposal] Export in foreign buffers - ASCII (ox-ascii)
@ 2018-10-22 19:22 Alexander Adolf
2018-10-24 7:04 ` Nicolas Goaziou
0 siblings, 1 reply; 5+ messages in thread
From: Alexander Adolf @ 2018-10-22 19:22 UTC (permalink / raw)
To: emacs-orgmode
Dear Org-Mode Developers,
I was missing convert-region functions in the ox-ascii export back-end
as are provided by the HTML, LaTeX, Texinfo, and MarkDown back-ends [1],
and hence crafted my own (copied below) to go into my init file. My use
case is composing emails using notmuch-message-mode.
[1] https://orgmode.org/manual/Export-in-foreign-buffers.html
I though this feature might be useful to others, too, and would likely
also seem a low hanging fruit to implement? ;-))
It would be awesome to see this new feature in one of the next releases
of ox-ascii.
Many thanks in advance and cheers,
--alexander
----------------------------------------------------------------------
(defun org-ascii-convert-region-to-ascii ()
"Assume the current region has org-mode syntax, and convert it to plain ASCII.
This can be used in any buffer. For example, you could write an
itemized list in org-mode syntax in a Mail buffer and then use
this command to convert it."
(interactive)
(let ((my/org-ascii-charset org-ascii-charset))
(setq org-ascii-charset 'ascii)
(org-export-replace-region-by 'ascii)
(setq org-ascii-charset my/org-ascii-charset)))
(defun org-ascii-convert-region-to-utf8 ()
"Assume the current region has org-mode syntax, and convert it to UTF-8.
This can be used in any buffer. For example, you could write an
itemized list in org-mode syntax in a Mail buffer and then use
this command to convert it."
(interactive)
(let ((my/org-ascii-charset org-ascii-charset))
(setq org-ascii-charset 'utf-8)
(org-export-replace-region-by 'ascii)
(setq org-ascii-charset my/org-ascii-charset)))
----------------------------------------------------------------------
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [feature proposal] Export in foreign buffers - ASCII (ox-ascii)
2018-10-22 19:22 [feature proposal] Export in foreign buffers - ASCII (ox-ascii) Alexander Adolf
@ 2018-10-24 7:04 ` Nicolas Goaziou
2018-10-24 17:03 ` Alexander Adolf
0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Goaziou @ 2018-10-24 7:04 UTC (permalink / raw)
To: Alexander Adolf; +Cc: emacs-orgmode
Hello,
Alexander Adolf <alexander.adolf@condition-alpha.com> writes:
> I was missing convert-region functions in the ox-ascii export back-end
> as are provided by the HTML, LaTeX, Texinfo, and MarkDown back-ends [1],
> and hence crafted my own (copied below) to go into my init file. My use
> case is composing emails using notmuch-message-mode.
>
> [1] https://orgmode.org/manual/Export-in-foreign-buffers.html
>
> I though this feature might be useful to others, too, and would likely
> also seem a low hanging fruit to implement? ;-))
It looks like an omission, indeed.
> (defun org-ascii-convert-region-to-ascii ()
> "Assume the current region has org-mode syntax, and convert it to plain ASCII.
> This can be used in any buffer. For example, you could write an
> itemized list in org-mode syntax in a Mail buffer and then use
> this command to convert it."
> (interactive)
> (let ((my/org-ascii-charset org-ascii-charset))
> (setq org-ascii-charset 'ascii)
> (org-export-replace-region-by 'ascii)
> (setq org-ascii-charset my/org-ascii-charset)))
I see you are not including Latin1 export. Is there any reason to
implement pure ASCII export? Wouldn't UTF-8 be sufficient?
More generally, I wonder if, in 2018, it still makes sense to provide
ASCII-only and Latin1 export.
> (defun org-ascii-convert-region-to-utf8 ()
> "Assume the current region has org-mode syntax, and convert it to UTF-8.
Org syntax
> This can be used in any buffer. For example, you could write an
> itemized list in org-mode syntax in a Mail buffer and then use
in Org syntax in a mail buffer
Anyway, I don't think the example is useful.
> this command to convert it."
> (interactive)
> (let ((my/org-ascii-charset org-ascii-charset))
> (setq org-ascii-charset 'utf-8)
> (org-export-replace-region-by 'ascii)
> (setq org-ascii-charset my/org-ascii-charset)))
I think
(let ((org-ascii-charset 'utf-8))
(org-export-replace-region-by 'ascii))
would be simpler.
The manual needs to be updated, too.
Thank you.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [feature proposal] Export in foreign buffers - ASCII (ox-ascii)
2018-10-24 7:04 ` Nicolas Goaziou
@ 2018-10-24 17:03 ` Alexander Adolf
2018-10-25 14:56 ` Nicolas Goaziou
0 siblings, 1 reply; 5+ messages in thread
From: Alexander Adolf @ 2018-10-24 17:03 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode
Hello Nicolas,
Many thanks for your swift response!
On 2018-10-24, at 09:04 , Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
> [...]
> I see you are not including Latin1 export. Is there any reason to
> implement pure ASCII export? Wouldn't UTF-8 be sufficient?
>
> More generally, I wonder if, in 2018, it still makes sense to provide
> ASCII-only and Latin1 export.
I was of the same opinion, hence I didn't include Latin-1.
Is pure ASCII still useful? I admit using UTF-8 99% of the time. But sometimes there's the odd guy using that arcane email client and who complains that my message came out garbled. That's when the pure ASCII comes in handy. That will always work; 100% guaranteed.
No strong feelings on whether to include pure ASCII or not. On the other hand, it seems so cheap implementation wise, you might just as well choose to include all three (i.e. UTF-8, ASCII, and Latin-1).
> [...]
> (let ((org-ascii-charset 'utf-8))
> (org-export-replace-region-by 'ascii))
>
> would be simpler.
Bummer! This was my initial version, actually. But for some reason it didn't seem to work (maybe I forgot eval-region?). You are right (of course), and I have switched my implementation back to my original approach (which copied below for completeness).
> The manual needs to be updated, too.
> [...]
Indeed.
Many thanks again and cheers,
--alexander
----------------------------------------------------------------------
(defun org-ascii-convert-region-to-ascii ()
"Assume the current region has Org syntax, and convert it to
plain ASCII. This can be used in any buffer. For example, you
could write an itemized list or a table in Org syntax in a mail
buffer and then use this command to convert it."
(interactive)
(let ((org-ascii-charset 'ascii))
(org-export-replace-region-by 'ascii)))
(defun org-ascii-convert-region-to-utf8 ()
"Assume the current region has Org syntax, and convert it to
UTF-8. This can be used in any buffer. For example, you could
write an itemized list or a table in Org syntax in a mail buffer
and then use this command to convert it."
(interactive)
(let ((org-ascii-charset 'utf-8))
(org-export-replace-region-by 'ascii)))
----------------------------------------------------------------------
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [feature proposal] Export in foreign buffers - ASCII (ox-ascii)
2018-10-24 17:03 ` Alexander Adolf
@ 2018-10-25 14:56 ` Nicolas Goaziou
2018-10-25 15:07 ` Alexander Adolf
0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Goaziou @ 2018-10-25 14:56 UTC (permalink / raw)
To: Alexander Adolf; +Cc: emacs-orgmode
Hello,
Alexander Adolf <alexander.adolf@condition-alpha.com> writes:
> ----------------------------------------------------------------------
> (defun org-ascii-convert-region-to-ascii ()
> "Assume the current region has Org syntax, and convert it to
> plain ASCII. This can be used in any buffer. For example, you
> could write an itemized list or a table in Org syntax in a mail
> buffer and then use this command to convert it."
> (interactive)
> (let ((org-ascii-charset 'ascii))
> (org-export-replace-region-by 'ascii)))
>
> (defun org-ascii-convert-region-to-utf8 ()
> "Assume the current region has Org syntax, and convert it to
> UTF-8. This can be used in any buffer. For example, you could
> write an itemized list or a table in Org syntax in a mail buffer
> and then use this command to convert it."
> (interactive)
> (let ((org-ascii-charset 'utf-8))
> (org-export-replace-region-by 'ascii)))
> ----------------------------------------------------------------------
I added the functions to "ox-ascii.el", with an autoload cookie,
a simplified docstring, and an entry in the manual.
Thank you.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [feature proposal] Export in foreign buffers - ASCII (ox-ascii)
2018-10-25 14:56 ` Nicolas Goaziou
@ 2018-10-25 15:07 ` Alexander Adolf
0 siblings, 0 replies; 5+ messages in thread
From: Alexander Adolf @ 2018-10-25 15:07 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode
Hello Nicolas,
On 2018-10-25, at 16:56 , Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
> [...]
> I added the functions to "ox-ascii.el", with an autoload cookie,
> a simplified docstring, and an entry in the manual.
> [...]
Wow, many thanks for being so kind as to include them! That was faster and way easier than I had anticipated. ;-))
Many thanks again!
--alexander
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-10-25 15:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-22 19:22 [feature proposal] Export in foreign buffers - ASCII (ox-ascii) Alexander Adolf
2018-10-24 7:04 ` Nicolas Goaziou
2018-10-24 17:03 ` Alexander Adolf
2018-10-25 14:56 ` Nicolas Goaziou
2018-10-25 15:07 ` Alexander Adolf
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).