From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: rcd-paps.el Date: Mon, 19 Dec 2022 15:50:48 +0300 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=_stw1.rcdrun.com-29575-1671455569-0001-2" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8028"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.2.9+54 (af2080d) (2022-11-21) Cc: "help-gnu-emacs@gnu.org" To: Eduardo Ochs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 19 14:13:35 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p7FxU-0001uH-H3 for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 19 Dec 2022 14:13:32 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7Fwu-00043W-KG; Mon, 19 Dec 2022 08:12:56 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p7Fws-00042w-Lc for help-gnu-emacs@gnu.org; Mon, 19 Dec 2022 08:12:54 -0500 Original-Received: from stw1.rcdrun.com ([217.170.207.13]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p7Fwp-0000yJ-Ar for help-gnu-emacs@gnu.org; Mon, 19 Dec 2022 08:12:54 -0500 Original-Received: from localhost ([::ffff:197.239.5.250]) (AUTH: PLAIN admin, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 0000000000055DC5.0000000063A06350.00007387; Mon, 19 Dec 2022 06:12:48 -0700 Mail-Followup-To: Eduardo Ochs , "help-gnu-emacs@gnu.org" Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=217.170.207.13; envelope-from=bugs@gnu.support; helo=stw1.rcdrun.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_SBL=0.141, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:141862 Archived-At: This is a MIME-formatted message. If you see this text it means that your E-mail software does not support MIME-formatted messages. --=_stw1.rcdrun.com-29575-1671455569-0001-2 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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/ --=_stw1.rcdrun.com-29575-1671455569-0001-2 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="rcd-paps.el" ;;; rcd-paps.el --- RCD PAPS Emacs Bindings to PAPS printing utilities ;; Copyright (C) 2021-2022 by Jean Louis ;; Author: Jean Louis ;; 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 . ;;; 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 --=_stw1.rcdrun.com-29575-1671455569-0001-2--