summaryrefslogtreecommitdiff
path: root/lisp/erc
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/erc')
-rw-r--r--lisp/erc/erc-backend.el91
-rw-r--r--lisp/erc/erc-button.el6
-rw-r--r--lisp/erc/erc-join.el10
-rw-r--r--lisp/erc/erc-log.el9
-rw-r--r--lisp/erc/erc-match.el2
-rw-r--r--lisp/erc/erc-ring.el3
-rw-r--r--lisp/erc/erc-track.el6
-rw-r--r--lisp/erc/erc.el26
8 files changed, 89 insertions, 64 deletions
diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el
index 1ef2fac1627..e07dc90fcdc 100644
--- a/lisp/erc/erc-backend.el
+++ b/lisp/erc/erc-backend.el
@@ -370,7 +370,7 @@ This overrides `erc-server-coding-system' depending on the
current target as returned by `erc-default-target'.
Example: If you know that the channel #linux-ru uses the coding-system
-`cyrillic-koi8', then add '(\"#linux-ru\" . cyrillic-koi8) to the
+`cyrillic-koi8', then add (\"#linux-ru\" . cyrillic-koi8) to the
alist."
:group 'erc-server
:type '(repeat (cons (string :tag "Target")
@@ -493,9 +493,19 @@ The current buffer is given by BUFFER."
4 erc-server-send-ping-interval
#'erc-server-send-ping
buffer))
- (setq erc-server-ping-timer-alist (cons (cons buffer
- erc-server-ping-handler)
- erc-server-ping-timer-alist)))))
+
+ ;; I check the timer alist for an existing timer. If one exists,
+ ;; I get rid of it
+ (let ((timer-tuple (assq buffer erc-server-ping-timer-alist)))
+ (if timer-tuple
+ ;; this buffer already has a timer. Cancel it and set the new one
+ (progn
+ (erc-cancel-timer (cdr timer-tuple))
+ (setf (cdr (assq buffer erc-server-ping-timer-alist)) erc-server-ping-handler))
+
+ ;; no existing timer for this buffer. Add new one
+ (add-to-list 'erc-server-ping-timer-alist
+ (cons buffer erc-server-ping-handler)))))))
(defun erc-server-process-alive (&optional buffer)
"Return non-nil when BUFFER has an `erc-server-process' open or running."
@@ -571,6 +581,11 @@ Make sure you are in an ERC buffer when running this."
(erc-open erc-session-server erc-session-port erc-server-current-nick
erc-session-user-full-name t erc-session-password)))))
+(defun erc-server-delayed-reconnect (event buffer)
+ (if (buffer-live-p buffer)
+ (with-current-buffer buffer
+ (erc-server-reconnect))))
+
(defun erc-server-filter-function (process string)
"The process filter for the ERC server."
(with-current-buffer (process-buffer process)
@@ -604,31 +619,29 @@ Make sure you are in an ERC buffer when running this."
(defsubst erc-server-reconnect-p (event)
"Return non-nil if ERC should attempt to reconnect automatically.
EVENT is the message received from the closed connection process."
- (and (not erc-server-quitting) ;; user issued an explicit quit, give up now
- (or erc-server-reconnecting ;; user issued explicit reconnect
- ;; otherwise go through the full spectrum of checks:
- (and erc-server-auto-reconnect
- (not erc-server-banned)
- ;; make sure we don't infinitely try to reconnect, unless the
- ;; user wants that
- (or (eq erc-server-reconnect-attempts t)
- (and (integerp erc-server-reconnect-attempts)
- (< erc-server-reconnect-count
- erc-server-reconnect-attempts)))
- (or erc-server-timed-out
- (not (string-match "^deleted" event)))
- ;; open-network-stream-nowait error for connection refused
- (not (string-match "^failed with code 111" event))))))
+ (or erc-server-reconnecting
+ (and erc-server-auto-reconnect
+ (not erc-server-banned)
+ (not erc-server-error-occurred)
+ ;; make sure we don't infinitely try to reconnect, unless the
+ ;; user wants that
+ (or (eq erc-server-reconnect-attempts t)
+ (and (integerp erc-server-reconnect-attempts)
+ (< erc-server-reconnect-count
+ erc-server-reconnect-attempts)))
+ (or erc-server-timed-out
+ (not (string-match "^deleted" event)))
+ ;; open-network-stream-nowait error for connection refused
+ (if (string-match "^failed with code 111" event) 'nonblocking t))))
(defun erc-process-sentinel-2 (event buffer)
"Called when `erc-process-sentinel-1' has detected an unexpected disconnect."
(if (not (buffer-live-p buffer))
(erc-update-mode-line)
(with-current-buffer buffer
- (let ((reconnect-p (erc-server-reconnect-p event)))
- (erc-display-message nil 'error (current-buffer)
- (if reconnect-p 'disconnected
- 'disconnected-noreconnect))
+ (let ((reconnect-p (erc-server-reconnect-p event)) message delay)
+ (setq message (if reconnect-p 'disconnected 'disconnected-noreconnect))
+ (erc-display-message nil 'error (current-buffer) message)
(if (not reconnect-p)
;; terminate, do not reconnect
(progn
@@ -640,21 +653,16 @@ EVENT is the message received from the closed connection process."
;; reconnect
(condition-case err
(progn
- (setq erc-server-reconnecting nil)
- (setq erc-server-reconnect-count (1+ erc-server-reconnect-count))
- (erc-server-reconnect))
- (error (when (buffer-live-p buffer)
- (set-buffer buffer)
- (unless (integerp erc-server-reconnect-attempts)
- (message "%s ... %s"
- "Reconnecting until we succeed"
- "kill the ERC server buffer to stop"))
- (if (numberp erc-server-reconnect-timeout)
- (run-at-time erc-server-reconnect-timeout nil
- #'erc-process-sentinel-2
- event buffer)
- (error (concat "`erc-server-reconnect-timeout'"
- " must be a number")))))))))))
+ (setq erc-server-reconnecting nil
+ erc-server-reconnect-count (1+ erc-server-reconnect-count))
+ (setq delay erc-server-reconnect-timeout)
+ (run-at-time delay nil
+ #'erc-server-delayed-reconnect event buffer))
+ (error (unless (integerp erc-server-reconnect-attempts)
+ (message "%s ... %s"
+ "Reconnecting until we succeed"
+ "kill the ERC server buffer to stop"))
+ (erc-server-delayed-reconnect event buffer))))))))
(defun erc-process-sentinel-1 (event buffer)
"Called when `erc-process-sentinel' has decided that we're disconnecting.
@@ -693,6 +701,9 @@ Conditionally try to reconnect and take appropriate action."
(setq erc-server-ping-handler nil)))
(run-hook-with-args 'erc-disconnected-hook
(erc-current-nick) (system-name) "")
+ (dolist (buf (erc-buffer-filter (lambda () (boundp 'erc-channel-users)) cproc))
+ (with-current-buffer buf
+ (setq erc-channel-users (make-hash-table :test 'equal))))
;; Remove the prompt
(goto-char (or (marker-position erc-input-marker) (point-max)))
(forward-line 0)
@@ -795,7 +806,9 @@ protection algorithm."
(defun erc-server-send-ping (buf)
"Send a ping to the IRC server buffer in BUF.
Additionally, detect whether the IRC process has hung."
- (if (buffer-live-p buf)
+ (if (and (buffer-live-p buf)
+ (with-current-buffer buf
+ erc-server-last-received-time))
(with-current-buffer buf
(if (and erc-server-send-ping-timeout
(>
diff --git a/lisp/erc/erc-button.el b/lisp/erc/erc-button.el
index 0e4c70944bb..d6f4b12ebbf 100644
--- a/lisp/erc/erc-button.el
+++ b/lisp/erc/erc-button.el
@@ -165,11 +165,11 @@ REGEXP is the string matching text around the button or a symbol
entries in lists or alists are considered to be nicks or other
complete words. Therefore they are enclosed in \\< and \\>
while searching. REGEXP can also be the quoted symbol
- 'nicknames, which matches the nickname of any user on the
+ \\='nicknames, which matches the nickname of any user on the
current server.
BUTTON is the number of the regexp grouping actually matching the
- button, This is ignored if REGEXP is 'nicknames.
+ button, This is ignored if REGEXP is \\='nicknames.
FORM is a lisp expression which must eval to true for the button to
be added,
@@ -180,7 +180,7 @@ CALLBACK is the function to call when the user push this button.
PAR is a number of a regexp grouping whose text will be passed to
CALLBACK. There can be several PAR arguments. If REGEXP is
- 'nicknames, these are ignored, and CALLBACK will be called with
+ \\='nicknames, these are ignored, and CALLBACK will be called with
the nickname matched as the argument."
:group 'erc-button
:version "24.1" ; remove finger (bug#4443)
diff --git a/lisp/erc/erc-join.el b/lisp/erc/erc-join.el
index 4c99898bc41..c1ce14ab016 100644
--- a/lisp/erc/erc-join.el
+++ b/lisp/erc/erc-join.el
@@ -156,7 +156,13 @@ This function is run from `erc-nickserv-identified-hook'."
(dolist (l erc-autojoin-channels-alist)
(when (string-match (car l) server)
(dolist (chan (cdr l))
- (erc-server-join-channel server chan)))))
+ (let ((buffer (erc-get-buffer chan)))
+ ;; Only auto-join the channels that we aren't already in
+ ;; using a different nick.
+ (when (or (not buffer)
+ (not (with-current-buffer buffer
+ (erc-server-process-alive))))
+ (erc-server-join-channel server chan)))))))
;; Return nil to avoid stomping on any other hook funcs.
nil)
@@ -170,7 +176,7 @@ This function is run from `erc-nickserv-identified-hook'."
(password (if (functionp secret)
(funcall secret)
secret)))
- (erc-server-send (concat "join " channel
+ (erc-server-send (concat "JOIN " channel
(if password
(concat " " password)
"")))))
diff --git a/lisp/erc/erc-log.el b/lisp/erc/erc-log.el
index f022284450a..4ac13aab070 100644
--- a/lisp/erc/erc-log.el
+++ b/lisp/erc/erc-log.el
@@ -270,9 +270,12 @@ The current buffer is given by BUFFER."
(setq buffer-file-name nil)
(erc-set-write-file-functions '(erc-save-buffer-in-logs))
(when erc-log-insert-log-on-open
- (ignore-errors (insert-file-contents (erc-current-logfile))
- (move-marker erc-last-saved-position
- (1- (point-max))))))))
+ (ignore-errors
+ (save-excursion
+ (goto-char (point-min))
+ (insert-file-contents (erc-current-logfile)))
+ (move-marker erc-last-saved-position
+ (1- (point-max))))))))
(defun erc-log-disable-logging (buffer)
"Disable logging in BUFFER."
diff --git a/lisp/erc/erc-match.el b/lisp/erc/erc-match.el
index 0622b18ca7f..ec3266fa1bd 100644
--- a/lisp/erc/erc-match.el
+++ b/lisp/erc/erc-match.el
@@ -191,7 +191,7 @@ use for the logged message."
"Flag specifying when matched message logging should happen.
When nil, don't log any matched messages.
When t, log messages.
-When 'away, log messages only when away."
+When `away', log messages only when away."
:group 'erc-match
:type '(choice (const nil)
(const away)
diff --git a/lisp/erc/erc-ring.el b/lisp/erc/erc-ring.el
index de988cc8275..77528eae88c 100644
--- a/lisp/erc/erc-ring.el
+++ b/lisp/erc/erc-ring.el
@@ -58,7 +58,7 @@ be recalled using M-p and M-n."
(defvar erc-input-ring-index nil
"Position in the input ring for erc.
-If nil, the input line is blank and the user is conceptually 'after'
+If nil, the input line is blank and the user is conceptually after
the most recently added item in the ring. If an integer, the input
line is non-blank and displays the item from the ring indexed by this
variable.")
@@ -148,4 +148,3 @@ containing a password."
;; Local Variables:
;; indent-tabs-mode: nil
;; End:
-
diff --git a/lisp/erc/erc-track.el b/lisp/erc/erc-track.el
index 2ebc1f22c09..5af1663378f 100644
--- a/lisp/erc/erc-track.el
+++ b/lisp/erc/erc-track.el
@@ -101,7 +101,7 @@ disconnected from `erc-modified-channels-alist'."
(defcustom erc-track-exclude-types '("NICK" "333" "353")
"List of message types to be ignored.
-This list could look like '(\"JOIN\" \"PART\").
+This list could look like (\"JOIN\" \"PART\").
By default, exclude changes of nicknames (NICK), display of who
set the channel topic (333), and listing of users on the current
@@ -210,7 +210,7 @@ If you would like to ignore changes in certain channels where there
are no faces corresponding to your `erc-track-faces-priority-list', set
this variable. You can set a list of channel name strings, so those
will be ignored while all other channels will be tracked as normal.
-Other options are 'all, to apply this to all channels or nil, to disable
+Other options are `all', to apply this to all channels or nil, to disable
this feature.
Note: If you have a lot of faces listed in `erc-track-faces-priority-list',
@@ -326,7 +326,7 @@ when there are no more active channels."
leastactive - find buffer with least unseen messages
mostactive - find buffer with most unseen messages.
-If set to 'importance, the importance is determined by position
+If set to `importance', the importance is determined by position
in `erc-track-faces-priority-list', where first is most
important."
:group 'erc-track
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index cd8e427f72b..49ba4ccf8cb 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -629,7 +629,7 @@ See also: `erc-get-channel-user-list'."
(defvar erc-channel-modes nil
"List of strings representing channel modes.
-E.g. '(\"i\" \"m\" \"s\" \"b Quake!*@*\")
+E.g. (\"i\" \"m\" \"s\" \"b Quake!*@*\")
\(not sure the ban list will be here, but why not)")
(make-variable-buffer-local 'erc-channel-modes)
@@ -1967,7 +1967,9 @@ Returns the buffer for the given server or channel."
(erc-update-modules)
(set-buffer buffer)
(setq old-point (point))
- (erc-mode)
+ (let ((old-recon-count erc-server-reconnect-count))
+ (erc-mode)
+ (setq erc-server-reconnect-count old-recon-count))
(setq erc-server-announced-name server-announced-name)
(setq erc-server-connected connected-p)
;; connection parameters
@@ -2027,7 +2029,8 @@ Returns the buffer for the given server or channel."
(auth-source-search :host server
:max 1
:user nick
- :port port
+ ;; secrets.el wouldn’t accept a number
+ :port (if (numberp port) (number-to-string port) port)
:require '(:secret)))
:secret)))
(if (functionp secret)
@@ -2208,6 +2211,7 @@ Arguments are the same as for `erc'."
The process will be given the name NAME, its target buffer will be
BUFFER. HOST and PORT specify the connection target."
(open-network-stream name buffer host port
+ :nowait t
:type 'tls))
;;; Displaying error messages
@@ -2421,9 +2425,9 @@ If STRING is nil, the function does nothing."
"Display STRING in the ERC BUFFER.
All screen output must be done through this function. If BUFFER is nil
or omitted, the default ERC buffer for the `erc-session-server' is used.
-The BUFFER can be an actual buffer, a list of buffers, 'all or 'active.
-If BUFFER = 'all, the string is displayed in all the ERC buffers for the
-current session. 'active means the current active buffer
+The BUFFER can be an actual buffer, a list of buffers, `all' or `active'.
+If BUFFER = `all', the string is displayed in all the ERC buffers for the
+current session. `active' means the current active buffer
\(`erc-active-buffer'). If the buffer can't be resolved, the current
buffer is used. `erc-display-line-1' is used to display STRING.
@@ -3251,7 +3255,7 @@ LINE has the format \"USER ACTION\"."
(put 'erc-cmd-ME 'do-not-parse-args t)
(defun erc-cmd-ME\'S (line)
- "Do a /ME command, but add the string \" 's\" to the beginning."
+ "Do a /ME command, but add the string \" \\='s\" to the beginning."
(erc-cmd-ME (concat " 's" line)))
(put 'erc-cmd-ME\'S 'do-not-parse-args t)
@@ -5032,7 +5036,7 @@ See also `erc-remove-current-channel-member'."
(defun erc-update-channel-topic (channel topic &optional modify)
"Find a buffer for CHANNEL and set the TOPIC for it.
-If optional MODIFY is 'append or 'prepend, then append or prepend the
+If optional MODIFY is `append' or `prepend', then append or prepend the
TOPIC string to the current topic."
(erc-with-buffer (channel)
(cond ((eq modify 'append)
@@ -5195,7 +5199,7 @@ person who changed the modes."
(t (setq erc-channel-user-limit nil))))))
(defun erc-update-channel-key (channel onoff key)
- "Update CHANNEL's key to KEY if ONOFF is 'on or to nil if it's 'off."
+ "Update CHANNEL's key to KEY if ONOFF is `on' or to nil if it's `off'."
(erc-with-buffer
(channel)
(cond ((eq onoff 'on) (setq erc-channel-key key))
@@ -6709,7 +6713,7 @@ or `erc-kill-buffer-hook' if any other buffer."
(cond
((eq (erc-server-buffer) (current-buffer))
(run-hooks 'erc-kill-server-hook))
- ((erc-channel-p (erc-default-target))
+ ((erc-channel-p (or (erc-default-target) (buffer-name)))
(run-hooks 'erc-kill-channel-hook))
(t
(run-hooks 'erc-kill-buffer-hook)))))
@@ -6737,7 +6741,7 @@ This function should be on `erc-kill-channel-hook'."
(text-property-not-all (point-min) (point-max) 'erc-parsed nil))
(defun erc-restore-text-properties ()
- "Restore the property 'erc-parsed for the region."
+ "Restore the property `erc-parsed' for the region."
(let ((parsed-posn (erc-find-parsed-property)))
(put-text-property
(point-min) (point-max)