auctex-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [AUCTeX-devel] use optional org-time-stamp for TeX macro date (TeX-a


From: Ikumi Keita
Subject: Re: [AUCTeX-devel] use optional org-time-stamp for TeX macro date (TeX-arg-date)
Date: Mon, 31 Jul 2017 23:57:50 +0900

Hi Uwe,

>>>>> Uwe Brauer <address@hidden> writes:
> I would like to use, optionally, org-time-stamp instead of the vanilla
> TeX-arg-date. The advantate is that the calendar is called in it is easy
> to select an appropriate date.

> So I came up with this 

> (defvar TeX-arg-date-use-orgmode nil
>   "Use `org-time-stamp' instead of the simple built in date TeX date 
> function. Default
>  is `nil'.")

> (defun TeX-arg-date (optional &optional prompt)
>   "Prompt for a date, defaulting to the current date.
> If OPTIONAL is non-nil, insert the resulting value as an optional
> argument, otherwise as a mandatory one.  Use PROMPT as the prompt
> string."
>   (if TeX-arg-date-use-orgmode
>        (concat (insert "{") (org-time-stamp nil) (insert "}")) 
>     (let ((default (format-time-string TeX-date-format (current-time))))
>       (TeX-argument-insert
>        (TeX-read-string (TeX-argument-prompt
>                          optional prompt (format "Date (default %s)" default))
>                         nil nil default)
>        optional))))

> (I can send a patch if needed)

> But I must admit that the implementation is very crude. Org-time-stamp
> inserts

> \date{<2017-07-13 Thu>}

> Which is a bit ugly, that format can be changed but as I learned form
> the orgmode list

> ,----
> | Custom format time are applied during fontification time. The major mode
> | you're using in your LaTeX document doesn't know about Org fontification
> | rules.
> | 
> | You may want to add some rules to font lock there
> `----

> So that is a bit though.

> Any suggestions?

The actual job of inserting timestamp is carried out by
`org-insert-time-stamp', which begins with

  (let ((fmt (funcall (if with-hm 'cdr 'car) org-time-stamp-formats))

, and the value of `org-time-stamp-formats' is

("<%Y-%m-%d %a>" . "<%Y-%m-%d %a %H:%M>")

at least for emacs 25.2. So I suppose binding `org-time-stamp-formats'
temporarily with `let' in your custom `TeX-arg-date' would do the trick.

Bye,
Ikumi Keita



reply via email to

[Prev in Thread] Current Thread [Next in Thread]