[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Circe-help] [PATCH] lui-time-stamp: support timestamps in margins

From: John Foerch
Subject: [Circe-help] [PATCH] lui-time-stamp: support timestamps in margins
Date: Wed, 4 Mar 2009 16:19:22 -0500

Two new values are added for lui-time-stamp-position: 'right-margin
and 'left-margin.  When either of these values is used, time-stamps
are displayed in said margin.  Margins are a new feature in Emacs 23.
See (info "(elisp)Display Margins") for details.

One thing that this patch does not do is turn the margin on.  It may
be best left to the user to do that step, because it is hard to
determine exactly how wide the margin should be.  A setup for margin
time-stamps might be like this:

   lui-time-stamp-position 'right-margin
   lui-time-stamp-format "%H:%M")

  (defun jjf-circe-set-margin ()
    (setq right-margin-width 5))
  (add-hook 'lui-mode-hook 'jjf-circe-set-margin)
 lui.el |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/lui.el b/lui.el
index 7e62797..daedbaa 100644
--- a/lui.el
+++ b/lui.el
@@ -206,11 +206,19 @@ This can be one of the following values:
       At the left side of the output. The output is thereby moved
       to the right.
+  'right-margin
+      In the right margin.  You will need to set right-margin-width
+      in all circe buffers.
+  'left-margin
+      In the left margin.  You will need to set left-margin-width
+      in all circe buffers.
       Do not add any time stamp."
   :type '(choice (const :tag "Right" right)
                  (integer :tag "Column")
                  (const :tag "Left" left)
+                 (const :tag "Right Margin" right-margin)
+                 (const :tag "Left Margin" left-margin)
                  (const :tag "None" nil))
   :group 'lui)
@@ -1057,7 +1065,19 @@ function."
                 (overlay-put ov 'field 'lui-time-stamp-indentation)
                 (overlay-put ov 'before-string indent-string))
             (insert indent-string))
-          (forward-line 1)))))
+          (forward-line 1))))
+     ((or (eq lui-time-stamp-position 'right-margin)
+          (eq lui-time-stamp-position 'left-margin))
+      (when (or (not lui-time-stamp-only-when-changed-p)
+                (not lui-time-stamp-last)
+                (not (string= ts lui-time-stamp-last)))
+        (let ((ts (propertize ts 'face 'lui-time-stamp-face)))
+          (let ((ov (make-overlay (point-min) (point-max)))
+                (time-stamp
+                 (propertize
+                  " "
+                  'display `((margin ,lui-time-stamp-position) ,ts))))
+            (overlay-put ov 'before-string time-stamp))))))
     (setq lui-time-stamp-last ts)))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]