From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Glenn Morris Newsgroups: gmane.emacs.devel Subject: Re: cal-tex.el landscape patch Date: Mon, 28 Aug 2017 13:55:59 -0400 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1503943162 19273 195.159.176.226 (28 Aug 2017 17:59:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 28 Aug 2017 17:59:22 +0000 (UTC) User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) Cc: Edward Reingold , emacs-devel To: Vincent =?utf-8?Q?Bela=C3=AFche?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 28 19:59:18 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmOJa-0004Qk-8L for ged-emacs-devel@m.gmane.org; Mon, 28 Aug 2017 19:59:10 +0200 Original-Received: from localhost ([::1]:40909 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmOJh-0007Kc-8Z for ged-emacs-devel@m.gmane.org; Mon, 28 Aug 2017 13:59:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35409) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmOGd-0005Nw-Bz for emacs-devel@gnu.org; Mon, 28 Aug 2017 13:56:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmOGc-00064U-Fm for emacs-devel@gnu.org; Mon, 28 Aug 2017 13:56:07 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:50077) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmOGX-00063A-3g; Mon, 28 Aug 2017 13:56:01 -0400 Original-Received: from rgm by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1dmOGV-00069v-Dh; Mon, 28 Aug 2017 13:55:59 -0400 X-Spook: Food Poisoning Ricin Transportation Security X-Ran: j$qABko_cE6N&ada^se#KAt$zgi"Mjo9X~uldm$EVs3Zgo+EL/mVXyJ^GWJEep0$l(t6ca X-Hue: yellow X-Attribution: GM In-Reply-To: ("Vincent \=\?utf-8\?Q\?Bela\=C3\=AFche\=22's\?\= message of "Sat, 26 Aug 2017 15:29:34 +0000") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:217869 Archived-At: Thanks, comments below. > --- a/lisp/calendar/cal-tex.el > +++ b/lisp/calendar/cal-tex.el > @@ -259,12 +259,37 @@ cal-tex-list-diary-entries > (defun cal-tex-preamble (&optional args) > "Insert the LaTeX calendar preamble into `cal-tex-buffer'. > Preamble includes initial definitions for various LaTeX commands. > -Optional string ARGS are included as options for the article document class." > +Optional string ARGS are included as options for the article > +document class with inclusion of default values \"12pt\" for > +size, and \"a4paper\" for paper unless size or paper are already > +specified in ARGS. When ARGS is omitted, by default the option > +\"12pt,a4paper\" is passed. I think in hindsight my suggestion to default to 12pt was not a good one, because it makes the argument parsing ugly. Sorry. And please don't default to A4 paper, since the default locale for Emacs is the US one (spelling etc). > +Please note that if ARGS is \"\" then > +\"\\documentclass[]{article}\" is inserted, while if ARGS it `t' > +then \"\\documentclass{article}\" is inserted." This doesn't seem like a nice interface. Why do you need the ARGS t case when it can be nil? > (set-buffer (generate-new-buffer cal-tex-buffer)) > - (insert (format "\\documentclass%s{article}\n" > - (if (stringp args) > - (format "[%s]" args) > - ""))) > + (save-match-data > + (insert (format "\\documentclass%s{article}\n" > + (cond > + ((stringp args) > + ;; set default size > + (unless (string-match "\\(^\\|,\\) *[0-9]+pt *\\(,\\|$\\)" args) > + (setq args (concat args ",12pt"))) > + ;; set default paper > + (unless (string-match "\\(^\\|,\\) *\\([ab][4-5]\\|le\\(tter\\|gal\\)\\|executive\\)paper *\\(,\\|$\\)" args) > + (setq args (concat args ",a4paper"))) > + (when (string= (substring args 0 1) ",") > + (setq args (substring args 1))) > + (format "[%s]" args)) > + ((null args) "[12pt]") > + (t "")))) This seems overly complicated to me. Again, it wasa bad suggestion of mine to have default values. string-match-p would avoid the need to save-match-data.