emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: rbenit68@openmailbox.org
To: York Zhao <gtdplatform@gmail.com>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: How to export casual letter without from and to address?
Date: Thu, 24 Mar 2016 13:32:44 +0100	[thread overview]
Message-ID: <a45ebdc3c1fd9f6f5101ad24c53acee6@openmailbox.org> (raw)
In-Reply-To: <CAD3zm23AN4CzTrBFDCYM+459BtcJSS+0DcpiPMD0GX1nOZLBAg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1339 bytes --]

El 2016-03-04 06:12, York Zhao escribió:
> Hi list,
> 
> I've been wondering for a while that when using org-mode to write 
> letters, how
> do you export casual a letter that doesn't have from address and to 
> address?
> 
> Thanks in advance,
> 
> York

I would like to share a lightweight solution based on groff.

I have assembled an ob-groff.el file mostly coping the essential parts 
from ox-asymptote.el.

Once this is done, you can C-c C-c a groff source block and get the link 
to the output file in the same buffer.


Notes:

- Tested with emacs 24.5 and 25.0.92, org-plus-contrib ELPA 20160321, on 
OS 10.10.5.

- groff last version 1.22.3, which has -D<encoding> option; remove from 
:cmdline if your groff version is < 1.22.3

- pdf output is hardcoded in ob-groff.el; you can remove from there and 
add to :cmdline to get .ps or .dvi files if you prefer.

- Groff examples are from:

http://etutorials.org/Linux+systems/red+hat+linux+bible+fedora+enterprise+edition/Part+II+Using+Red+Hat+Linux/Chapter+6+Publishing+with+Red+Hat+Linux/Creating+Documents+in+Groff+or+LaTeX/

http://pipeline.lbl.gov/code/3rd_party/licenses.win/groff/1.19.2/html/mom/letters.html

I hope not to have forgotten acknowledgment to some of those wonderful 
people that write and share FOSS.

Thanks all!


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ob-groff-sample.org --]
[-- Type: text/x-lisp; name=ob-groff-sample.org, Size: 7007 bytes --]

#+STARTUP: hideblocks


#+BEGIN_SRC emacs-lisp
;; Author: Tim Krones (itsjeyd)
;; Date: Jan 14 '15 at 15:03:48Z
;; http://emacs.stackexchange.com/questions/7211/collapse-src-blocks-in-org-mode-by-default

(defvar org-blocks-hidden nil)
(defun org-toggle-blocks ()
  (interactive)
  (if org-blocks-hidden
      (org-show-block-all)
    (org-hide-block-all))
  (setq-local org-blocks-hidden (not org-blocks-hidden)))
#+END_SRC


