summaryrefslogtreecommitdiff
path: root/lisp/net/rcirc.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/net/rcirc.el')
-rw-r--r--lisp/net/rcirc.el90
1 files changed, 46 insertions, 44 deletions
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index de524d9ef10..e8710becd0e 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -168,6 +168,14 @@ underneath each nick."
(string :tag "Prefix text"))
:group 'rcirc)
+(defcustom rcirc-url-max-length nil
+ "Maximum number of characters in displayed URLs.
+If nil, no maximum is applied."
+ :version "27.1"
+ :type '(choice (const :tag "No maximum" nil)
+ (integer :tag "Number of characters"))
+ :group 'rcirc)
+
(defvar rcirc-ignore-buffer-activity-flag nil
"If non-nil, ignore activity in this buffer.")
(make-variable-buffer-local 'rcirc-ignore-buffer-activity-flag)
@@ -186,9 +194,6 @@ underneath each nick."
(define-minor-mode rcirc-omit-mode
"Toggle the hiding of \"uninteresting\" lines.
-With a prefix argument ARG, enable Rcirc-Omit mode if ARG is
-positive, and disable it otherwise. If called from Lisp, enable
-the mode if ARG is omitted or nil.
Uninteresting lines are those whose responses are listed in
`rcirc-omit-responses'."
@@ -665,24 +670,33 @@ last ping."
(defun rcirc-handler-ctcp-KEEPALIVE (process _target _sender message)
(with-rcirc-process-buffer process
- (setq header-line-format (format "%f" (- (float-time)
- (string-to-number message))))))
+ (setq header-line-format
+ (format "%f" (float-time
+ (time-since (string-to-number message)))))))
(defvar rcirc-debug-buffer "*rcirc debug*")
(defvar rcirc-debug-flag nil
"If non-nil, write information to `rcirc-debug-buffer'.")
(defun rcirc-debug (process text)
"Add an entry to the debug log including PROCESS and TEXT.
-Debug text is written to `rcirc-debug-buffer' if `rcirc-debug-flag'
-is non-nil."
+Debug text is appended to `rcirc-debug-buffer' if `rcirc-debug-flag'
+is non-nil.
+
+For convenience, the read-only state of the debug buffer is ignored.
+When the point is at the end of the visible portion of the buffer, it
+is moved to after the text inserted. Otherwise the point is not moved."
(when rcirc-debug-flag
(with-current-buffer (get-buffer-create rcirc-debug-buffer)
- (goto-char (point-max))
- (insert (concat
- "["
- (format-time-string "%Y-%m-%dT%T ") (process-name process)
- "] "
- text)))))
+ (let ((old (point-marker)))
+ (set-marker-insertion-type old t)
+ (goto-char (point-max))
+ (let ((inhibit-read-only t))
+ (terpri (current-buffer) t)
+ (insert "["
+ (format-time-string "%FT%T ") (process-name process)
+ "] "
+ text))
+ (goto-char old)))))
(define-obsolete-variable-alias 'rcirc-sentinel-hooks
'rcirc-sentinel-functions "24.3")
@@ -718,8 +732,8 @@ When 0, do not auto-reconnect."
(< 0 rcirc-reconnect-delay))
(let ((now (current-time)))
(when (or (null rcirc-last-connect-time)
- (< rcirc-reconnect-delay
- (float-time (time-subtract now rcirc-last-connect-time))))
+ (time-less-p rcirc-reconnect-delay
+ (time-subtract now rcirc-last-connect-time)))
(setq rcirc-last-connect-time now)
(rcirc-cmd-reconnect nil))))
(run-hook-with-args 'rcirc-sentinel-functions process sentinel))))
@@ -1353,10 +1367,7 @@ Create the buffer if it doesn't exist."
"Keymap for multiline mode in rcirc.")
(define-minor-mode rcirc-multiline-minor-mode
- "Minor mode for editing multiple lines in rcirc.
-With a prefix argument ARG, enable the mode if ARG is positive,
-and disable it otherwise. If called from Lisp, enable the mode
-if ARG is omitted or nil."
+ "Minor mode for editing multiple lines in rcirc."
:init-value nil
:lighter " rcirc-mline"
:keymap rcirc-multiline-minor-mode-map
@@ -1867,10 +1878,7 @@ This function does not alter the INPUT string."
;;;###autoload
(define-minor-mode rcirc-track-minor-mode
- "Global minor mode for tracking activity in rcirc buffers.
-With a prefix argument ARG, enable the mode if ARG is positive,
-and disable it otherwise. If called from Lisp, enable the mode
-if ARG is omitted or nil."
+ "Global minor mode for tracking activity in rcirc buffers."
:init-value nil
:lighter ""
:keymap rcirc-track-minor-mode-map
@@ -2065,9 +2073,7 @@ activity. Only run if the buffer is not visible and
(defvar rcirc-visible-buffers nil)
(defun rcirc-window-configuration-change ()
(unless (minibuffer-window-active-p (minibuffer-window))
- ;; delay this until command has finished to make sure window is
- ;; actually visible before clearing activity
- (add-hook 'post-command-hook 'rcirc-window-configuration-change-1)))
+ (rcirc-window-configuration-change-1)))
(defun rcirc-window-configuration-change-1 ()
;; clear activity and overlay arrows
@@ -2091,9 +2097,7 @@ activity. Only run if the buffer is not visible and
rcirc-activity)))
;; update the mode-line string
(unless (equal old-activity rcirc-activity)
- (rcirc-update-activity-string)))
-
- (remove-hook 'post-command-hook 'rcirc-window-configuration-change-1))
+ (rcirc-update-activity-string))))
;;; buffer name abbreviation
@@ -2494,24 +2498,26 @@ If ARG is given, opens the URL in a new browser window."
(rcirc-record-activity (current-buffer) 'nick)))))
(defun rcirc-markup-urls (_sender _response)
- (while (and rcirc-url-regexp ;; nil means disable URL catching
+ (while (and rcirc-url-regexp ; nil means disable URL catching.
(re-search-forward rcirc-url-regexp nil t))
(let* ((start (match-beginning 0))
- (end (match-end 0))
- (url (match-string-no-properties 0))
- (link-text (buffer-substring-no-properties start end)))
+ (url (buffer-substring-no-properties start (point))))
+ (when rcirc-url-max-length
+ ;; Replace match with truncated URL.
+ (delete-region start (point))
+ (insert (url-truncate-url-for-viewing url rcirc-url-max-length)))
;; Add a button for the URL. Note that we use `make-text-button',
;; rather than `make-button', as text-buttons are much faster in
;; large buffers.
- (make-text-button start end
+ (make-text-button start (point)
'face 'rcirc-url
'follow-link t
'rcirc-url url
'action (lambda (button)
(browse-url (button-get button 'rcirc-url))))
- ;; record the url if it is not already the latest stored url
- (when (not (string= link-text (caar rcirc-urls)))
- (push (cons link-text start) rcirc-urls)))))
+ ;; Record the URL if it is not already the latest stored URL.
+ (unless (string= url (caar rcirc-urls))
+ (push (cons url start) rcirc-urls)))))
(defun rcirc-markup-keywords (sender response)
(when (and (string= response "PRIVMSG")
@@ -2796,11 +2802,8 @@ the only argument."
"RPL_WHOISIDLE"
(let* ((nick (nth 1 args))
(idle-secs (string-to-number (nth 2 args)))
- (idle-string
- (if (< idle-secs most-positive-fixnum)
- (format-seconds "%yy %dd %hh %mm %z%ss" idle-secs)
- "a very long time"))
- (signon-time (seconds-to-time (string-to-number (nth 3 args))))
+ (idle-string (format-seconds "%yy %dd %hh %mm %z%ss" idle-secs))
+ (signon-time (string-to-number (nth 3 args)))
(signon-string (format-time-string "%c" signon-time))
(message (format "%s idle for %s, signed on %s"
nick idle-string signon-string)))
@@ -2821,8 +2824,7 @@ Not in rfc1459.txt"
(with-current-buffer buffer
(let ((setter (nth 2 args))
(time (current-time-string
- (seconds-to-time
- (string-to-number (cl-cadddr args))))))
+ (string-to-number (cl-cadddr args)))))
(rcirc-print process sender "TOPIC" (cadr args)
(format "%s (%s on %s)" rcirc-topic setter time))))))