1

I'm trying to create a keyboard shortcut to add date to my class notes in Lyx so that they are organized better. I want the shortcut to add the notes on the left.

That is, I just want to add the following, with the current date each time.

enter image description here

The following keyboard shortcut does half the job:

command-sequence ert-insert; self-insert \reversemarginpar; char-forward; marginalnote-insert; self-insert 2017-05-07; char-forward

However, the date is not assigned dynamically. Is it possible to make the date be filled automatically based on current writing (not compiling) date?

4
  • Have you tried after the self-insert to simply put \today? May 11, 2017 at 13:40
  • @GalGrünfeld This adds the day of compilation and not the day of adding the comment.
    – tmrlvi
    May 11, 2017 at 13:49
  • Untested idea: define a dummy 'converter' to call an external script that puts the date in a file, e.g., currentdate.tex, then in your keyboard shortcut call the converter and self-insert \input{currentdate.tex}.
    – Marijn
    May 11, 2017 at 14:33
  • @Marijn It will work only once, no? If I use the keyboard shortcut twice in a single document, then I'll get the same value in both places.
    – tmrlvi
    May 11, 2017 at 15:03

1 Answer 1

1

The solution is to use the LyX command date-insert instead of self-insert. It receives a parameter for the date format, in strftime format (e.g. %Y-%m-%d).

I.e., the full keyboard binding is:

command-sequence ert-insert; self-insert \reversemarginpar; char-forward; marginalnote-insert; date-insert; char-forward

All the commands appear in LyX Wiki, but without much documentation. The source code contains complete and thorough documentation, so it is easier to find the needed commands there.

As for possibility to use self-insert for dynamic input, by looking at the source, it seems that it only copies the text as is, as if it was inserted using keyboard.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .