From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?iso-8859-1?Q?Vincent_Bela=EFche?= Newsgroups: gmane.emacs.devel Subject: RE: cal-tex.el landscape patch Date: Thu, 14 Sep 2017 12:46:12 +0000 Message-ID: References: , , NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="_000_AM5PR10MB0676A0CBE892A51E1E202BF4846F0AM5PR10MB0676EURP_" X-Trace: blaine.gmane.org 1505393196 16591 195.159.176.226 (14 Sep 2017 12:46:36 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 14 Sep 2017 12:46:36 +0000 (UTC) Cc: Edward Reingold , emacs-devel To: Glenn Morris Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Sep 14 14:46:32 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 1dsTXL-0004Ah-Qc for ged-emacs-devel@m.gmane.org; Thu, 14 Sep 2017 14:46:32 +0200 Original-Received: from localhost ([::1]:47648 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsTXT-0003jA-86 for ged-emacs-devel@m.gmane.org; Thu, 14 Sep 2017 08:46:39 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36633) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsTXD-0003h4-N8 for emacs-devel@gnu.org; Thu, 14 Sep 2017 08:46:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsTXB-0003T1-GH for emacs-devel@gnu.org; Thu, 14 Sep 2017 08:46:23 -0400 Original-Received: from mail-oln040092072026.outbound.protection.outlook.com ([40.92.72.26]:44192 helo=EUR03-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dsTX5-0003Mj-DG; Thu, 14 Sep 2017 08:46:15 -0400 Original-Received: from VE1EUR03FT015.eop-EUR03.prod.protection.outlook.com (10.152.18.52) by VE1EUR03HT053.eop-EUR03.prod.protection.outlook.com (10.152.19.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.35.14; Thu, 14 Sep 2017 12:46:12 +0000 Original-Received: from AM5PR10MB0676.EURPRD10.PROD.OUTLOOK.COM (10.152.18.55) by VE1EUR03FT015.mail.protection.outlook.com (10.152.18.176) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.20.35.14 via Frontend Transport; Thu, 14 Sep 2017 12:46:12 +0000 Original-Received: from AM5PR10MB0676.EURPRD10.PROD.OUTLOOK.COM ([fe80::cc7c:4104:f217:d185]) by AM5PR10MB0676.EURPRD10.PROD.OUTLOOK.COM ([fe80::cc7c:4104:f217:d185%13]) with mapi id 15.20.0056.010; Thu, 14 Sep 2017 12:46:12 +0000 Thread-Topic: cal-tex.el landscape patch Thread-Index: AQHTGod4AUzM6bbSVkywIfPXHbKr+KKUSM/QgACExcWAAJSvKIAAB9aAgAFXIAqAAAhRq4ADTzsNgAJrbluAF/UDCQ== In-Reply-To: Accept-Language: fr-FR, en-US Content-Language: fr-FR X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: gnu.org; dkim=none (message not signed) header.d=none;gnu.org; dmarc=none action=none header.from=hotmail.fr; x-incomingtopheadermarker: OriginalChecksum:5748D9C002B00CA542EF8EF1789A11EA9A86DD91FF15BEE11BB9CC63FEF4574B; UpperCasedChecksum:EB303D27CDF43D773EB987BBC4050C0689167C0EA373C8B76131435EFE3B0E5F; SizeAsReceived:7739; Count:47 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [mQ8onhj/W5odFQLU5wRayCpSrxIie+ch] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VE1EUR03HT053; 6:Pj3z8LXg0xI7YesR9R3YmsdM8hqUqOvDqs95FVhHB7YsCknBSk9E/85M2enW8TBAJI1kWedtpJ0ktl7Vt/qW7Lo7RlM9O1wW8oSgLFb6mA/mpjK7567TdlRMuFx5+EKd/d5eTxS8t4yMU6aOvtboYhB8x+8KMFabCdp7A8dUMUJ1agcjCqrz3APwb3fHFrKX58T9dj7CPI0GjYb3qF1hwfLQEKXqJ12XggOomJKvaK2VqFNVUy2IgYPeWCdjzoWTuSl7NrZk2prnJ246DgpB0xlGlUWN2YRQ15OSrLpVa0BTpfNDqd14NXYLfGv1KCAJ/R4/6Mlp6p8PrdQ0eDNvHQ==; 5:b7GbSO/TfnWD/oKCaxBQbxaxvzQJKNWv4Uu19JzU7FAow9L9shDYFXTW8VCRXLQKjY0RVM9dE7UCRIwuhZTPdrGCE1G6s5ZXpTNx6Xsn8aLasOztXBk6saaodOMZtQ7RcV4/YeuBKNl7hpC6a7jEkQ==; 24:YCExXI+lXAwww1kxxOlxnoCk+NwnY6sARyAuIsGoMyEaUFiH/r0xvrLuM4DITdvsJ7J2ldBQZCwR6uy6lupz/s9UNgmUvwLVWHMxgBKUeog=; 7:kP713AER8L1VyX0cf8cFLKVHJ2kdVtk7K8rbRw0UJ/I2zFsYNXlmVaOFAjHQlBSDkILjm7uNS0ggH12YOySjfKf8VkQxTy8NJFWwiDu77EJq9vhVZS7XqoGirGWiAkRv/o3cXuYzh6P/t6tLudc2PHPl8chDCdk69GSpNx8nqKeWIhdar91LfaVRkSpQ3TGmuWt4UPEyKk/k3jRVxDLctnw2sZycIY9Te x-incomingheadercount: 47 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: aaaef61a-c81e-4adc-e763-08d4fb6e94da x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(300000503095)(300135400095)(201702061074)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031324274)(2017031323274)(2017031322404)(1601125374)(1603101448)(1701031045)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:VE1EUR03HT053; x-ms-traffictypediagnostic: VE1EUR03HT053: x-exchange-antispam-report-test: UriScan:(22074186197030)(170290950945281); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(444000031); SRVR:VE1EUR03HT053; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:VE1EUR03HT053; x-forefront-prvs: 0430FA5CB7 x-forefront-antispam-report: SFV:NSPM; SFS:(7070007)(98901004); DIR:OUT; SFP:1901; SCL:1; SRVR:VE1EUR03HT053; H:AM5PR10MB0676.EURPRD10.PROD.OUTLOOK.COM; FPR:; SPF:None; LANG:; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Sep 2017 12:46:12.7493 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR03HT053 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.92.72.26 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:218263 Archived-At: --_000_AM5PR10MB0676A0CBE892A51E1E202BF4846F0AM5PR10MB0676EURP_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello Glenn, Maybe I have missed your answer. If there was no answer yet, please take yo= ur time, no hurry, I just wanted to make sure that I have not overlooked an= ything. V. ________________________________ De : Vincent Bela=EFche Envoy=E9 : mercredi 30 ao=FBt 2017 11:45 =C0 : Glenn Morris Cc : Edward Reingold; emacs-devel Objet : RE: cal-tex.el landscape patch Hello, Comments below, De : Glenn Morris Envoy=E9 : lundi 28 ao=FBt 2017 19:55 =C0 : Vincent Bela=EFche Cc : Edward Reingold; emacs-devel Objet : Re: cal-tex.el landscape patch > >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 c= lass." >> +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. So you mean that I should remove the argument parsing. But it cannot be removed all together because anyway I parse this argument to detect landscape option. >And please don't default to A4 paper, since the default locale for >Emacs is the US one (spelling etc). Would it be acceptable then if letterpaper is specified. Specifying the paper is a good idea because some latex distribution can be installed with a default paper size different from letterpaper. If we want \paperwidth and \paperheight defined to the correct value in the document so that the LaTeX code compute the cell size autonmously and the users can configure what paper size they want, then it is good that paper is explicitely defined. > >> +Please note that if ARGS is \"\" then >> +\"\\documentclass[]{article}\" is i= nserted, 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? If nil, then the options list is the default one, that is in the case of my path `12pt,a4paper'. It could make that an empty string generates `\documentclass{article}' instead of `\documentclass[]{article}' that would remove the need of having the `t' case. I thought that it was good to let the function caller decide what they want in the output, but since `\documentclass{article}' and `\documentclass[]{article}' are equivalent this is not really usefull. > >> (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=3D (substring args 0 1) ",") >> + (setq args (substring args 1))) >> + (format "[%s]" args)) >> + ((null args) "[12pt]") Reading the patch, I realize that I did a mistake, it should have been ((null args) "[12pt,a4paper]") Or with whatever paper size you want a default. >> >> + (t "")))) > >This seems overly complicated to me. I see here the main point for acceptance of this patch. Would it be more acceptabe if the (string-match blah blah blah) would be replaced by some defsubst like (cal-tex-has-size-p args) (cal-tex-has-paper-p args) >Again, it was a bad suggestion of mine to have default values. As I wrote, having the paper size explicitely configured would help if different paper sizes are to be supported in the future. And this feature is part of the TO DO list at the beginning of cal-tex.el : ;; TO DO [...] ;; (*) Make calendar styles for A4 paper. Now, this paper and point size defaults should certainly be some defcustom. Even more, there should be one first defcustom, call it cal-tex-default-options for all the types of calendars, and one other defcustom, call it cal-tex-default-options-alist, for types calendar that need some particular configuration different from cal-tex-default-options. >string-match-p would avoid the need to save-match-data. OK, noted. I will use this in the future. Vincent. --_000_AM5PR10MB0676A0CBE892A51E1E202BF4846F0AM5PR10MB0676EURP_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hello Glenn,
Maybe I have missed your answer. If there was no answer yet, please take yo= ur time, no hurry, I just wanted to make sure that I have not overlooked an= ything.
  V.


De : Vincent Bela=EFche &= lt;vincent.b.1@hotmail.fr>
Envoy=E9 : mercredi 30 ao=FBt 2017 11:45
=C0 : Glenn Morris
Cc : Edward Reingold; emacs-devel
Objet : RE: cal-tex.el landscape patch
 

Hello,

Comments below,


De : Glenn Morris <rgm@gnu.org>
Envoy=E9 : lundi 28 ao=FBt 2017 19:55
=C0 : Vincent Bela=EFche
Cc : Edward Reingold; emacs-devel
Objet : Re: cal-tex.el landscape patch
>
>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 `c= al-tex-buffer'.
>>  Preamble includes initial definitions for various LaTeX comm= ands.
>> -Optional string ARGS are included as options for the article docu= ment class."
>> +Optional string ARGS are included as options for the article<= br> >> +document class with inclusion of default values \"12pt\&= quot; for
>> +size, and \"a4paper\" for paper unless size or pape= r 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.

So you mean that I should remove the argument parsing. But it cannot be
removed all together because anyway I parse this argument to detect
landscape option.

>And please don't default to A4 paper, since the default locale for
>Emacs is the US one (spelling etc).

Would it be acceptable then if letterpaper is specified. Specifying the
paper is a good idea because some latex distribution can be installed
with a default paper size different from letterpaper.

If we want \paperwidth and \paperheight defined to the correct value in
the document so that the LaTeX code compute the cell size autonmously
and the users can configure what paper size they want, then it is good
that paper is explicitely defined.

>
>> +Please note that if ARGS is \"\" then
>> +\"\\docum= entclass[]{article}\" is inserted, while if ARGS it `t'
>> +then \"\\do= cumentclass{article}\" is inserted."
>
>This doesn't seem like a nice interface.  Why do you need the ARGS= t
>case when it can be nil?

If nil, then the options list is the default one, that is in the case of my path `12pt,a4paper'. It could make that an empty string generates
`\documentclass{article}' instead of `\documentclass[]{article}' that
would remove the need of having the `t' case.

I thought that it was good to let the function caller decide what they
want in the output, but since `\documentclass{article}' and
`\documentclass[]{article}' are equivalent this is not really usefull.


>
>>    (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"
>> +          &= nbsp;         (cond
>> +          &= nbsp;          ((stringp args)=
>> +          &= nbsp;           ;; set de= fault size
>> +          &= nbsp;           (unless (= string-match "\\(^\\|,\\) *[0-9]+pt *\\(,\\|$\\)" args)
>> +          &= nbsp;           &nbs= p; (setq args (concat args ",12pt")))
>> +          &= nbsp;           ;; set de= fault paper
>> +          &= nbsp;           (unless (= string-match "\\(^\\|,\\) *\\([ab][4-5]\\|le\\(tter\\|gal\\)\\|executi= ve\\)paper *\\(,\\|$\\)" args)
>> +          &= nbsp;           &nbs= p; (setq args (concat args ",a4paper")))
>> +          &= nbsp;           (when (st= ring=3D (substring args 0 1) ",")
>> +          &= nbsp;           &nbs= p; (setq args (substring args 1)))
>> +          &= nbsp;           (format &= quot;[%s]" args))
>> +          &= nbsp;          ((null args) &q= uot;[12pt]")

Reading the patch, I realize that I did a mistake, it should have been

   ((null args) "[12pt,a4paper]")

Or with whatever paper size you want a default.


>>
>> + (t ""))))
>
>This seems overly complicated to me.

I see here the main point for acceptance of this patch. Would it be more acceptabe if the (string-match blah blah blah) would be replaced by some defsubst like

(cal-tex-has-size-p args)

(cal-tex-has-paper-p args)



>Again, it was a bad suggestion of mine to have default values.

As I wrote, having the paper size explicitely configured would help if
different paper sizes are to be supported in the future. And this
feature is part of the TO DO list at the beginning of cal-tex.el :

;; TO DO

[...]

;;     (*)  Make calendar styles for A4 paper.

Now, this paper and point size defaults should certainly be some
defcustom. Even more, there should be one first defcustom, call it
cal-tex-default-options for all the types of calendars, and one other
defcustom, call it cal-tex-default-options-alist, for types calendar
that need some particular configuration different from
cal-tex-default-options.

>string-match-p would avoid the need to save-match-data.

OK, noted. I will use this in the future.

  Vincent.
--_000_AM5PR10MB0676A0CBE892A51E1E202BF4846F0AM5PR10MB0676EURP_--