;;; erc-stamp.el --- Timestamping for ERC messages
-;; Copyright (C) 2002-2004, 2006-2012 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2004, 2006-2016 Free Software Foundation, Inc.
;; Author: Mario Lang <mlang@delysid.org>
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
;; Keywords: comm, processes, timestamp
;; URL: http://www.emacswiki.org/cgi-bin/wiki.pl?ErcStamp
(string)))
(defcustom erc-insert-away-timestamp-function
- 'erc-insert-timestamp-left-and-right
+ #'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 'string)
-(defcustom erc-timestamp-intangible t
+(defcustom erc-timestamp-intangible nil
"Whether the timestamps should be intangible, i.e. prevent the point
from entering them and instead jump over them."
:group 'erc-stamp
+ :version "24.5"
:type 'boolean)
(defface erc-timestamp-face '((t :weight bold :foreground "green"))
;;;###autoload (autoload 'erc-timestamp-mode "erc-stamp" nil t)
(define-erc-module stamp timestamp
"This mode timestamps messages in the channel buffers."
- ((add-hook 'erc-mode-hook 'erc-munge-invisibility-spec)
- (add-hook 'erc-insert-modify-hook 'erc-add-timestamp t)
- (add-hook 'erc-send-modify-hook 'erc-add-timestamp t))
- ((remove-hook 'erc-mode-hook 'erc-munge-invisibility-spec)
- (remove-hook 'erc-insert-modify-hook 'erc-add-timestamp)
- (remove-hook 'erc-send-modify-hook 'erc-add-timestamp)))
+ ((add-hook 'erc-mode-hook #'erc-munge-invisibility-spec)
+ (add-hook 'erc-insert-modify-hook #'erc-add-timestamp t)
+ (add-hook 'erc-send-modify-hook #'erc-add-timestamp t))
+ ((remove-hook 'erc-mode-hook #'erc-munge-invisibility-spec)
+ (remove-hook 'erc-insert-modify-hook #'erc-add-timestamp)
+ (remove-hook 'erc-send-modify-hook #'erc-add-timestamp)))
(defun erc-add-timestamp ()
"Add timestamp and text-properties to message.
(add-text-properties (point-min) (point-max)
(list 'timestamp ct))
(add-text-properties (point-min) (point-max)
- (list 'point-entered 'erc-echo-timestamp)))))
+ (list 'cursor-sensor-functions
+ (list #'erc-echo-timestamp))))))
(defvar erc-timestamp-last-inserted nil
"Last timestamp inserted into the buffer.")
(setq erc-timestamp-last-inserted string)
(goto-char (point-max))
(forward-char -1);; before the last newline
- (let* ((current-window (get-buffer-window (current-buffer)))
- (str-width (string-width string))
+ (let* ((str-width (string-width string))
(pos (cond
(erc-timestamp-right-column erc-timestamp-right-column)
((and (boundp 'erc-fill-mode)
(t
(- (window-width) str-width 1))))
(from (point))
- (col (current-column))
- indent)
+ (col (current-column)))
;; The following is a kludge used to calculate whether to move
;; to the next line before inserting a stamp. It allows for
;; some margin of error if what is displayed on the line differs
(erc-put-text-property from (point) 'field 'erc-timestamp)
(erc-put-text-property from (point) 'rear-nonsticky t)
(when erc-timestamp-intangible
- (erc-put-text-property from (1+ (point)) 'intangible t)))))
+ (erc-put-text-property from (1+ (point)) 'cursor-intangible t)))))
-(defun erc-insert-timestamp-left-and-right (string)
+(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
Return the empty string if FORMAT is nil."
(if format
(let ((ts (format-time-string format time)))
- (erc-put-text-property 0 (length ts) 'face 'erc-timestamp-face ts)
+ (erc-put-text-property 0 (length ts)
+ 'font-lock-face 'erc-timestamp-face ts)
(erc-put-text-property 0 (length ts) 'invisible 'timestamp ts)
(erc-put-text-property 0 (length ts)
'isearch-open-invisible 'timestamp ts)
;; N.B. Later use categories instead of this harmless, but
;; inelegant, hack. -- BPT
- (when erc-timestamp-intangible
- (erc-put-text-property 0 (length ts) 'intangible t ts))
+ (and erc-timestamp-intangible
+ (not erc-hide-timestamps) ; bug#11706
+ (erc-put-text-property 0 (length ts) 'cursor-intangible t ts))
ts)
""))
;; please modify this function and move it to a more appropriate
;; location.
(defun erc-munge-invisibility-spec ()
+ (and erc-timestamp-intangible (not (bound-and-true-p cursor-intangible-mode))
+ (cursor-intangible-mode 1))
+ (and erc-echo-timestamps (not (bound-and-true-p cursor-sensor-mode))
+ (cursor-sensor-mode 1))
(if erc-hide-timestamps
- (setq buffer-invisibility-spec
- (if (listp buffer-invisibility-spec)
- (cons 'timestamp buffer-invisibility-spec)
- (list 't 'timestamp)))
- (setq buffer-invisibility-spec
- (if (listp buffer-invisibility-spec)
- (remove 'timestamp buffer-invisibility-spec)
- (list 't)))))
+ (add-to-invisibility-spec 'timestamp)
+ (remove-from-invisibility-spec 'timestamp)))
(defun erc-hide-timestamps ()
"Hide timestamp information from display."
(erc-munge-invisibility-spec)))
(erc-buffer-list)))
-(defun erc-echo-timestamp (before now)
- "Print timestamp text-property of an IRC message.
-Argument BEFORE is where point was before it got moved and
-NOW is position of point currently."
- (when erc-echo-timestamps
- (let ((stamp (get-text-property now 'timestamp)))
+(defun erc-echo-timestamp (window _before dir)
+ "Print timestamp text-property of an IRC message."
+ (when (and erc-echo-timestamps (eq 'entered dir))
+ (let* ((now (window-point window))
+ (stamp (get-text-property now 'timestamp)))
(when stamp
(message "%s" (format-time-string erc-echo-timestamp-format
stamp))))))