#+BEGIN_SRC emacs-lisp
;; Author: John Kitchin
;; Date: 2016 Feb 27 at 02:12:20Z
;; http://emacs.stackexchange.com/questions/20577/org-babel-load-all-languages-on-demand
;;
(defadvice org-babel-execute-src-block (around load-language nil activate)
  "Load language if needed"
  (let ((language (org-element-property :language (org-element-at-point))))
    (unless (cdr (assoc (intern language) org-babel-load-languages))
      (add-to-list 'org-babel-load-languages (cons (intern language) t))
      (org-babel-do-load-languages 'org-babel-load-languages org-babel-load-languages))
    ad-do-it))
#+END_SRC


#+BEGIN_SRC emacs-lisp
;;;
;;; ob-groff.el --- Babel Functions for GNU troff (groff)          -*- lexical-binding: t; -*-

;; Copyright (C) 2016 rbenit68

;; Author: rbenit68 at openmailbox dot org
;; Contributors:
;; Version: 0.1
;; Keywords: org, babel, source block, groff

;; This file is not part of GNU Emacs.

;; This program 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 of the License, or
;; (at your option) any later version.

;; This program 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 GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.

;;; Commentary:

;; GNU troff (groff) from org-mode source blocks.
;; 

;;; Code:
(require 'ob)

(defvar org-babel-default-header-args:groff '())

(defvar org-babel-groff-command "groff"
  "Name of command to use for executing groff code.")

(defun org-babel-execute:groff (body params)
  "Execute a block of groff code.
This function is called by `org-babel-execute-src-block'."
  (let* ((out-file (cdr (assoc :file params)))
         (format (or (and out-file
                          (string-match ".+\\.\\(.+\\)" out-file)
                          (match-string 1 out-file))
                     "pdf"))
         (cmdline (cdr (assoc :cmdline params)))
         (in-file (org-babel-temp-file "groff-"))
         (cmd
	  (concat "groff "
		  " -Tpdf " cmdline
		  " " (org-babel-process-file-name in-file)
		  (if out-file
		      (concat
		       " > " (org-babel-process-file-name out-file))
		    )
)))
    (with-temp-file in-file
      (insert (org-babel-expand-body:generic
	       body params
	       )))
    (message cmd) (shell-command cmd)
    nil)) ;; signal that output has already been written to file

(defun org-babel-prep-session:groff (_session _params)
  "Return an error if the :session header argument is set.
groff does not support sessions."
  (error "groff sessions are nonsensical"))

(provide 'ob-groff)

;;; ob-groff.el ends here

#+end_src


#+BEGIN_SRC emacs-lisp
;; Author: Nicholas Van Horn
;; Date: 2016, last seen: Mar 23 '16 21:45CET
;; http://nicholasvanhorn.com/posts/org-structure-completion.html 

;;(eval-after-load 'org
;;  '(progn
     (add-to-list 'org-structure-template-alist
                  '("g" "#+BEGIN_SRC groff :file foo.pdf :cmdline -Dutf-8 \n?\n#+END_SRC" "<src lang=\"?\">\n\n</src>"))
;;   )
;;)
#+END_SRC


#+BEGIN_SRC groff :file letter.pdf :cmdline -Dutf-8 -mom
.AUTHOR    "RBYannick P. Guique"
.DOCTYPE    LETTER
.PRINTSTYLE TYPESET
.START
.sp 2in
.FROM
.RIGHT
.Y.P. GUIQUE
.022 Umask Road
.St-Sauveur-en-dehors-de-la-mappe, Québec
.TO
.GUILLAUME BARRIÈRES
.Minidoux Corporation
.5000 Pannes Drive
.Redmond, Virginia
.DATE
.RIGHT
August 25, 2004
.GREETING
Dear Mr. Barrières,
.PP
It has come to my attention that you have been lobbying the
US government to prohibit the use of open source software by
endeavouring to outlaw so-called "warranty free"
applications.
.PP
I feel it is my duty to inform you that the success of your
operating system with its embedded web browser relies heavily
on open source programs and protocolS, Most notably TCP/IP.
.PP
Therefore, in the interests of your corporation's fiscal health,
I strongly advise that you withdraw support for any US
legislation that would cripple or render illegal open source
development.
.CLOSING
Sincerely, 
#+END_SRC


#+BEGIN_SRC groff :file header.pdf :cmdline -Dutf-8 -mom
.de PP
.sp
.ti +0.25i
.ft R
..
.de HD
.sp
.ps \\$1
.ce
.ft B
\\$2
.ps
.ft P
.sp
..
.sp 0.67i
.HD 14 "A sample header"
.PP
We begin the text of the first paragraph here. This is indented
and formatted. We continue with the text of the first paragraph
until we want the second paragraph.
.PP
We re-issue the macro, and get the space and indent.
#+end_src


#+BEGIN_SRC groff :file lettermm.pdf :cmdline -Dutf-8 -mm
.WA "Christopher T. Craft"
999 Anyway Way
Anytown, UT 84111 USA
.WE
.IA
John W. Doe
111 Notown Blvd.
Notown, UT 84111
.IE
.LO RN "Our telephone conversation"
.LO SA "Dear Mr. Doe:"
.LT
In reference to our telephone conversation on the 4th, I am calling to
confirm our upcoming appointment on the 18th. I look forward to
discussing the merger. I believe we have a win-win situation here.
.FC "Yours Truly,"
.SG
#+END_SRC


#+BEGIN_SRC groff :file memo.pdf :cmdline -Dutf-8 -mm
.TL
Merger Technical Specifications
.AF "ABC Corporation"
.AU "Christopher Craft"
.AT "President"
.AS
This memo details the specifications for the planned merger.
.AE
.MT "Merger Description and Marching Orders"
As a result of our talks with XYZ corporation, we plan to go
forward with the merger. This document contains the following:
.BL
.LI
Schedule and time tables.
.LI
Financial statements.
.LI
Asset allocations.
.LE
.SP
Please add any corrections you have, then sign the approval line
indicated at the bottom of this sheet.
.FC
.SG
.AV "John W. Doe, XYZ Corporation President"
.AV "Sylvia Q. Public, XYZ Corporation CFO"
.NS
Everyone in the corporation.
.NE
#+END_SRC


#+BEGIN_SRC groff :file equation.pdf :cmdline -Dutf-8 -mm -e
.EQ
a ~ mark = ~ 30
.EN
.sp
.EQ
a sup 2 ~ + ~ b sup 2~lineup = ~ 1000
.EN
.sp
.EQ
x sup 3 ~ + ~ y sup 3 ~ + ~ z sup 3~lineup = ~ 1400
.EN
#+END_SRC


#+BEGIN_SRC groff :file table.pdf :cmdline -Dutf-8 -mm -t
.TS
center, box, tab(:);
c s s
c | c | c
l | l | l.
Mergers and Acquisitions Team
=
Employee:Title:Location
=_
Jones, James:Marketing Manager:New York Office
Smith, Charles:Sales Manager:Los Angeles Office
Taylor, Sarah:R&D Manager:New York Office
Walters, Mark:Information Systems Manager:Salt Lake City Office
Zur, Mike:Distribution Manager:Portland Office
.TE
#+END_SRC



      parent reply	other threads:[~2016-03-24 13:13 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-04  5:12 How to export casual letter without from and to address? York Zhao
2016-03-05  3:36 ` York Zhao
2016-03-05 10:12   ` Eric S Fraga
2016-03-05 11:22     ` H. Dieter Wilhelm
2016-03-05 15:57       ` York Zhao
2016-03-06 10:38         ` H. Dieter Wilhelm
2016-03-05 15:47     ` York Zhao
2016-03-05 17:33       ` Marcin Borkowski
2016-03-05 18:56       ` Eric S Fraga
2016-03-05 19:52         ` Marcin Borkowski
2016-03-06 19:02           ` Rasmus
2016-03-06  3:15       ` Nick Dokos
2016-03-06 19:04 ` Rasmus
2016-03-07  1:11   ` York Zhao
2016-03-24 12:32 ` rbenit68 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a45ebdc3c1fd9f6f5101ad24c53acee6@openmailbox.org \
    --to=rbenit68@openmailbox.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=gtdplatform@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).