From: Stefan Kangas Date: Sun, 31 Jan 2021 02:19:41 +0000 (+0100) Subject: Prefer defvar-local in erc X-Git-Tag: emacs-28.0.90~4016 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=fc66ec33226aeed0b745356363ed952c8ff1f7fd;p=emacs.git Prefer defvar-local in erc * lisp/erc/erc-backend.el (erc-server-current-nick) (erc-server-process, erc-session-server, erc-session-connector) (erc-session-port, erc-server-announced-name) (erc-server-version, erc-server-parameters) (erc-server-connected, erc-server-reconnect-count) (erc-server-quitting, erc-server-reconnecting) (erc-server-timed-out, erc-server-banned) (erc-server-error-occurred, erc-server-lines-sent) (erc-server-last-peers, erc-server-last-sent-time) (erc-server-last-ping-time, erc-server-last-received-time) (erc-server-lag, erc-server-filter-data, erc-server-duplicates) (erc-server-processing-p, erc-server-flood-last-message) (erc-server-flood-queue, erc-server-flood-timer) (erc-server-ping-handler): * lisp/erc/erc-capab.el (erc-capab-identify-activated) (erc-capab-identify-sent): * lisp/erc/erc-dcc.el (erc-dcc-byte-count, erc-dcc-entry-data) (erc-dcc-file-name): * lisp/erc/erc-ezbounce.el (erc-ezb-session-list): * lisp/erc/erc-join.el (erc--autojoin-timer): * lisp/erc/erc-netsplit.el (erc-netsplit-list): * lisp/erc/erc-networks.el (erc-network): * lisp/erc/erc-notify.el (erc-last-ison, erc-last-ison-time): * lisp/erc/erc-ring.el (erc-input-ring, erc-input-ring-index): * lisp/erc/erc-stamp.el (erc-timestamp-last-inserted) (erc-timestamp-last-inserted-left) (erc-timestamp-last-inserted-right): * lisp/erc/erc.el (erc-session-password, erc-channel-users) (erc-server-users, erc-channel-topic, erc-channel-modes) (erc-insert-marker, erc-input-marker, erc-last-saved-position) (erc-dbuf, erc-active-buffer, erc-default-recipients) (erc-session-user-full-name, erc-channel-user-limit) (erc-channel-key, erc-invitation, erc-channel-list) (erc-bad-nick, erc-logged-in, erc-default-nicks) (erc-nick-change-attempt-count, erc-send-input-line-function) (erc-channel-new-member-names, erc-channel-banlist) (erc-current-message-catalog): Prefer defvar-local. --- diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index 487dc7692ef..4cabd42f532 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -120,38 +120,31 @@ ;;; User data -(defvar erc-server-current-nick nil +(defvar-local erc-server-current-nick nil "Nickname on the current server. Use `erc-current-nick' to access this.") -(make-variable-buffer-local 'erc-server-current-nick) ;;; Server attributes -(defvar erc-server-process nil +(defvar-local erc-server-process nil "The process object of the corresponding server connection.") -(make-variable-buffer-local 'erc-server-process) -(defvar erc-session-server nil +(defvar-local erc-session-server nil "The server name used to connect to for this session.") -(make-variable-buffer-local 'erc-session-server) -(defvar erc-session-connector nil +(defvar-local erc-session-connector nil "The function used to connect to this session (nil for the default).") -(make-variable-buffer-local 'erc-session-connector) -(defvar erc-session-port nil +(defvar-local erc-session-port nil "The port used to connect to.") -(make-variable-buffer-local 'erc-session-port) -(defvar erc-server-announced-name nil +(defvar-local erc-server-announced-name nil "The name the server announced to use.") -(make-variable-buffer-local 'erc-server-announced-name) -(defvar erc-server-version nil +(defvar-local erc-server-version nil "The name and version of the server's ircd.") -(make-variable-buffer-local 'erc-server-version) -(defvar erc-server-parameters nil +(defvar-local erc-server-parameters nil "Alist listing the supported server parameters. This is only set if the server sends 005 messages saying what is @@ -177,86 +170,70 @@ RFC2812 - server supports RFC 2812 features SILENCE=10 - supports the SILENCE command, maximum allowed number of entries TOPICLEN=160 - maximum allowed topic length WALLCHOPS - supports sending messages to all operators in a channel") -(make-variable-buffer-local 'erc-server-parameters) ;;; Server and connection state (defvar erc-server-ping-timer-alist nil "Mapping of server buffers to their specific ping timer.") -(defvar erc-server-connected nil +(defvar-local erc-server-connected nil "Non-nil if the current buffer has been used by ERC to establish an IRC connection. If you wish to determine whether an IRC connection is currently active, use the `erc-server-process-alive' function instead.") -(make-variable-buffer-local 'erc-server-connected) -(defvar erc-server-reconnect-count 0 +(defvar-local erc-server-reconnect-count 0 "Number of times we have failed to reconnect to the current server.") -(make-variable-buffer-local 'erc-server-reconnect-count) -(defvar erc-server-quitting nil +(defvar-local erc-server-quitting nil "Non-nil if the user requests a quit.") -(make-variable-buffer-local 'erc-server-quitting) -(defvar erc-server-reconnecting nil +(defvar-local erc-server-reconnecting nil "Non-nil if the user requests an explicit reconnect, and the current IRC process is still alive.") -(make-variable-buffer-local 'erc-server-reconnecting) -(defvar erc-server-timed-out nil +(defvar-local erc-server-timed-out nil "Non-nil if the IRC server failed to respond to a ping.") -(make-variable-buffer-local 'erc-server-timed-out) -(defvar erc-server-banned nil +(defvar-local erc-server-banned nil "Non-nil if the user is denied access because of a server ban.") -(make-variable-buffer-local 'erc-server-banned) -(defvar erc-server-error-occurred nil +(defvar-local erc-server-error-occurred nil "Non-nil if the user triggers some server error.") -(make-variable-buffer-local 'erc-server-error-occurred) -(defvar erc-server-lines-sent nil +(defvar-local erc-server-lines-sent nil "Line counter.") -(make-variable-buffer-local 'erc-server-lines-sent) -(defvar erc-server-last-peers '(nil . nil) +(defvar-local erc-server-last-peers '(nil . nil) "Last peers used, both sender and receiver. Those are used for /MSG destination shortcuts.") -(make-variable-buffer-local 'erc-server-last-peers) -(defvar erc-server-last-sent-time nil +(defvar-local erc-server-last-sent-time nil "Time the message was sent. This is useful for flood protection.") -(make-variable-buffer-local 'erc-server-last-sent-time) -(defvar erc-server-last-ping-time nil +(defvar-local erc-server-last-ping-time nil "Time the last ping was sent. This is useful for flood protection.") -(make-variable-buffer-local 'erc-server-last-ping-time) -(defvar erc-server-last-received-time nil +(defvar-local erc-server-last-received-time nil "Time the last message was received from the server. This is useful for detecting hung connections.") -(make-variable-buffer-local 'erc-server-last-received-time) -(defvar erc-server-lag nil +(defvar-local erc-server-lag nil "Calculated server lag time in seconds. This variable is only set in a server buffer.") -(make-variable-buffer-local 'erc-server-lag) -(defvar erc-server-filter-data nil +(defvar-local erc-server-filter-data nil "The data that arrived from the server but has not been processed yet.") -(make-variable-buffer-local 'erc-server-filter-data) -(defvar erc-server-duplicates (make-hash-table :test 'equal) +(defvar-local erc-server-duplicates (make-hash-table :test 'equal) "Internal variable used to track duplicate messages.") -(make-variable-buffer-local 'erc-server-duplicates) ;; From Circe -(defvar erc-server-processing-p nil +(defvar-local erc-server-processing-p nil "Non-nil when we're currently processing a message. When ERC receives a private message, it sets up a new buffer for @@ -267,23 +244,19 @@ network exceptions. So, if someone sends you two messages quickly after each other, ispell is started for the first, but might take long enough for the second message to be processed first.") -(make-variable-buffer-local 'erc-server-processing-p) -(defvar erc-server-flood-last-message 0 +(defvar-local erc-server-flood-last-message 0 "When we sent the last message. See `erc-server-flood-margin' for an explanation of the flood protection algorithm.") -(make-variable-buffer-local 'erc-server-flood-last-message) -(defvar erc-server-flood-queue nil +(defvar-local erc-server-flood-queue nil "The queue of messages waiting to be sent to the server. See `erc-server-flood-margin' for an explanation of the flood protection algorithm.") -(make-variable-buffer-local 'erc-server-flood-queue) -(defvar erc-server-flood-timer nil +(defvar-local erc-server-flood-timer nil "The timer to resume sending.") -(make-variable-buffer-local 'erc-server-flood-timer) ;;; IRC protocol and misc options @@ -453,9 +426,8 @@ If this is set to nil, never try to reconnect." :type '(choice (const :tag "Disabled" nil) (integer :tag "Seconds"))) -(defvar erc-server-ping-handler nil +(defvar-local erc-server-ping-handler nil "This variable holds the periodic ping timer.") -(make-variable-buffer-local 'erc-server-ping-handler) ;;;; Helper functions diff --git a/lisp/erc/erc-capab.el b/lisp/erc/erc-capab.el index 06d4fbd9f6a..4e4d012545a 100644 --- a/lisp/erc/erc-capab.el +++ b/lisp/erc/erc-capab.el @@ -113,13 +113,11 @@ character not found in IRC nicknames to avoid confusion." ;;; Variables: -(defvar erc-capab-identify-activated nil +(defvar-local erc-capab-identify-activated nil "CAPAB IDENTIFY-MSG has been activated.") -(make-variable-buffer-local 'erc-capab-identify-activated) -(defvar erc-capab-identify-sent nil +(defvar-local erc-capab-identify-sent nil "CAPAB IDENTIFY-MSG and IDENTIFY-CTCP messages have been sent.") -(make-variable-buffer-local 'erc-capab-identify-sent) ;;; Functions: diff --git a/lisp/erc/erc-dcc.el b/lisp/erc/erc-dcc.el index 590785e91c2..9dedd3cda86 100644 --- a/lisp/erc/erc-dcc.el +++ b/lisp/erc/erc-dcc.el @@ -538,8 +538,7 @@ PROC is the server process." nil '(notice error) 'active 'dcc-get-notfound ?n nick ?f filename)))) -(defvar erc-dcc-byte-count nil) -(make-variable-buffer-local 'erc-dcc-byte-count) +(defvar-local erc-dcc-byte-count nil) (defun erc-dcc-do-LIST-command (proc) "This is the handler for the /dcc list command. @@ -751,9 +750,8 @@ the matching regexp, or nil if none found." 'dcc-malformed ?n nick ?u login ?h host ?q query))))) -(defvar erc-dcc-entry-data nil +(defvar-local erc-dcc-entry-data nil "Holds the `erc-dcc-list' entry for this DCC connection.") -(make-variable-buffer-local 'erc-dcc-entry-data) ;;; SEND handling @@ -905,8 +903,7 @@ other client." :group 'erc-dcc :type 'integer) -(defvar erc-dcc-file-name nil) -(make-variable-buffer-local 'erc-dcc-file-name) +(defvar-local erc-dcc-file-name nil) (defun erc-dcc-get-file (entry file parent-proc) "Set up a transfer from the remote client to the local over a TCP connection. diff --git a/lisp/erc/erc-ezbounce.el b/lisp/erc/erc-ezbounce.el index 62238dd4344..8378ff53742 100644 --- a/lisp/erc/erc-ezbounce.el +++ b/lisp/erc/erc-ezbounce.el @@ -61,9 +61,8 @@ The alist's format is as follows: "Alist of actions to take on NOTICEs from EZBounce.") -(defvar erc-ezb-session-list '() +(defvar-local erc-ezb-session-list '() "List of detached EZBounce sessions.") -(make-variable-buffer-local 'erc-ezb-session-list) (defvar erc-ezb-inside-session-listing nil "Indicate whether current notices are expected to be EZB session listings.") diff --git a/lisp/erc/erc-join.el b/lisp/erc/erc-join.el index 947b2949690..e6e50707830 100644 --- a/lisp/erc/erc-join.el +++ b/lisp/erc/erc-join.el @@ -105,8 +105,7 @@ servers, presumably in the same domain." :group 'erc-autojoin :type 'boolean) -(defvar erc--autojoin-timer nil) -(make-variable-buffer-local 'erc--autojoin-timer) +(defvar-local erc--autojoin-timer nil) (defun erc-autojoin-channels-delayed (server nick buffer) "Attempt to autojoin channels. diff --git a/lisp/erc/erc-netsplit.el b/lisp/erc/erc-netsplit.el index 9fd3cfe1cc4..37fc4cf16c1 100644 --- a/lisp/erc/erc-netsplit.el +++ b/lisp/erc/erc-netsplit.el @@ -82,12 +82,11 @@ Args: PROC is the process the netjoin originated from and :group 'erc-hooks :type 'hook) -(defvar erc-netsplit-list nil +(defvar-local erc-netsplit-list nil "This is a list of the form \((\"a.b.c.d e.f.g\" TIMESTAMP FIRST-JOIN \"nick1\" ... \"nickn\") ...) where FIRST-JOIN is t or nil, depending on whether or not the first join from that split has been detected or not.") -(make-variable-buffer-local 'erc-netsplit-list) (defun erc-netsplit-install-message-catalogs () (erc-define-catalog diff --git a/lisp/erc/erc-networks.el b/lisp/erc/erc-networks.el index 9c2bb9dfee3..9926255e3aa 100644 --- a/lisp/erc/erc-networks.el +++ b/lisp/erc/erc-networks.el @@ -722,9 +722,8 @@ MATCHER is used to find a corresponding network to a server while (regexp) (const :tag "Network has no common server ending" nil))))) -(defvar erc-network nil +(defvar-local erc-network nil "The name of the network you are connected to (a symbol).") -(make-variable-buffer-local 'erc-network) ;; Functions: diff --git a/lisp/erc/erc-notify.el b/lisp/erc/erc-notify.el index 098049edc68..e133e05a7d3 100644 --- a/lisp/erc/erc-notify.el +++ b/lisp/erc/erc-notify.el @@ -75,13 +75,11 @@ strings." ;;;; Internal variables -(defvar erc-last-ison nil +(defvar-local erc-last-ison nil "Last ISON information received through `erc-notify-timer'.") -(make-variable-buffer-local 'erc-last-ison) -(defvar erc-last-ison-time 0 +(defvar-local erc-last-ison-time 0 "Last time ISON was sent to the server in `erc-notify-timer'.") -(make-variable-buffer-local 'erc-last-ison-time) ;;;; Setup diff --git a/lisp/erc/erc-ring.el b/lisp/erc/erc-ring.el index 3813eafe004..71a9f8ef3da 100644 --- a/lisp/erc/erc-ring.el +++ b/lisp/erc/erc-ring.el @@ -53,16 +53,14 @@ be recalled using M-p and M-n." (define-key erc-mode-map "\M-p" 'undefined) (define-key erc-mode-map "\M-n" 'undefined))) -(defvar erc-input-ring nil "Input ring for erc.") -(make-variable-buffer-local 'erc-input-ring) +(defvar-local erc-input-ring nil "Input ring for erc.") -(defvar erc-input-ring-index nil +(defvar-local 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 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.") -(make-variable-buffer-local 'erc-input-ring-index) (defun erc-input-ring-setup () "Do the setup required so that we can use comint style input rings. diff --git a/lisp/erc/erc-stamp.el b/lisp/erc/erc-stamp.el index c7dfb0807bc..2c42a18081e 100644 --- a/lisp/erc/erc-stamp.el +++ b/lisp/erc/erc-stamp.el @@ -191,21 +191,18 @@ or `erc-send-modify-hook'." (list (lambda (_window _before dir) (erc-echo-timestamp dir ct)))))))) -(defvar erc-timestamp-last-inserted nil +(defvar-local erc-timestamp-last-inserted nil "Last timestamp inserted into the buffer.") -(make-variable-buffer-local 'erc-timestamp-last-inserted) -(defvar erc-timestamp-last-inserted-left nil +(defvar-local erc-timestamp-last-inserted-left nil "Last timestamp inserted into the left side of the buffer. This is used when `erc-insert-timestamp-function' is set to `erc-timestamp-left-and-right'") -(make-variable-buffer-local 'erc-timestamp-last-inserted-left) -(defvar erc-timestamp-last-inserted-right nil +(defvar-local erc-timestamp-last-inserted-right nil "Last timestamp inserted into the right side of the buffer. This is used when `erc-insert-timestamp-function' is set to `erc-timestamp-left-and-right'") -(make-variable-buffer-local 'erc-timestamp-last-inserted-right) (defcustom erc-timestamp-only-if-changed-flag t "Insert timestamp only if its value changed since last insertion. diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index bb68173b6dc..37e4cc39d53 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -270,9 +270,8 @@ A typical value would be \((\"#emacs\" \"QUIT\" \"JOIN\") :group 'erc-ignore :type 'erc-message-type) -(defvar erc-session-password nil +(defvar-local erc-session-password nil "The password used for the current session.") -(make-variable-buffer-local 'erc-session-password) (defcustom erc-disconnected-hook nil "Run this hook with arguments (NICK IP REASON) when disconnected. @@ -337,18 +336,16 @@ Functions are passed a buffer as the first argument." :type 'hook) -(defvar erc-channel-users nil +(defvar-local erc-channel-users nil "A hash table of members in the current channel, which associates nicknames with cons cells of the form: \(USER . MEMBER-DATA) where USER is a pointer to an erc-server-user struct, and MEMBER-DATA is a pointer to an erc-channel-user struct.") -(make-variable-buffer-local 'erc-channel-users) -(defvar erc-server-users nil +(defvar-local erc-server-users nil "A hash table of users on the current server, which associates nicknames with erc-server-user struct instances.") -(make-variable-buffer-local 'erc-server-users) (defun erc-downcase (string) "Convert STRING to IRC standard conforming downcase." @@ -632,23 +629,19 @@ See also: `erc-get-channel-user-list'." (or (not nicky) (string-lessp nickx nicky)))))))) -(defvar erc-channel-topic nil +(defvar-local erc-channel-topic nil "A topic string for the channel. Should only be used in channel-buffers.") -(make-variable-buffer-local 'erc-channel-topic) -(defvar erc-channel-modes nil +(defvar-local erc-channel-modes nil "List of strings representing channel modes. 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) -(defvar erc-insert-marker nil +(defvar-local erc-insert-marker nil "The place where insertion of new text in erc buffers should happen.") -(make-variable-buffer-local 'erc-insert-marker) -(defvar erc-input-marker nil +(defvar-local erc-input-marker nil "The marker where input should be inserted.") -(make-variable-buffer-local 'erc-input-marker) (defun erc-string-no-properties (string) "Return a copy of STRING will all text-properties removed." @@ -900,9 +893,8 @@ directory in the list." :group 'erc-scripts :type 'boolean) -(defvar erc-last-saved-position nil +(defvar-local erc-last-saved-position nil "A marker containing the position the current buffer was last saved at.") -(make-variable-buffer-local 'erc-last-saved-position) (defcustom erc-kill-buffer-on-part nil "Kill the channel buffer on PART. @@ -1271,8 +1263,7 @@ See also `erc-show-my-nick'." (defvar erc-debug-log-file (expand-file-name "ERC.debug") "Debug log file name.") -(defvar erc-dbuf nil) -(make-variable-buffer-local 'erc-dbuf) +(defvar-local erc-dbuf nil) (defmacro define-erc-module (name alias doc enable-body disable-body &optional local-p) @@ -1462,11 +1453,10 @@ If BUFFER is nil, the current buffer is used." ;; Last active buffer, to print server messages in the right place -(defvar erc-active-buffer nil +(defvar-local erc-active-buffer nil "The current active buffer, the one where the user typed the last command. Defaults to the server buffer, and should only be set in the server buffer.") -(make-variable-buffer-local 'erc-active-buffer) (defun erc-active-buffer () "Return the value of `erc-active-buffer' for the current server. @@ -1820,52 +1810,41 @@ all channel buffers on all servers." ;; Some local variables -(defvar erc-default-recipients nil +(defvar-local erc-default-recipients nil "List of default recipients of the current buffer.") -(make-variable-buffer-local 'erc-default-recipients) -(defvar erc-session-user-full-name nil +(defvar-local erc-session-user-full-name nil "Full name of the user on the current server.") -(make-variable-buffer-local 'erc-session-user-full-name) -(defvar erc-channel-user-limit nil +(defvar-local erc-channel-user-limit nil "Limit of users per channel.") -(make-variable-buffer-local 'erc-channel-user-limit) -(defvar erc-channel-key nil +(defvar-local erc-channel-key nil "Key needed to join channel.") -(make-variable-buffer-local 'erc-channel-key) -(defvar erc-invitation nil +(defvar-local erc-invitation nil "Last invitation channel.") -(make-variable-buffer-local 'erc-invitation) -(defvar erc-away nil +(defvar-local erc-away nil "Non-nil indicates that we are away. Use `erc-away-time' to access this if you might be in a channel buffer rather than a server buffer.") -(make-variable-buffer-local 'erc-away) -(defvar erc-channel-list nil +(defvar-local erc-channel-list nil "Server channel list.") -(make-variable-buffer-local 'erc-channel-list) -(defvar erc-bad-nick nil +(defvar-local erc-bad-nick nil "Non-nil indicates that we got a `nick in use' error while connecting.") -(make-variable-buffer-local 'erc-bad-nick) -(defvar erc-logged-in nil +(defvar-local erc-logged-in nil "Non-nil indicates that we are logged in.") -(make-variable-buffer-local 'erc-logged-in) -(defvar erc-default-nicks nil +(defvar-local erc-default-nicks nil "The local copy of `erc-nick' - the list of nicks to choose from.") -(make-variable-buffer-local 'erc-default-nicks) -(defvar erc-nick-change-attempt-count 0 +(defvar-local erc-nick-change-attempt-count 0 "Used to keep track of how many times an attempt at changing nick is made.") -(make-variable-buffer-local 'erc-nick-change-attempt-count) (defun erc-migrate-modules (mods) "Migrate old names of ERC modules to new ones." @@ -2764,8 +2743,7 @@ present." (let ((prop-val (erc-get-parsed-vector position))) (and prop-val (member (erc-response.command prop-val) list)))) -(defvar erc-send-input-line-function 'erc-send-input-line) -(make-variable-buffer-local 'erc-send-input-line-function) +(defvar-local erc-send-input-line-function 'erc-send-input-line) (defun erc-send-input-line (target line &optional force) "Send LINE to TARGET. @@ -3181,12 +3159,11 @@ were most recently invited. See also `invitation'." (defalias 'erc-cmd-CHANNEL 'erc-cmd-JOIN) (defalias 'erc-cmd-J 'erc-cmd-JOIN) -(defvar erc-channel-new-member-names nil +(defvar-local erc-channel-new-member-names nil "If non-nil, a names list is currently being received. If non-nil, this variable is a hash-table that associates received nicks with t.") -(make-variable-buffer-local 'erc-channel-new-member-names) (defun erc-cmd-NAMES (&optional channel) "Display the users in CHANNEL. @@ -3833,7 +3810,7 @@ If CHANNEL is not specified, clear the topic for the default channel." ;;; Banlists -(defvar erc-channel-banlist nil +(defvar-local erc-channel-banlist nil "A list of bans seen for the current channel. Each ban is an alist of the form: @@ -3841,7 +3818,6 @@ Each ban is an alist of the form: The property `received-from-server' indicates whether or not the ban list has been requested from the server.") -(make-variable-buffer-local 'erc-channel-banlist) (put 'erc-channel-banlist 'received-from-server nil) (defun erc-cmd-BANLIST () @@ -6783,8 +6759,7 @@ functions." ""))))) -(defvar erc-current-message-catalog 'english) -(make-variable-buffer-local 'erc-current-message-catalog) +(defvar-local erc-current-message-catalog 'english) (defun erc-retrieve-catalog-entry (entry &optional catalog) "Retrieve ENTRY from CATALOG.