From: Tero Tilus <tero@tilus.net>
To: sup-talk <sup-talk@rubyforge.org>
Subject: [sup-talk] [PATCH] Moar configurability (was: AM/PM display)
Date: Sat, 19 Dec 2009 01:51:51 +0200 [thread overview]
Message-ID: <1261179239-sup-9258@tilus.net> (raw)
In-Reply-To: <1261167840-sup-592@orion>
[-- Attachment #1: Type: text/plain, Size: 708 bytes --]
Jay Mendoza, 2009-12-18 22:26:
> In inbox-mode, Sup seems to display all of my message as if they
> were received in the PM hours. Is this a known defect, or just a
> misconfiguration on my part?
I remember seeing AM hours (and see them now). I also don't see how
it possibly could be caused by configuration.
...which reminds me of a couple of configurability hacks (configurable
"missing attachment detector" and configurable thread list date
formats) I cooked together quite a while ago and don't remenber
sharing yet. Shame on me. So here they are, keep them if you like
them (if they aren't already obsoleted by something I'm not aware of)
--
Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/
[-- Attachment #2: 0006-configurable-listing-date-formats-and-attachment-det.patch --]
[-- Type: application/octet-stream, Size: 2827 bytes --]
From 6b331fbe954f085f8d0867d7881db1a45fac67a2 Mon Sep 17 00:00:00 2001
From: Tero Tilus <tero@tilus.net>
Date: Sat, 19 Dec 2009 01:31:10 +0200
Subject: [PATCH] configurable listing date formats and attachment detection
Signed-off-by: Tero Tilus <tero@tilus.net>
---
lib/sup.rb | 8 ++++++++
lib/sup/modes/edit-message-mode.rb | 2 +-
lib/sup/util.rb | 19 ++++++++++---------
3 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/lib/sup.rb b/lib/sup.rb
index 7f9396c..a5cbb95 100644
--- a/lib/sup.rb
+++ b/lib/sup.rb
@@ -218,6 +218,13 @@ else
:signature => File.join(ENV["HOME"], ".signature")
}
},
+ :time_format => {
+ :same_day => "%l:%M%P",
+ :day_before => "Yest.%l%P",
+ :same_month => "%b %e",
+ :same_year => "%b %e",
+ :otherwise => "%b %Y",
+ },
:editor => ENV["EDITOR"] || "/usr/bin/vim -f -c 'setlocal spell spelllang=en_us' -c 'set filetype=mail'",
:thread_by_subject => false,
:edit_signature => false,
@@ -225,6 +232,7 @@ else
:ask_for_bcc => false,
:ask_for_subject => true,
:confirm_no_attachments => true,
+ :mentions_attachment_regex => '\battach(ment|ed|ing|)\b',
:confirm_top_posting => true,
:discard_snippets_from_encrypted_messages => false,
:default_attachment_save_dir => "",
diff --git a/lib/sup/modes/edit-message-mode.rb b/lib/sup/modes/edit-message-mode.rb
index 8849271..4e4c63f 100644
--- a/lib/sup/modes/edit-message-mode.rb
+++ b/lib/sup/modes/edit-message-mode.rb
@@ -444,7 +444,7 @@ private
end
def mentions_attachments?
- @body.any? { |l| l =~ /^[^>]/ && l =~ /\battach(ment|ed|ing|)\b/i }
+ @body.any? { |l| l =~ /^[^>]/ && l =~ /#{$config[:mentions_attachment_regexp] || '\battach(ment|ed|ing|)\b'}/i }
end
def top_posting?
diff --git a/lib/sup/util.rb b/lib/sup/util.rb
index f99e1c1..2ca9fa1 100644
--- a/lib/sup/util.rb
+++ b/lib/sup/util.rb
@@ -480,17 +480,18 @@ class Time
TO_NICE_S_MAX_LEN = 9 # e.g. "Yest.10am"
def to_nice_s from=Time.now
- if year != from.year
- strftime "%b %Y"
- elsif month != from.month
- strftime "%b %e"
+ fmt = $config[:time_format]
+ if is_the_same_day? from
+ strftime(fmt[:same_day] || "%l:%M%P")
+ elsif is_the_day_before? from
+ nearest_hour.strftime(fmt[:day_before] || "Yest.%l%P")
else
- if is_the_same_day? from
- strftime("%l:%M%P")
- elsif is_the_day_before? from
- "Yest." + nearest_hour.strftime("%l%P")
+ if year != from.year
+ strftime(fmt[:otherwise] || "%b %Y")
+ elsif month != from.month
+ strftime(fmt[:same_year] || "%b %e")
else
- strftime "%b %e"
+ strftime(fmt[:same_month] || "%b %e")
end
end
end
--
1.5.6.5
[-- Attachment #3: Type: text/plain, Size: 140 bytes --]
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk
next prev parent reply other threads:[~2009-12-18 23:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-18 20:26 [sup-talk] AM/PM display Jay Mendoza
2009-12-18 21:34 ` Mike Kelly
2009-12-18 23:51 ` Tero Tilus [this message]
2009-12-19 18:12 ` [sup-talk] [PATCH] Moar configurability (was: AM/PM display) William Morgan
2009-12-20 2:31 ` Tero Tilus
2009-12-21 13:38 ` William Morgan
2009-12-19 18:12 ` [sup-talk] AM/PM display William Morgan
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1261179239-sup-9258@tilus.net \
--to=tero@tilus.net \
--cc=sup-talk@rubyforge.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox