[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Erc-commit] [commit][emacs22] erc-stamp: Put timestamp on both left and
From: |
mwolson |
Subject: |
[Erc-commit] [commit][emacs22] erc-stamp: Put timestamp on both left and right by default |
Date: |
Sun, 14 Oct 2007 00:49:03 -0400 |
commit 1b48951546788176ae91a7778006f981db09aeeb
Author: Michael Olson <address@hidden>
Date: Wed Jun 20 00:26:17 2007 +0000
erc-stamp: Put timestamp on both left and right by default
2007-06-20 Michael Olson <address@hidden>
* erc-stamp.el (erc-timestamp-format-left): New option that
specifies the left timestamp to use for
erc-insert-timestamp-left-and-right.
(erc-timestamp-format-right): New option that specifies the right
timestamp to use for erc-insert-timestamp-left-and-right.
(erc-insert-timestamp-function): Change default to
erc-insert-timestamp-left-and-right.
(erc-insert-away-timestamp-function): Ditto.
(erc-timestamp-last-inserted-left)
(erc-timestamp-last-inserted-right): New variables to keep track
of data for erc-insert-timestamp-left-and-right.
(erc-insert-timestamp-left-and-right): New function that places
timestamps on both the left and right sides of the screen, but
only if each timestamp has changed since it was last computed.
Thanks to offby1 for urging me to merge this.
git-archimport-id: address@hidden/erc--main--0--patch-152
diff --git a/ChangeLog b/ChangeLog
index fcd6883..ea81e0f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2007-06-20 Michael Olson <address@hidden>
+
+ * erc-stamp.el (erc-timestamp-format-left): New option that
+ specifies the left timestamp to use for
+ erc-insert-timestamp-left-and-right.
+ (erc-timestamp-format-right): New option that specifies the right
+ timestamp to use for erc-insert-timestamp-left-and-right.
+ (erc-insert-timestamp-function): Change default to
+ erc-insert-timestamp-left-and-right.
+ (erc-insert-away-timestamp-function): Ditto.
+ (erc-timestamp-last-inserted-left)
+ (erc-timestamp-last-inserted-right): New variables to keep track
+ of data for erc-insert-timestamp-left-and-right.
+ (erc-insert-timestamp-left-and-right): New function that places
+ timestamps on both the left and right sides of the screen, but
+ only if each timestamp has changed since it was last computed.
+ Thanks to offby1 for urging me to merge this.
+
2007-06-19 Michael Olson <address@hidden>
* erc-log.el: Update header with accurate instructions.
diff --git a/erc-stamp.el b/erc-stamp.el
index 0b8017f..d753dd0 100644
--- a/erc-stamp.el
+++ b/erc-stamp.el
@@ -58,16 +58,48 @@ If nil, timestamping is turned off."
:type '(choice (const nil)
(string)))
-(defcustom erc-insert-timestamp-function 'erc-insert-timestamp-right
+(defcustom erc-timestamp-format-left "\n[%a %b %e %Y]\n"
+ "*If set to a string, messages will be timestamped.
+This string is processed using `format-time-string'.
+Good examples are \"%T\" and \"%H:%M\".
+
+This timestamp is used for timestamps on the left side of the
+screen when `erc-insert-timestamp-function' is set to
+`erc-insert-timestamp-left-and-right'.
+
+If nil, timestamping is turned off."
+ :group 'erc-stamp
+ :type '(choice (const nil)
+ (string)))
+
+(defcustom erc-timestamp-format-right " [%H:%M]"
+ "*If set to a string, messages will be timestamped.
+This string is processed using `format-time-string'.
+Good examples are \"%T\" and \"%H:%M\".
+
+This timestamp is used for timestamps on the right side of the
+screen when `erc-insert-timestamp-function' is set to
+`erc-insert-timestamp-left-and-right'.
+
+If nil, timestamping is turned off."
+ :group 'erc-stamp
+ :type '(choice (const nil)
+ (string)))
+
+(defcustom erc-insert-timestamp-function 'erc-insert-timestamp-left-and-right
"*Function to use to insert timestamps.
It takes a single argument STRING which is the final string
which all text-properties already appended. This function only cares about
inserting this string at the right position. Narrowing is in effect
while it is called, so (point-min) and (point-max) determine the region to
-operate on."
+operate on.
+
+You will probably want to set
+`erc-insert-away-timestamp-function' to the same value."
:group 'erc-stamp
- :type '(choice (const :tag "Right" erc-insert-timestamp-right)
+ :type '(choice (const :tag "Both sides" erc-insert-timestamp-left-and-right)
+ (const :tag "Right" erc-insert-timestamp-right)
(const :tag "Left" erc-insert-timestamp-left)
function))
@@ -82,12 +114,14 @@ If `erc-timestamp-format' is set, this will not be used."
:type '(choice (const nil)
(string)))
-(defcustom erc-insert-away-timestamp-function 'erc-insert-timestamp-right
+(defcustom erc-insert-away-timestamp-function
+ 'erc-insert-timestamp-left-and-right
"*Function to use to insert the away timestamp.
See `erc-insert-timestamp-function' for details."
:group 'erc-stamp
- :type '(choice (const :tag "Right" erc-insert-timestamp-right)
+ :type '(choice (const :tag "Both sides" erc-insert-timestamp-left-and-right)
+ (const :tag "Right" erc-insert-timestamp-right)
(const :tag "Left" erc-insert-timestamp-left)
function))
@@ -160,6 +194,18 @@ or `erc-send-modify-hook'."
"Last timestamp inserted into the buffer.")
(make-variable-buffer-local 'erc-timestamp-last-inserted)
+(defvar erc-timestamp-last-inserted-left nil
+ "Last timestamp inserted into the left side of the buffer.
+This is used when `erc-insert-timestamp-function' is set to
+`erc-timestamp-left-and-right'")
+(make-variable-buffer-local 'erc-timestamp-last-inserted-left)
+
+(defvar erc-timestamp-last-inserted-right nil
+ "Last timestamp inserted into the right side of the buffer.
+This is used when `erc-insert-timestamp-function' is set to
+`erc-timestamp-left-and-right'")
+(make-variable-buffer-local 'erc-timestamp-last-inserted-right)
+
(defcustom erc-timestamp-only-if-changed-flag t
"*Insert timestamp only if its value changed since last insertion.
If `erc-insert-timestamp-function' is `erc-insert-timestamp-left', a
@@ -272,6 +318,26 @@ be printed just before the window-width."
(when erc-timestamp-intangible
(erc-put-text-property from (1+ (point)) 'intangible t)))))
+(defun erc-insert-timestamp-left-and-right (string)
+ "This is another function that can be assigned to
+`erc-insert-timestamp-function'. If the date is changed, it will
+print a blank line, the date, and another blank line. If the time is
+changed, it will then print it off to the right."
+ (let* ((ct (current-time))
+ (ts-left (erc-format-timestamp ct erc-timestamp-format-left))
+ (ts-right (erc-format-timestamp ct erc-timestamp-format-right)))
+ ;; insert left timestamp
+ (unless (string-equal ts-left erc-timestamp-last-inserted-left)
+ (goto-char (point-min))
+ (erc-put-text-property 0 (length ts-left) 'field 'erc-timestamp ts-left)
+ (insert ts-left)
+ (setq erc-timestamp-last-inserted-left ts-left))
+ ;; insert right timestamp
+ (let ((erc-timestamp-only-if-changed-flag t)
+ (erc-timestamp-last-inserted erc-timestamp-last-inserted-right))
+ (erc-insert-timestamp-right ts-right)
+ (setq erc-timestamp-last-inserted-right ts-right))))
+
;; for testing: (setq erc-timestamp-only-if-changed-flag nil)
(defun erc-format-timestamp (time format)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Erc-commit] [commit][emacs22] erc-stamp: Put timestamp on both left and right by default,
mwolson <=