[california] atsign adds location to summary (hash replaces atsign): Bug #735938
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [california] atsign adds location to summary (hash replaces atsign): Bug #735938
- Date: Tue, 23 Sep 2014 22:37:25 +0000 (UTC)
commit f520506da1045f1bec163ea2272b4da18b80e28b
Author: Jim Nelson <jim yorba org>
Date: Tue Sep 23 15:35:47 2014 -0700
atsign adds location to summary (hash replaces atsign): Bug #735938
"@" now works like English "at" in Quick Add. Since there might
still be some motivation for not including the location in the
summary, "#" can be used as atsign did before this commit.
src/component/component-details-parser.vala | 27 ++++++++++----
src/tests/tests-quick-add.vala | 53 ++++++++++++++++++++++++++-
2 files changed, 72 insertions(+), 8 deletions(-)
---
diff --git a/src/component/component-details-parser.vala b/src/component/component-details-parser.vala
index e3de8d4..65fe221 100644
--- a/src/component/component-details-parser.vala
+++ b/src/component/component-details-parser.vala
@@ -27,7 +27,11 @@ public class DetailsParser : BaseObject {
/**
* { link Shorthand} for TIME or LOCATION.
*/
- ATSIGN;
+ ATSIGN,
+ /**
+ * { link Shorthand} for TIME or LOCATION w/o including in title.
+ */
+ HASH;
/**
* Converts a string to a recognized { link Shorthand}.
@@ -37,6 +41,9 @@ public class DetailsParser : BaseObject {
case "@":
return ATSIGN;
+ case "#":
+ return HASH;
+
default:
return NONE;
}
@@ -222,7 +229,12 @@ public class DetailsParser : BaseObject {
continue;
stack.restore();
- // The ATSIGN is also recognized as a TIME preposition
+ // The ATSIGN and HASH is also recognized as a TIME preposition
+ stack.mark();
+ if (token.shorthand == Shorthand.HASH && parse_time(stack.pop(), false))
+ continue;
+ stack.restore();
+
stack.mark();
if (token.shorthand == Shorthand.ATSIGN && parse_time(stack.pop(), false))
continue;
@@ -250,14 +262,15 @@ public class DetailsParser : BaseObject {
stack.restore();
// only look for LOCATION prepositions if not already adding text to the location field
- // (ATSIGN is considered a LOCATION preposition)
+ // (HASH is considered a special LOCATION preposition)
if (!adding_location
- && (token.casefolded in LOCATION_PREPOSITIONS || token.shorthand == Shorthand.ATSIGN)) {
+ && (token.casefolded in LOCATION_PREPOSITIONS || token.shorthand == Shorthand.HASH
+ || token.shorthand == Shorthand.ATSIGN)) {
// add current token (the preposition) to summary but not location (because location
// tokens are added to summary, i.e. "dinner at John's" yields "John's" for location
- // and "dinner at John's" for summary) ... note that ATSIGN does not add to summary
+ // and "dinner at John's" for summary) ... note that HASH does not add to summary
// to allow for more concise summaries
- if (token.shorthand != Shorthand.ATSIGN)
+ if (token.shorthand != Shorthand.HASH)
add_text(token);
// now adding to both summary and location
@@ -265,7 +278,7 @@ public class DetailsParser : BaseObject {
// ...unless at-sign used, which has the side-effect of not adding to summary
// (see above)
- if (token.shorthand == Shorthand.ATSIGN)
+ if (token.shorthand == Shorthand.HASH)
adding_summary = false;
continue;
diff --git a/src/tests/tests-quick-add.vala b/src/tests/tests-quick-add.vala
index 168ea73..2997849 100644
--- a/src/tests/tests-quick-add.vala
+++ b/src/tests/tests-quick-add.vala
@@ -55,9 +55,12 @@ private class QuickAdd : UnitTest.Harness {
add_case("time-range-no-meridiem", time_range_no_meridiem);
add_case("atsign-location", atsign_location);
add_case("atsign-time", atsign_time);
+ add_case("hash-location", hash_location);
+ add_case("hash-time", hash_time);
add_case("quoted", quoted);
add_case("open-quoted", open_quoted);
add_case("quoted-atsign", quoted_atsign);
+ add_case("quoted-hash", quoted_hash);
add_case("ymd-dm", ymd_dm);
}
@@ -611,7 +614,7 @@ private class QuickAdd : UnitTest.Harness {
dump = parser.event.source;
- return parser.event.summary == "Dinner"
+ return parser.event.summary == "Dinner @ Tadich Grill"
&& parser.event.location == "Tadich Grill"
&& !parser.event.is_all_day
&& parser.event.exact_time_span.start_exact_time.hour == 19
@@ -637,6 +640,38 @@ private class QuickAdd : UnitTest.Harness {
&& parser.event.exact_time_span.get_date_span().equal_to(Calendar.System.today.to_date_span());
}
+ private bool hash_location(out string? dump) throws Error {
+ Component.DetailsParser parser = new Component.DetailsParser(
+ "Dinner # Tadich Grill 7pm", null);
+
+ dump = parser.event.source;
+
+ return parser.event.summary == "Dinner"
+ && parser.event.location == "Tadich Grill"
+ && !parser.event.is_all_day
+ && parser.event.exact_time_span.start_exact_time.hour == 19
+ && parser.event.exact_time_span.start_exact_time.minute == 0
+ && parser.event.exact_time_span.end_exact_time.hour == 20
+ && parser.event.exact_time_span.end_exact_time.minute == 0
+ && parser.event.exact_time_span.get_date_span().equal_to(Calendar.System.today.to_date_span());
+ }
+
+ private bool hash_time(out string? dump) throws Error {
+ Component.DetailsParser parser = new Component.DetailsParser(
+ "Dinner # 7pm", null);
+
+ dump = parser.event.source;
+
+ return parser.event.summary == "Dinner"
+ && parser.event.location == null
+ && !parser.event.is_all_day
+ && parser.event.exact_time_span.start_exact_time.hour == 19
+ && parser.event.exact_time_span.start_exact_time.minute == 0
+ && parser.event.exact_time_span.end_exact_time.hour == 20
+ && parser.event.exact_time_span.end_exact_time.minute == 0
+ && parser.event.exact_time_span.get_date_span().equal_to(Calendar.System.today.to_date_span());
+ }
+
private bool quoted(out string? dump) throws Error {
Component.DetailsParser parser = new Component.DetailsParser(
"\"Live at Budokon\" at The Roxy 7pm", null);
@@ -669,6 +704,22 @@ private class QuickAdd : UnitTest.Harness {
dump = parser.event.source;
+ return parser.event.summary == "\"Live at Budokon\" @ The Roxy"
+ && parser.event.location == "The Roxy"
+ && !parser.event.is_all_day
+ && parser.event.exact_time_span.start_exact_time.hour == 19
+ && parser.event.exact_time_span.start_exact_time.minute == 0
+ && parser.event.exact_time_span.end_exact_time.hour == 20
+ && parser.event.exact_time_span.end_exact_time.minute == 0
+ && parser.event.exact_time_span.get_date_span().equal_to(Calendar.System.today.to_date_span());
+ }
+
+ private bool quoted_hash(out string? dump) throws Error {
+ Component.DetailsParser parser = new Component.DetailsParser(
+ "\"Live at Budokon\" # The Roxy 7pm", null);
+
+ dump = parser.event.source;
+
return parser.event.summary == "\"Live at Budokon\""
&& parser.event.location == "The Roxy"
&& !parser.event.is_all_day
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]