unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Vincent Belaïche" <vincent.b.1@hotmail.fr>
To: Glenn Morris <rgm@gnu.org>
Cc: Edward Reingold <reingold@iit.edu>, emacs-devel <emacs-devel@gnu.org>
Subject: RE: cal-tex.el landscape patch
Date: Wed, 30 Aug 2017 09:45:07 +0000	[thread overview]
Message-ID: <AM5PR10MB0676B63C858EFD04246BF6F8849C0@AM5PR10MB0676.EURPRD10.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <xma82jwp8w.fsf@fencepost.gnu.org>


Hello,

Comments below,


De : Glenn Morris <rgm@gnu.org>
Envoyé : lundi 28 août 2017 19:55
À : Vincent Belaïche
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 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.

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 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?

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= (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.


  reply	other threads:[~2017-08-30  9:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-21 14:19 cal-tex.el landscape patch Vincent Belaïche
2017-08-22  7:04 ` Marcin Borkowski
2017-08-22 22:05   ` Vincent Belaïche
2017-08-25  1:10 ` Glenn Morris
2017-08-25  9:07   ` Vincent Belaïche
2017-08-25 17:58     ` Vincent Belaïche
2017-08-25 18:25       ` Edward Reingold
2017-08-26 15:06         ` Vincent Belaïche
2017-08-26 15:29           ` Vincent Belaïche
2017-08-28 17:20             ` Paul Eggert
2017-08-28 17:55             ` Glenn Morris
2017-08-30  9:45               ` Vincent Belaïche [this message]
2017-09-14 12:46                 ` Vincent Belaïche
2017-09-14 20:31                   ` Glenn Morris

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.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=AM5PR10MB0676B63C858EFD04246BF6F8849C0@AM5PR10MB0676.EURPRD10.PROD.OUTLOOK.COM \
    --to=vincent.b.1@hotmail.fr \
    --cc=emacs-devel@gnu.org \
    --cc=reingold@iit.edu \
    --cc=rgm@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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.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).