all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Eduardo Ochs <eduardoochs@gmail.com>
Cc: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: Re: rcd-paps.el
Date: Mon, 19 Dec 2022 15:50:48 +0300	[thread overview]
Message-ID: <Y6BeKFChYpwWhFAq@protected.localdomain> (raw)
In-Reply-To: <CADs++6gfn+JSnzUoUBC12vfYC-pmHEMWiGR8MyZ6u2=0J7n3xg@mail.gmail.com>

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

This package is not finished, find it attached if you wish to modify
or suggest things.

I use it in peculiar way:

M-x rcd-paps-buffer-to-pdf and

M-x rcd-paps-buffer-to-pdf-view 

which anyway generates PDF file, and then I send PDF file for
printing.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/

[-- Attachment #2: rcd-paps.el --]
[-- Type: text/plain, Size: 6962 bytes --]

;;; rcd-paps.el --- RCD PAPS Emacs Bindings to PAPS printing utilities

;; Copyright (C) 2021-2022 by Jean Louis

;; Author: Jean Louis <bugs@gnu.support>
;; Version: 0.1
;; Package-Requires: (rcd-utilities)
;; Keywords: tools
;; URL: 

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

;;; Commentary:

;;; Change Log:

;;; Code:

(require 'rcd-utilities)

(defcustom rcd-paps-orientation nil
  "Page orientation. By default it is portrait, if TRUE, it will
be landscape"
  :group 'rcd-paps
  :type 'boolean)

(defcustom rcd-paps-columns 1
  "Number of columns output"
  :group 'rcd-paps
  :type 'integer)

(defcustom rcd-paps-pdf-viewer "evince"
  "PDF Viewer"
  :group 'rcd-paps
  :type 'string)

;; (defcustom rcd-paps-paper "evince"
;;   "PDF Viewer"
;;   :group 'rcd-paps
;;   :type 'string)

(defcustom rcd-paps-output-directory (file-name-as-directory (getenv "HOME"))
  "Default PAPS output directory."
  :group 'rcd-paps
  :type 'string)

;; Application Options:
;;   --landscape                       Landscape output. (Default: portrait)
;;   --columns=NUM                     Number of columns output. (Default: 1)
;;   --font=DESC                       Set font. (Default: Monospace 12)
;;   -o, --output=DESC                 Output file. (Default: stdout)
;;   -v, --version                     Current version.
;;   --rtl                             Do right-to-left text layout.
;;   --justify                         Justify the layout.
;;   --hyphens                         Show hyphens when wrapping.
;;   --wrap=WRAP                       Text wrapping mode [word, char, word-char]. (Default: word-char)
;;   --show-wrap                       Show characters for wrapping.
;;   --paper=PAPER                     Set paper size [legal, letter, a3, a4]. (Default: a4)
;;   --gravity=GRAVITY                 Base glyph rotation [south, west, north, east, auto]. (Defaut: auto)
;;   --gravity-hint=HINT               Base glyph orientation [natural, strong, line]. (Default: natural)
;;   --format=FORMAT                   Set output format [pdf, svg, ps]. (Default: ps)
;;   --bottom-margin=NUM               Set bottom margin in postscript point units (1/72 inch). (Default: 36)
;;   --top-margin=NUM                  Set top margin. (Default: 36)
;;   --right-margin=NUM                Set right margin. (Default: 36)
;;   --left-margin=NUM                 Set left margin. (Default: 36)
;;   --gutter-width=NUM                Set gutter width. (Default: 40)
;;   --header                          Draw page header for each page.
;;   --footer                          Draw page footer for each page.
;;   --title=TITLE                     Title string for page header (Default: filename/stdin).
;;   --header-left=HEADER_LEFT         Left side of the header. Default is localized date.
;;   --header-center=HEADER_CENTER     Center side of the header. Default is localized date.
;;   --header-right=HEADER_RIGHT       Right side of the header. Default is localized date.
;;   --markup                          Interpret input text as pango markup.
;;   --encoding=ENCODING               Assume encoding of input text. (Default: UTF-8)
;;   --lpi=REAL                        Set the amount of lines per inch.
;;   --cpi=REAL                        Set the amount of characters per inch.
;;   --g-fatal-warnings=REAL           Make all glib warnings fatal.

(defun rcd-paps-process (text &optional format title &rest args)
  (let* ((format (or format "pdf"))
	 (title (cond (title title)
		      (current-prefix-arg (rcd-ask-get "Title: "))
		      (t (buffer-name))))
	 (length (length title))
	 (orientation (cond (rcd-paps-orientation "--landscape")
			    (current-prefix-arg (when (y-or-n-p "Do you wish to use landscape? ")
						  "--landscape"))))
	 (max 45)
	 (title (if (> length max) (substring title 0 max) title)))
    (apply 'rcd-command-output-from-input "paps" text "--format" format "--title" title "--header"
	   (format "--columns=%d"
		   (cond (current-prefix-arg (rcd-ask-number "Columns: "))
			 (t rcd-paps-columns)))
	   (cond (orientation (append (list "--landscape") args))
		 (t args)))))

(defun rcd-paps-text-to-pdf (text &optional file-name title)
  (let* ((output (rcd-paps-process text "pdf" title))
	 (file-name (or file-name (concat (file-name-as-directory (getenv "HOME")) (rcd-ask "File name without .pdf extension: ") ".pdf"))))
    (string-to-file-force output  file-name)))

(defun rcd-paps-buffer-to-pdf ()
  (interactive)
  (let ((output (rcd-paps-process-buffer))
	(file-name (rcd-temp-file-name nil "pdf")))
    (prog1
	(string-to-file-force output file-name)
	(rcd-message "PDF: %s" file-name))))

(defun rcd-paps-buffer-to-pdf-view ()
  (interactive)
  (start-process rcd-paps-pdf-viewer rcd-paps-pdf-viewer rcd-paps-pdf-viewer (rcd-paps-buffer-to-pdf)))

(defun rcd-paps-region-to-pdf ()
  (interactive)
  (let ((output (rcd-paps-process-region))
	(file-name (rcd-temp-file-name nil "pdf")))
    (prog1
	(string-to-file-force output file-name)
	(rcd-message "PDF: %s" file-name))))

(defun rcd-paps-region-to-pdf-view ()
  (interactive)
  (start-process rcd-paps-pdf-viewer rcd-paps-pdf-viewer rcd-paps-pdf-viewer (rcd-paps-region-to-pdf)))

(defun rcd-paps-process-region (&rest args)
  (let ((text (rcd-region-string)))
    (when text
      (apply 'rcd-paps-process text args))))

(defun rcd-paps-process-buffer (&rest args)
  (let ((text (buffer-substring-no-properties (point-min) (point-max))))
    (apply 'rcd-paps-process text args)))

(defun rcd-paps-print-buffer ()
  (interactive)
  (let* ((file-name (concat (buffer-name) ".pdf"))
	 (file (read-file-name "File name: " rcd-paps-output-directory nil nil file-name))
	 (output (rcd-paps-process-buffer)))
    (string-to-file-force output file)
    (message "Buffer printed to `%s'" file)))

(defun rcd-export-pdf ()
  (interactive)
  (let* ((type "pdf")
	 (file (concat rcd-paps-output-directory (buffer-name) "." type))
	 (output (x-export-frames nil (intern type))))
    (string-to-file-force output file)
    (message "Buffer printed to `%s'" file)))

(defun rcd-paps-config-paper ()
  (interactive)
  (let ((paper (rcd-choose '("legal" "letter" "a3" "a4") "Configure `paps' paper size: " nil "a4")))
    (customize-set-value rcd-paps-paper paper)))

(provide 'rcd-paps)

;;; rcd-paps.el ends here

  reply	other threads:[~2022-12-19 12:50 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-14 16:38 wie kann ich Emacs so einstellen, dass ich drucken kann Gottfried
2022-12-14 17:27 ` Philip Kaludercic
2022-12-16 15:27   ` printing Gottfried
2022-12-16 22:26     ` printing Michael Heerdegen
2022-12-17  6:29       ` printing tomas
2022-12-17  7:41         ` printing Emanuel Berg
2022-12-17 13:48     ` printing Gottfried
2022-12-17 16:30       ` printing tomas
2022-12-14 21:30 ` wie kann ich Emacs so einstellen, dass ich drucken kann Michael Heerdegen
2022-12-17  9:00 ` Jean Louis
2022-12-17  9:29   ` Michael Heerdegen
2022-12-17  9:41     ` Jean Louis
2022-12-17 10:34       ` Michael Heerdegen
2022-12-17 10:39         ` Michael Heerdegen
2022-12-18  8:04   ` Eduardo Ochs
2022-12-18 17:18     ` Jean Louis
2022-12-18 22:34       ` rcd-paps.el (was: Re: wie kann ich Emacs...) Eduardo Ochs
2022-12-19 12:50         ` Jean Louis [this message]
2022-12-18 12:06   ` wie kann ich Emacs so einstellen, dass ich drucken kann Gottfried
2022-12-18 17:20     ` Jean Louis
2022-12-19 13:49       ` Gottfried
2022-12-19 17:19         ` Jean Louis
2022-12-27 16:10           ` wie kann ich Emacs so einstellen, dass ich drucken kann (printing in Emacs) Gottfried
2022-12-27 17:35             ` Jean Louis
2022-12-27 16:39           ` wie kann ich Emacs so einstellen, dass ich drucken kann (printing with paps) Gottfried
2022-12-27 16:47             ` Gottfried
2022-12-27 17:37               ` Jean Louis
2022-12-28 16:31                 ` printing with paps Gottfried
2022-12-30 14:26                   ` Jean Louis
2022-12-31 12:09                     ` Gottfried
2022-12-31 22:53                       ` Jean Louis
2022-12-31 23:46                         ` Jean Louis
2023-01-01 14:24                           ` Gottfried
2023-01-01 14:53                             ` Jean Louis

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

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

  git send-email \
    --in-reply-to=Y6BeKFChYpwWhFAq@protected.localdomain \
    --to=bugs@gnu.support \
    --cc=eduardoochs@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.