allow quote / reply date & time format to be set using %D{format}.
authorAlfons Hoogervorst <alfons@proteus.demon.nl>
Sat, 11 May 2002 23:33:22 +0000 (23:33 +0000)
committerAlfons Hoogervorst <alfons@proteus.demon.nl>
Sat, 11 May 2002 23:33:22 +0000 (23:33 +0000)
ChangeLog.claws
configure.in
src/quote_fmt_lex.l
src/quote_fmt_parse.y

index e6460136b64439f41d1c25b59a981da50b10b2c7..4aec4332a7eb05e5bbfe8bbbf79e45ec7787aabc 100644 (file)
@@ -1,3 +1,14 @@
+2002-05-12 [alfons]    0.7.5claws18
+
+       * src/quote_fmt_lex.l
+       * src/quote_fmt_parse.y
+               allow quote / reply date & time format to be set using
+               %D{format}. format is a format string you'd pass to
+               strftime() (see man strftime, or the Display tab |
+               Date format setting).
+
+               Currently %D converts the date to local time. 
+
 2002-05-11 [paul]      0.7.5claws17
 
        * sync with 0.7.5cvs19 (except src/prefs_folder_item.c)
index 757b0d6b85b0005b1f12b1e4895af746828429d0..70a8874639ec64585f58e8ca93c501293e5bf065 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=7
 MICRO_VERSION=5
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws17
+EXTRA_VERSION=claws18
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index e1a083f6ddc2ee902c62a8a1ea36121b1a573a4d..9855d22f0f2a9d0434652b38811207759dba888d 100644 (file)
@@ -6,24 +6,64 @@
 %option prefix="quote_fmt"
 %option outfile="lex.yy.c"
 
+%s S_NORMAL S_DATE
+
+%{
+/*
+ * see notes below.
+ */
+static int firsttime = 1;
+%}
+
 %%
 
-"%d" /* date */ return SHOW_DATE;
-"%f" /* from */ return SHOW_FROM;
-"%N" /* full name */ return SHOW_FULLNAME;
-"%F" /* first name */ return SHOW_FIRST_NAME;
-"%L" /* last name */ return SHOW_LAST_NAME;
-"%I" /* initial of sender */ return SHOW_SENDER_INITIAL;
-"%s" /* subject */ return SHOW_SUBJECT;
-"%t" /* to */ return SHOW_TO;
-"%c" /* cc */ return SHOW_CC;
-"%n" /* newsgroups */ return SHOW_NEWSGROUPS;
-"%i" /* message-id */ return SHOW_MESSAGEID;
-"%r" /* references */ return SHOW_REFERENCES;
-"%M" /* message */ return SHOW_MESSAGE;
-"%Q" /* quoted message */ return SHOW_QUOTED_MESSAGE;
-"%m" /* message with no signature */ return SHOW_MESSAGE_NO_SIGNATURE;
-"%q" /* quoted message with no signature */ return SHOW_QUOTED_MESSAGE_NO_SIGNATURE;
+%{
+/*
+ * NOTES:
+ * this lex script used to use characters also in use
+ * by strftime() (which we want to use for custom
+ * time formats in replies and templates). to circumvent
+ * this we have to play a little bit with states.
+ *
+ * these are the characters we also want to use in the
+ * %D time customizer:
+ *
+ * %a %A %b %B %c %C %d %H %I %j %m %M %p %S %w %x %y %Y %Z
+ *
+ * you can use these characters too, but don't forget to
+ * prepend them with the <S_NORMAL> state.
+ *
+ * also there is also work around for resetting the state
+ * (firsttime variable). this assumes that yylex() will
+ * always return to S_NORMAL after quote fmt parsing is
+ * done.
+ */
+%} 
+
+%{
+       if (firsttime) {
+               BEGIN S_NORMAL;
+               firsttime = 0;
+       }       
+%}
+
+<S_NORMAL>"%c" /* cc */ return SHOW_CC;
+<S_NORMAL>"%d" /* date */ return SHOW_DATE;
+<S_NORMAL>"%D" /* date */ { BEGIN S_DATE; return SHOW_DATE_EXPR; }
+<S_NORMAL>"%f" /* from */ return SHOW_FROM;
+<S_NORMAL>"%F" /* first name */ return SHOW_FIRST_NAME;
+<S_NORMAL>"%i" /* message-id */ return SHOW_MESSAGEID;
+<S_NORMAL>"%I" /* initial of sender */ return SHOW_SENDER_INITIAL;
+<S_NORMAL>"%m" /* message with no signature */ return SHOW_MESSAGE_NO_SIGNATURE;
+<S_NORMAL>"%M" /* message */ return SHOW_MESSAGE;
+<S_NORMAL>"%n" /* newsgroups */ return SHOW_NEWSGROUPS;
+<S_NORMAL>"%N" /* full name */ return SHOW_FULLNAME;
+<S_NORMAL>"%L" /* last name */ return SHOW_LAST_NAME;
+<S_NORMAL>"%r" /* references */ return SHOW_REFERENCES;
+<S_NORMAL>"%s" /* subject */ return SHOW_SUBJECT;
+<S_NORMAL>"%t" /* to */ return SHOW_TO;
+<S_NORMAL>"%Q" /* quoted message */ return SHOW_QUOTED_MESSAGE;
+<S_NORMAL>"%q" /* quoted message with no signature */ return SHOW_QUOTED_MESSAGE_NO_SIGNATURE;
 "\\\%" /* % */ return SHOW_PERCENT;
 "\\\\" /* \ */ return SHOW_BACKSLASH;
 "\\t"|"\t" /* tab */ return SHOW_TAB;
 "?r" /* query references */ return QUERY_REFERENCES;
 "|f" /* insert file */ return INSERT_FILE;
 "|p" /* insert program output */ return INSERT_PROGRAMOUTPUT;
-"{" return OPARENT;
-"}" return CPARENT;
+<S_DATE>"{" return OPARENT;
+<S_DATE>"}" { BEGIN S_NORMAL; return CPARENT; }
+<S_NORMAL>"{" return OPARENT;
+<S_NORMAL>"}" return CPARENT;
 . { yylval.chr = yytext[0]; return CHARACTER; }
 
 %%
index 59b8d04064dc50c7163138210927dc5442c06f49..2f3ec9a4305e760058b3a49c36ebab3806b529c2 100644 (file)
@@ -143,6 +143,7 @@ static int isseparator(char ch)
 %token INSERT_FILE INSERT_PROGRAMOUTPUT
 %token OPARENT CPARENT
 %token CHARACTER
+%token SHOW_DATE_EXPR
 
 %start quote_fmt
 
@@ -191,6 +192,18 @@ special:
                if (msginfo->newsgroups)
                        INSERT(msginfo->newsgroups);
        }
+       | SHOW_DATE_EXPR OPARENT string CPARENT
+       {
+               if (msginfo->date_t) {
+                       char timef[128];
+                       struct tm *lt;
+
+                       if (NULL != (lt = localtime(&msginfo->date_t))) {
+                               strftime(timef, sizeof timef, $3, lt);
+                               INSERT(timef);
+                       }
+               }
+       }
        | SHOW_DATE
        {
                if (msginfo->date)