X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/e6fd457e010c2ec034a331335530d817852cc11c..f2536958ec711b50a0cf8714defb921193ea8ae4:/lisp/erc/erc-stamp.el diff --git a/lisp/erc/erc-stamp.el b/lisp/erc/erc-stamp.el index 4d55e21da7..a4c91ca9fb 100644 --- a/lisp/erc/erc-stamp.el +++ b/lisp/erc/erc-stamp.el @@ -1,8 +1,9 @@ ;;; 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 +;; Maintainer: emacs-devel@gnu.org ;; Keywords: comm, processes, timestamp ;; URL: http://www.emacswiki.org/cgi-bin/wiki.pl?ErcStamp @@ -43,7 +44,7 @@ group provides settings related to the format and display of timestamp information in `erc-mode' buffer. For timestamping to be activated, you just need to load `erc-stamp' -in your .emacs file or interactively using `load-library'." +in your init file or interactively using `load-library'." :group 'erc) (defcustom erc-timestamp-format "[%H:%M]" @@ -113,7 +114,7 @@ If `erc-timestamp-format' is set, this will not be used." (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." @@ -146,25 +147,26 @@ the minibuffer." :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 (:bold t :foreground "green"))) +(defface erc-timestamp-face '((t :weight bold :foreground "green")) "ERC timestamp face." :group 'erc-faces) ;;;###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. @@ -186,7 +188,8 @@ or `erc-send-modify-hook'." (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.") @@ -287,8 +290,7 @@ be printed just before the window-width." (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) @@ -301,8 +303,7 @@ be printed just before the window-width." (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 @@ -317,9 +318,9 @@ be printed just before the window-width." (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 @@ -352,8 +353,9 @@ Return the empty string if FORMAT is nil." '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) "")) @@ -363,15 +365,13 @@ Return the empty string if FORMAT is nil." ;; 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." @@ -402,12 +402,11 @@ enabled when the message was inserted." (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))))))