2022-10-01 22:32:25 +02:00
|
|
|
;;; erc-compat.el --- ERC compatibility code for older Emacsen -*- lexical-binding: t; -*-
|
2006-01-29 13:08:58 +00:00
|
|
|
|
2023-01-01 05:31:12 -05:00
|
|
|
;; Copyright (C) 2002-2003, 2005-2023 Free Software Foundation, Inc.
|
2006-01-29 13:08:58 +00:00
|
|
|
|
|
|
|
;; Author: Alex Schroeder <alex@gnu.org>
|
2022-01-24 10:59:05 -05:00
|
|
|
;; Maintainer: Amin Bandali <bandali@gnu.org>, F. Jason Park <jp@neverwas.me>
|
Update ERC module URLs
* lisp/erc/erc-autoaway.el, lisp/erc/erc-button.el,
lisp/erc/erc-compat.el, lisp/erc/erc-fill.el, lisp/erc/erc-imenu.el,
lisp/erc/erc-join.el, lisp/erc/erc-lang.el, lisp/erc/erc-match.el,
lisp/erc/erc-pcomplete.el, lisp/erc/erc-ring.el,
lisp/erc/erc-spelling.el, lisp/erc/erc-stamp.el,
lisp/erc/erc-track.el: Update URL to friendlier form, over https.
* lisp/erc/erc-ibuffer.el: Remove URL to nonexistent page.
* lisp/erc/erc-list.el, lisp/erc/erc-log.el, lisp/erc/erc-notify.el,
lisp/erc/erc-replace.el, lisp/erc/erc-services.el,
lisp/erc/erc-sound.el, lisp/erc/erc-speedbar.el,
lisp/erc/erc-truncate.el: Add URL to corresponding EmacsWiki page.
2020-01-24 01:09:43 -05:00
|
|
|
;; URL: https://www.emacswiki.org/emacs/ERC
|
2006-01-29 13:08:58 +00:00
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
2008-05-06 03:36:21 +00:00
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
2006-01-29 13:08:58 +00:00
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 03:36:21 +00:00
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
2006-01-29 13:08:58 +00:00
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 15:52:52 -07:00
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
2006-01-29 13:08:58 +00:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;; This mostly defines stuff that cannot be worked around easily.
|
|
|
|
|
2022-07-08 04:58:26 -07:00
|
|
|
;; ERC depends on the `compat' library from GNU ELPA for supporting
|
|
|
|
;; older versions of Emacs. See this discussion for additional info:
|
|
|
|
;; https://lists.gnu.org/archive/html/emacs-devel/2022-07/msg00512.html
|
|
|
|
|
2006-01-29 13:08:58 +00:00
|
|
|
;;; Code:
|
|
|
|
|
2022-07-08 04:58:26 -07:00
|
|
|
(require 'compat nil 'noerror)
|
2022-12-29 06:43:19 -08:00
|
|
|
(eval-when-compile (require 'cl-lib))
|
2022-07-08 04:58:26 -07:00
|
|
|
|
2023-01-19 20:52:47 -08:00
|
|
|
;; Except for the "erc-" namespacing, these two definitions should be
|
|
|
|
;; continuously updated to match the latest upstream ones verbatim.
|
|
|
|
;; Although they're pretty simple, it's likely not worth checking for
|
|
|
|
;; and possibly deferring to the non-prefixed versions.
|
|
|
|
;;
|
|
|
|
;; BEGIN Compat macros
|
|
|
|
|
|
|
|
;;;; Macros for extended compatibility function calls
|
|
|
|
|
|
|
|
(defmacro erc-compat-function (fun)
|
|
|
|
"Return compatibility function symbol for FUN.
|
|
|
|
|
|
|
|
If the Emacs version provides a sufficiently recent version of
|
|
|
|
FUN, the symbol FUN is returned itself. Otherwise the macro
|
|
|
|
returns the symbol of a compatibility function which supports the
|
|
|
|
behavior and calling convention of the current stable Emacs
|
|
|
|
version. For example Compat 29.1 will provide compatibility
|
|
|
|
functions which implement the behavior and calling convention of
|
|
|
|
Emacs 29.1.
|
|
|
|
|
|
|
|
See also `compat-call' to directly call compatibility functions."
|
|
|
|
(let ((compat (intern (format "compat--%s" fun))))
|
|
|
|
`#',(if (fboundp compat) compat fun)))
|
|
|
|
|
|
|
|
(defmacro erc-compat-call (fun &rest args)
|
|
|
|
"Call compatibility function or macro FUN with ARGS.
|
|
|
|
|
|
|
|
A good example function is `plist-get' which was extended with an
|
|
|
|
additional predicate argument in Emacs 29.1. The compatibility
|
|
|
|
function, which supports this additional argument, can be
|
|
|
|
obtained via (compat-function plist-get) and called
|
|
|
|
via (compat-call plist-get plist prop predicate). It is not
|
|
|
|
possible to directly call (plist-get plist prop predicate) on
|
|
|
|
Emacs older than 29.1, since the original `plist-get' function
|
|
|
|
does not yet support the predicate argument. Note that the
|
|
|
|
Compat library never overrides existing functions.
|
|
|
|
|
|
|
|
See also `compat-function' to lookup compatibility functions."
|
|
|
|
(let ((compat (intern (format "compat--%s" fun))))
|
|
|
|
`(,(if (fboundp compat) compat fun) ,@args)))
|
|
|
|
|
|
|
|
;; END Compat macros
|
|
|
|
|
Put most erc autoloads in a dedicated file erc-loaddefs.el
These are features that are only useful after erc.el is loaded.
* lisp/erc/erc.el (top-level): Load erc-loaddefs.
* lisp/erc/erc-autoaway.el, lisp/erc/erc-button.el:
* lisp/erc/erc-capab.el, lisp/erc/erc-compat.el:
* lisp/erc/erc-dcc.el, lisp/erc/erc-desktop-notifications.el:
* lisp/erc/erc-ezbounce.el, lisp/erc/erc-fill.el:
* lisp/erc/erc-identd.el, lisp/erc/erc-imenu.el:
* lisp/erc/erc-join.el, lisp/erc/erc-list.el, lisp/erc/erc-log.el:
* lisp/erc/erc-match.el, lisp/erc/erc-menu.el:
* lisp/erc/erc-netsplit.el, lisp/erc/erc-notify.el:
* lisp/erc/erc-page.el, lisp/erc/erc-pcomplete.el:
* lisp/erc/erc-replace.el, lisp/erc/erc-ring.el:
* lisp/erc/erc-services.el, lisp/erc/erc-sound.el:
* lisp/erc/erc-speedbar.el, lisp/erc/erc-spelling.el:
* lisp/erc/erc-stamp.el, lisp/erc/erc-track.el:
* lisp/erc/erc-truncate.el, lisp/erc/erc-xdcc.el:
Set generated-autoload-file to "erc-loaddefs.el".
2017-11-28 21:16:02 -05:00
|
|
|
;;;###autoload(autoload 'erc-define-minor-mode "erc-compat")
|
2021-09-26 18:14:27 +02:00
|
|
|
(define-obsolete-function-alias 'erc-define-minor-mode
|
|
|
|
#'define-minor-mode "28.1")
|
2006-01-29 13:08:58 +00:00
|
|
|
|
|
|
|
(defun erc-decode-coding-string (s coding-system)
|
|
|
|
"Decode S using CODING-SYSTEM."
|
2021-09-26 18:14:27 +02:00
|
|
|
(declare (obsolete decode-coding-string "28.1"))
|
2006-01-29 13:08:58 +00:00
|
|
|
(decode-coding-string s coding-system t))
|
|
|
|
|
|
|
|
(defun erc-encode-coding-string (s coding-system)
|
|
|
|
"Encode S using CODING-SYSTEM.
|
|
|
|
Return the same string, if the encoding operation is trivial.
|
|
|
|
See `erc-encoding-coding-alist'."
|
2021-09-26 18:14:27 +02:00
|
|
|
(declare (obsolete encode-coding-string "28.1"))
|
2006-01-29 13:08:58 +00:00
|
|
|
(encode-coding-string s coding-system t))
|
|
|
|
|
Make more erc function aliases obsolete
* lisp/erc/erc-compat.el (erc-propertize, erc-view-mode-enter)
(erc-function-arglist, erc-delete-dups)
(erc-replace-regexp-in-string): Make these aliases obsolete.
* lisp/erc/erc-capab.el (erc-capab-identify-add-prefix)
(erc-capab-identify-remove/set-identified-flag):
* lisp/erc/erc-dcc.el (erc-dcc-chat-parse-output)
(erc-dcc-unquote-filename, pcomplete/erc-mode/DCC):
* lisp/erc/erc-list.el (erc-list-menu-mode, erc-list-button)
(erc-list-make-string):
* lisp/erc/erc-log.el (erc-log-standardize-name):
* lisp/erc/erc-match.el (erc-log-matches-make-buffer):
* lisp/erc/erc-networks.el (erc-server-select):
* lisp/erc/erc.el (erc-message-english-PART)
(erc-update-mode-line-buffer, erc-format-my-nick)
(erc-format-@nick, erc-get-user-mode-prefix, erc-display-prompt)
(erc-part-reason-zippy, erc-quit-reason-zippy, erc-get-arglist)
(erc-toggle-debug-irc-protocol, erc-log-irc-protocol)
(erc-migrate-modules): Adjust callers.
2020-08-07 13:54:50 +02:00
|
|
|
(define-obsolete-function-alias 'erc-propertize #'propertize "28.1")
|
|
|
|
(define-obsolete-function-alias 'erc-view-mode-enter #'view-mode-enter "28.1")
|
2008-11-19 04:38:16 +00:00
|
|
|
(autoload 'help-function-arglist "help-fns")
|
Make more erc function aliases obsolete
* lisp/erc/erc-compat.el (erc-propertize, erc-view-mode-enter)
(erc-function-arglist, erc-delete-dups)
(erc-replace-regexp-in-string): Make these aliases obsolete.
* lisp/erc/erc-capab.el (erc-capab-identify-add-prefix)
(erc-capab-identify-remove/set-identified-flag):
* lisp/erc/erc-dcc.el (erc-dcc-chat-parse-output)
(erc-dcc-unquote-filename, pcomplete/erc-mode/DCC):
* lisp/erc/erc-list.el (erc-list-menu-mode, erc-list-button)
(erc-list-make-string):
* lisp/erc/erc-log.el (erc-log-standardize-name):
* lisp/erc/erc-match.el (erc-log-matches-make-buffer):
* lisp/erc/erc-networks.el (erc-server-select):
* lisp/erc/erc.el (erc-message-english-PART)
(erc-update-mode-line-buffer, erc-format-my-nick)
(erc-format-@nick, erc-get-user-mode-prefix, erc-display-prompt)
(erc-part-reason-zippy, erc-quit-reason-zippy, erc-get-arglist)
(erc-toggle-debug-irc-protocol, erc-log-irc-protocol)
(erc-migrate-modules): Adjust callers.
2020-08-07 13:54:50 +02:00
|
|
|
(define-obsolete-function-alias 'erc-function-arglist #'help-function-arglist "28.1")
|
|
|
|
(define-obsolete-function-alias 'erc-delete-dups #'delete-dups "28.1")
|
|
|
|
(define-obsolete-function-alias 'erc-replace-regexp-in-string #'replace-regexp-in-string "28.1")
|
2006-01-29 13:08:58 +00:00
|
|
|
|
2007-11-01 01:12:59 +00:00
|
|
|
(defun erc-set-write-file-functions (new-val)
|
2021-09-26 18:14:27 +02:00
|
|
|
(declare (obsolete nil "28.1"))
|
2007-11-01 01:12:59 +00:00
|
|
|
(set (make-local-variable 'write-file-functions) new-val))
|
|
|
|
|
2006-01-29 13:08:58 +00:00
|
|
|
(defvar erc-emacs-build-time
|
2016-03-02 10:21:45 -08:00
|
|
|
(if (or (stringp emacs-build-time) (not emacs-build-time))
|
2006-01-29 13:08:58 +00:00
|
|
|
emacs-build-time
|
|
|
|
(format-time-string "%Y-%m-%d" emacs-build-time))
|
2016-03-02 10:21:45 -08:00
|
|
|
"Time at which Emacs was dumped out, or nil if not available.")
|
2021-09-26 18:14:27 +02:00
|
|
|
(make-obsolete-variable 'erc-emacs-build-time 'emacs-build-time "28.1")
|
|
|
|
(define-obsolete-variable-alias 'erc-user-emacs-directory 'user-emacs-directory "28.1")
|
2007-09-08 03:07:09 +00:00
|
|
|
|
2006-01-29 13:08:58 +00:00
|
|
|
(defun erc-replace-match-subexpression-in-string
|
* lisp/obsolete: Use lexical-binding
Use lexical-binding in all the lisp/obsolete/*.el files.
While at it, removed redundant :group arguments and used #' to quote
functions. Commented out the key bindings which the #' revealed
to lead to non-existing commands, and replaced those revealed to be obsolete.
* lisp/obsolete/cl-compat.el: Use cl-lib.
* lisp/obsolete/cust-print.el: Assume `defalias` exists.
(with-custom-print): Use `declare`.
* lisp/obsolete/iswitchb.el (iswitchb-init-XEmacs-trick)
(iswitchb-xemacs-backspacekey): Remove functions.
* lisp/obsolete/landmark.el (landmark, landmark-nslify-wts):
Prefer `apply` to `eval`.
* lisp/obsolete/longlines.el (longlines-mode): Don't use `add-to-list`
on a hook.
* lisp/obsolete/pgg-gpg.el (pgg-gpg-process-region): Use `clear-string`.
* lisp/obsolete/pgg-pgp.el (pgg-pgp-encrypt-region): Remove oddly
unused var `passphrase`.
(pgg-pgp-verify-region): Declare var `jam-zcat-filename-list`.
* lisp/obsolete/pgg-pgp5.el (pgg-pgp5-encrypt-region): Remove oddly
unused var `passphrase`.
(pgg-pgp5-verify-region): Declare var `jam-zcat-filename-list`.
* lisp/obsolete/pgg.el: Remove some XEmacs compatibility code.
(pgg-run-at-time, pgg-cancel-timer, pgg-clear-string): Remove functions.
Use their core equivalent instead.
* lisp/obsolete/rcompile.el (remote-compile): Remove unused vars `l`,
`l-host`, `l-user`, and `localname`.
* lisp/obsolete/starttls.el (starttls-any-program-available):
Use `define-obsolete-function-alias`.
* lisp/obsolete/tls.el (tls-format-message): Delete function, use
`format-message` instead.
* lisp/obsolete/url-ns.el (url-ns-prefs): Use `with-current-buffer`
and `dlet`.
* lisp/obsolete/vip.el (vip-escape-to-emacs): Remove unused var `key`.
(vip-command-argument, vip-read-string, ex-delete, ex-line): Remove
unused var `conditions`.
(ex-map): Use a closure instead of `eval`.
(ex-set): Make it an alias of `set-variable`.
(ex-substitute): Remove unused var `cont`.
* lisp/obsolete/abbrevlist.el:
* lisp/obsolete/bruce.el:
* lisp/obsolete/cc-compat.el:
* lisp/obsolete/cl-compat.el:
* lisp/obsolete/cl.el:
* lisp/obsolete/complete.el:
* lisp/obsolete/crisp.el:
* lisp/obsolete/cust-print.el:
* lisp/obsolete/erc-compat.el:
* lisp/obsolete/erc-hecomplete.el:
* lisp/obsolete/eudcb-ph.el:
* lisp/obsolete/fast-lock.el:
* lisp/obsolete/gs.el:
* lisp/obsolete/gulp.el:
* lisp/obsolete/html2text.el:
* lisp/obsolete/info-edit.el:
* lisp/obsolete/iswitchb.el:
* lisp/obsolete/landmark.el:
* lisp/obsolete/lazy-lock.el:
* lisp/obsolete/longlines.el:
* lisp/obsolete/mailpost.el:
* lisp/obsolete/mantemp.el:
* lisp/obsolete/meese.el:
* lisp/obsolete/messcompat.el:
* lisp/obsolete/metamail.el:
* lisp/obsolete/mouse-sel.el:
* lisp/obsolete/nnir.el:
* lisp/obsolete/old-emacs-lock.el:
* lisp/obsolete/otodo-mode.el:
* lisp/obsolete/patcomp.el:
* lisp/obsolete/pc-mode.el:
* lisp/obsolete/pc-select.el:
* lisp/obsolete/pgg-def.el:
* lisp/obsolete/pgg-gpg.el:
* lisp/obsolete/pgg-parse.el:
* lisp/obsolete/pgg-pgp.el:
* lisp/obsolete/pgg-pgp5.el:
* lisp/obsolete/pgg.el:
* lisp/obsolete/rcompile.el:
* lisp/obsolete/s-region.el:
* lisp/obsolete/sb-image.el:
* lisp/obsolete/sregex.el:
* lisp/obsolete/starttls.el:
* lisp/obsolete/sup-mouse.el:
* lisp/obsolete/terminal.el:
* lisp/obsolete/tls.el:
* lisp/obsolete/tpu-edt.el:
* lisp/obsolete/tpu-extras.el:
* lisp/obsolete/tpu-mapper.el:
* lisp/obsolete/url-ns.el:
* lisp/obsolete/vc-arch.el:
* lisp/obsolete/vi.el:
* lisp/obsolete/vip.el:
* lisp/obsolete/ws-mode.el:
* lisp/obsolete/yow.el: Use lexical-binding.
2021-02-22 16:54:59 -05:00
|
|
|
(newtext string _match subexp _start &optional fixedcase literal)
|
2006-01-29 13:08:58 +00:00
|
|
|
"Replace the subexpression SUBEXP of the last match in STRING with NEWTEXT.
|
|
|
|
MATCH is the text which matched the subexpression (see `match-string').
|
|
|
|
START is the beginning position of the last match (see `match-beginning').
|
|
|
|
See `replace-match' for explanations of FIXEDCASE and LITERAL."
|
2021-09-26 18:14:27 +02:00
|
|
|
(declare (obsolete replace-match "28.1"))
|
2019-06-20 01:44:19 +02:00
|
|
|
(replace-match newtext fixedcase literal string subexp))
|
2006-01-29 13:08:58 +00:00
|
|
|
|
2020-08-02 07:55:02 +02:00
|
|
|
(define-obsolete-function-alias 'erc-with-selected-window
|
|
|
|
#'with-selected-window "28.1")
|
|
|
|
(define-obsolete-function-alias 'erc-cancel-timer #'cancel-timer "28.1")
|
|
|
|
(define-obsolete-function-alias 'erc-make-obsolete #'make-obsolete "28.1")
|
|
|
|
(define-obsolete-function-alias 'erc-make-obsolete-variable
|
|
|
|
#'make-obsolete-variable "28.1")
|
2006-01-29 13:08:58 +00:00
|
|
|
|
2021-09-26 18:14:27 +02:00
|
|
|
;; Provide a simpler replacement for `cl-member-if'
|
2006-01-29 13:08:58 +00:00
|
|
|
(defun erc-member-if (predicate list)
|
|
|
|
"Find the first item satisfying PREDICATE in LIST.
|
|
|
|
Return the sublist of LIST whose car matches."
|
2021-09-26 18:14:27 +02:00
|
|
|
(declare (obsolete cl-member-if "28.1"))
|
2006-01-29 13:08:58 +00:00
|
|
|
(let ((ptr list))
|
|
|
|
(catch 'found
|
|
|
|
(while ptr
|
|
|
|
(when (funcall predicate (car ptr))
|
|
|
|
(throw 'found ptr))
|
|
|
|
(setq ptr (cdr ptr))))))
|
|
|
|
|
2021-09-26 18:14:27 +02:00
|
|
|
;; Provide a simpler replacement for `cl-delete-if'
|
2006-01-29 13:08:58 +00:00
|
|
|
(defun erc-delete-if (predicate seq)
|
|
|
|
"Remove all items satisfying PREDICATE in SEQ.
|
|
|
|
This is a destructive function: it reuses the storage of SEQ
|
|
|
|
whenever possible."
|
2021-09-26 18:14:27 +02:00
|
|
|
(declare (obsolete cl-delete-if "28.1"))
|
2006-01-29 13:08:58 +00:00
|
|
|
;; remove from car
|
|
|
|
(while (when (funcall predicate (car seq))
|
|
|
|
(setq seq (cdr seq))))
|
|
|
|
;; remove from cdr
|
|
|
|
(let ((ptr seq)
|
|
|
|
(next (cdr seq)))
|
|
|
|
(while next
|
|
|
|
(when (funcall predicate (car next))
|
|
|
|
(setcdr ptr (if (consp next)
|
|
|
|
(cdr next)
|
|
|
|
nil)))
|
|
|
|
(setq ptr (cdr ptr))
|
|
|
|
(setq next (cdr ptr))))
|
|
|
|
seq)
|
|
|
|
|
2021-09-26 18:14:27 +02:00
|
|
|
;; Provide a simpler replacement for `cl-remove-if-not'
|
2006-01-29 13:08:58 +00:00
|
|
|
(defun erc-remove-if-not (predicate seq)
|
|
|
|
"Remove all items not satisfying PREDICATE in SEQ.
|
|
|
|
This is a non-destructive function; it makes a copy of SEQ to
|
|
|
|
avoid corrupting the original SEQ."
|
2021-09-26 18:14:27 +02:00
|
|
|
(declare (obsolete cl-remove-if-not "28.1"))
|
2006-01-29 13:08:58 +00:00
|
|
|
(let (newseq)
|
|
|
|
(dolist (el seq)
|
|
|
|
(when (funcall predicate el)
|
|
|
|
(setq newseq (cons el newseq))))
|
|
|
|
(nreverse newseq)))
|
|
|
|
|
|
|
|
;; Copied from cl-extra.el
|
|
|
|
(defun erc-subseq (seq start &optional end)
|
|
|
|
"Return the subsequence of SEQ from START to END.
|
|
|
|
If END is omitted, it defaults to the length of the sequence.
|
|
|
|
If START or END is negative, it counts from the end."
|
2021-09-26 18:14:27 +02:00
|
|
|
(declare (obsolete cl-subseq "28.1"))
|
2006-01-29 13:08:58 +00:00
|
|
|
(if (stringp seq) (substring seq start end)
|
|
|
|
(let (len)
|
|
|
|
(and end (< end 0) (setq end (+ end (setq len (length seq)))))
|
|
|
|
(if (< start 0) (setq start (+ start (or len (setq len (length seq))))))
|
|
|
|
(cond ((listp seq)
|
|
|
|
(if (> start 0) (setq seq (nthcdr start seq)))
|
|
|
|
(if end
|
|
|
|
(let ((res nil))
|
|
|
|
(while (>= (setq end (1- end)) start)
|
|
|
|
(push (pop seq) res))
|
|
|
|
(nreverse res))
|
|
|
|
(copy-sequence seq)))
|
|
|
|
(t
|
|
|
|
(or end (setq end (or len (length seq))))
|
|
|
|
(let ((res (make-vector (max (- end start) 0) nil))
|
|
|
|
(i 0))
|
|
|
|
(while (< start end)
|
|
|
|
(aset res i (aref seq start))
|
|
|
|
(setq i (1+ i) start (1+ start)))
|
|
|
|
res))))))
|
|
|
|
|
Move ERC's core dependencies to separate file
Asking people to order require's is about as effective
as asking kids to keep off the grass.
* lisp/erc/erc-backend.el (erc--target, erc-auto-query,
erc-channel-list, erc-channel-users, erc-default-nicks,
erc-default-recipients, erc-format-nick-function,
erc-format-query-as-channel-p, erc-hide-prompt, erc-input-marker,
erc-insert-marker, erc-invitation, erc-join-buffer,
erc-kill-buffer-on-part, erc-kill-server-buffer-on-quit, erc-log-p,
erc-minibuffer-ignored, erc-networks--id, erc-nick,
erc-nick-change-attempt-count, erc-prompt-for-channel-key,
erc-prompt-hidden, erc-reuse-buffers, erc-verbose-server-ping,
erc-whowas-on-nosuchnick): Forward-declare variables.
(erc--open-target, erc--target-from-string, erc-active-buffer,
erc-add-default-channel, erc-banlist-update, erc-buffer-filter,
erc-buffer-list-with-nick, erc-channel-begin-receiving-names,
erc-channel-end-receiving-names, erc-channel-p,
erc-channel-receive-names, erc-cmd-JOIN, erc-connection-established,
erc-current-nick, erc-current-nick-p, erc-current-time,
erc-default-target, erc-delete-default-channel,
erc-display-error-notice, erc-display-server-message,
erc-emacs-time-to-erc-time, erc-format-message,
erc-format-privmessage, erc-get-buffer, erc-handle-login,
erc-handle-user-status-change, erc-ignored-reply-p,
erc-ignored-user-p, erc-is-message-ctcp-and-not-action-p,
erc-is-message-ctcp-p, erc-log-irc-protocol, erc-login,
erc-make-notice, erc-network, erc-networks--id-given,
erc-networks--id-reload, erc-nickname-in-use, erc-parse-user,
erc-process-away, erc-process-ctcp-query, erc-query-buffer-p,
erc-remove-channel-member, erc-remove-channel-users, erc-remove-user,
erc-sec-to-time, erc-server-buffer, erc-set-active-buffer,
erc-set-current-nick, erc-set-modes, erc-time-diff, erc-trim-string,
erc-update-mode-line, erc-update-mode-line-buffer,
erc-wash-quit-reason, erc-display-message, erc-get-buffer-create,
erc-process-ctcp-reply, erc-update-channel-topic, erc-update-modes,
erc-update-user-nick, erc-open, erc-update-channel-member):
Forward-declare functions.
(erc-response): Move to lisp/erc/erc-common.el.
(erc-compat--with-memoization): Use "erc-compat-" prefixed macro.
* lisp/erc/erc-common.el: New file. Change indentation for
`erc-with-all-buffers-of-server' from 1 to 2.
* lisp/erc/erc-compat.el (erc-compat--with-memoization): Migrate macro
from `erc-backend' and rename.
* lisp/erc/erc-goodies.el: Require `erc-common' instead of `erc'.
(erc-controls-highlight-regexp, erc-controls-remove-regexp,
erc-input-marker, erc-insert-marker, erc-server-process, erc-modules,
erc-log-p): Forward declare variables.
(erc-buffer-list, erc-error, erc-extract-command-from-line):
Forward-declare functions.
* lisp/erc/erc-networks.el (erc--target, erc-insert-marker,
erc-kill-buffer-hook, erc-kill-server-hook, erc-modules,
erc-rename-buffers, erc-reuse-buffers, erc-server-announced-name,
erc-server-connected, erc-server-parameters, erc-server-process,
erc-session-server): Forward declare variables.
(erc--default-target, erc--get-isupport-entry, erc-buffer-filter,
erc-current-nick, erc-display-error-notice, erc-error, erc-get-buffer,
erc-server-buffer, erc-server-process-alive): Forward-declare
functions.
(erc-obsolete-var): Also suppress free-variable warnings.
* lisp/erc/erc.el: Require `erc-networks', `erc-goodies', and
`erc-backend' at top of file. Don't require `erc-compat'.
(erc--server-last-reconnect-count, erc--server-reconnecting,
erc-channel-members-changed-hook, erc-network, erc-networks--id,
erc-server-367-functions, erc-server-announced-name,
erc-server-connect-function, erc-server-connected,
erc-server-current-nick, erc-server-lag, erc-server-last-sent-time,
erc-server-process, erc-server-quitting, erc-server-reconnect-count,
erc-server-reconnecting, erc-session-client-certificate,
erc-session-connector, erc-session-port, erc-session-server,
erc-session-user-full-name) Remove superfluous forward declarations.
(erc-message-parsed, tabbar--local-hlf, motif-version-string):
Relocate forward declares to central location.
(erc-session-password): Move to `erc-backend'.
(erc-downcase, erc-with-server-buffer, erc-server-user,
erc-channel-user, erc-get-channel-user, erc-get-server-user): Move to
lisp/erc/erc-common.el.
(erc-add-server-user, erc-remove-server-user,
erc-channel-user-owner-p, erc-channel-user-admin-p,
erc-channel-user-op-p, erc-channel-user-halfop-p,
erc-channel-user-voice-p): Convert from inline functions to normal
functions.
(define-erc-module, erc--target, erc--target-channel,
erc--target-channel-local, erc-log, erc-log-aux, erc-with-buffer,
erc-with-all-buffers-of-server): Move to lisp/erc/erc-common.el.
(erc-channel-members-changed-hook): Relocate option to avoid compiler
warning.
(erc-input, erc--input-split): Move to lisp/erc/erc-common.el.
(erc-controls-strip): Remove forward declaration temporarily until
this file stops requiring `erc-goodies'.
* test/lisp/erc/erc-networks-tests.el: Require `erc' instead of
`erc-networks'.
* test/lisp/erc/erc.el (erc--meta--backend-dependencies): Remove
obsolete test. Don't require `erc-networks'. Bug#56340.
2022-07-01 11:06:51 -04:00
|
|
|
|
2022-04-24 06:20:09 -07:00
|
|
|
;;;; Auth Source
|
|
|
|
|
|
|
|
(declare-function auth-source-pass--get-attr
|
|
|
|
"auth-source-pass" (key entry-data))
|
|
|
|
(declare-function auth-source-pass--disambiguate
|
|
|
|
"auth-source-pass" (host &optional user port))
|
|
|
|
(declare-function auth-source-backend-parse-parameters
|
|
|
|
"auth-source-pass" (entry backend))
|
|
|
|
(declare-function auth-source-backend "auth-source" (&rest slots))
|
|
|
|
(declare-function auth-source-pass-entries "auth-source-pass" nil)
|
|
|
|
(declare-function auth-source-pass-parse-entry "auth-source-pass" (entry))
|
|
|
|
|
|
|
|
(defvar auth-sources)
|
|
|
|
(defvar auth-source-backend-parser-functions)
|
|
|
|
|
|
|
|
;; This hard codes `auth-source-pass-port-separator' to ":"
|
|
|
|
(defun erc-compat--29-auth-source-pass--retrieve-parsed (seen e port-number-p)
|
|
|
|
(when (string-match (rx (or bot "/")
|
2022-11-24 21:03:03 -08:00
|
|
|
(or (: (? (group-n 20 (+ (not (in "/:")))) "@")
|
|
|
|
(group-n 10 (+ (not (in "/:@"))))
|
2022-04-24 06:20:09 -07:00
|
|
|
(? ":" (group-n 30 (+ (not (in " /:"))))))
|
2022-11-24 21:03:03 -08:00
|
|
|
(: (group-n 11 (+ (not (in "/:@"))))
|
2022-04-24 06:20:09 -07:00
|
|
|
(? ":" (group-n 31 (+ (not (in " /:")))))
|
2022-11-24 21:03:03 -08:00
|
|
|
(? "/" (group-n 21 (+ (not (in "/:")))))))
|
2022-04-24 06:20:09 -07:00
|
|
|
eot)
|
|
|
|
e)
|
|
|
|
(puthash e `( :host ,(or (match-string 10 e) (match-string 11 e))
|
|
|
|
,@(if-let* ((tr (match-string 21 e)))
|
|
|
|
(list :user tr :suffix t)
|
|
|
|
(list :user (match-string 20 e)))
|
|
|
|
:port ,(and-let* ((p (or (match-string 30 e)
|
|
|
|
(match-string 31 e)))
|
|
|
|
(n (string-to-number p)))
|
|
|
|
(if (or (zerop n) (not port-number-p))
|
|
|
|
(format "%s" p)
|
|
|
|
n)))
|
|
|
|
seen)))
|
|
|
|
|
|
|
|
;; This looks bad, but it just inlines `auth-source-pass--find-match-many'.
|
|
|
|
(defun erc-compat--29-auth-source-pass--build-result-many
|
|
|
|
(hosts users ports require max)
|
|
|
|
"Return a plist of HOSTS, PORTS, USERS, and secret."
|
|
|
|
(unless (listp hosts) (setq hosts (list hosts)))
|
|
|
|
(unless (listp users) (setq users (list users)))
|
|
|
|
(unless (listp ports) (setq ports (list ports)))
|
|
|
|
(unless max (setq max 1))
|
|
|
|
(let ((seen (make-hash-table :test #'equal))
|
|
|
|
(entries (auth-source-pass-entries))
|
|
|
|
(check (lambda (m k v)
|
|
|
|
(let ((mv (plist-get m k)))
|
|
|
|
(if (memq k require)
|
|
|
|
(and v (equal mv v))
|
|
|
|
(or (not v) (not mv) (equal mv v))))))
|
|
|
|
out suffixed suffixedp)
|
|
|
|
(catch 'done
|
|
|
|
(dolist (host hosts)
|
|
|
|
(pcase-let ((`(,_ ,u ,p) (auth-source-pass--disambiguate host)))
|
|
|
|
(unless (or (not (equal "443" p)) (string-prefix-p "https://" host))
|
|
|
|
(setq p nil))
|
|
|
|
(dolist (user (or users (list u)))
|
|
|
|
(dolist (port (or ports (list p)))
|
|
|
|
(dolist (e entries)
|
|
|
|
(when-let*
|
|
|
|
((m (or (gethash e seen)
|
|
|
|
(erc-compat--29-auth-source-pass--retrieve-parsed
|
|
|
|
seen e (integerp port))))
|
|
|
|
((equal host (plist-get m :host)))
|
|
|
|
((funcall check m :port port))
|
|
|
|
((funcall check m :user user))
|
|
|
|
(parsed (auth-source-pass-parse-entry e))
|
|
|
|
(secret (or (auth-source-pass--get-attr 'secret parsed)
|
|
|
|
(not (memq :secret require)))))
|
|
|
|
(push
|
|
|
|
`( :host ,host ; prefer user-provided :host over h
|
|
|
|
,@(and-let* ((u (plist-get m :user))) (list :user u))
|
|
|
|
,@(and-let* ((p (plist-get m :port))) (list :port p))
|
|
|
|
,@(and secret (not (eq secret t)) (list :secret secret)))
|
|
|
|
(if (setq suffixedp (plist-get m :suffix)) suffixed out))
|
|
|
|
(unless suffixedp
|
|
|
|
(when (or (zerop (cl-decf max))
|
|
|
|
(null (setq entries (delete e entries))))
|
|
|
|
(throw 'done out)))))
|
|
|
|
(setq suffixed (nreverse suffixed))
|
|
|
|
(while suffixed
|
|
|
|
(push (pop suffixed) out)
|
|
|
|
(when (zerop (cl-decf max))
|
|
|
|
(throw 'done out))))))))
|
|
|
|
(reverse out)))
|
|
|
|
|
|
|
|
(cl-defun erc-compat--29-auth-source-pass-search
|
|
|
|
(&rest spec &key host user port require max &allow-other-keys)
|
|
|
|
;; From `auth-source-pass-search'
|
|
|
|
(cl-assert (and host (not (eq host t)))
|
|
|
|
t "Invalid password-store search: %s %s")
|
2022-11-13 01:52:48 -08:00
|
|
|
(let ((rv (erc-compat--29-auth-source-pass--build-result-many
|
|
|
|
host user port require max)))
|
|
|
|
(if (and (fboundp 'auth-source--obfuscate)
|
|
|
|
(fboundp 'auth-source--deobfuscate))
|
|
|
|
(let (out)
|
|
|
|
(dolist (e rv out)
|
|
|
|
(when-let* ((s (plist-get e :secret))
|
|
|
|
(v (auth-source--obfuscate s)))
|
2023-01-10 11:59:57 -08:00
|
|
|
(setq e (plist-put e :secret (apply-partially
|
|
|
|
#'auth-source--deobfuscate v))))
|
2022-11-13 01:52:48 -08:00
|
|
|
(push e out)))
|
|
|
|
rv)))
|
2022-04-24 06:20:09 -07:00
|
|
|
|
|
|
|
(defun erc-compat--29-auth-source-pass-backend-parse (entry)
|
|
|
|
(when (eq entry 'password-store)
|
|
|
|
(auth-source-backend-parse-parameters
|
|
|
|
entry (auth-source-backend
|
|
|
|
:source "."
|
|
|
|
:type 'password-store
|
|
|
|
:search-function #'erc-compat--29-auth-source-pass-search))))
|
|
|
|
|
|
|
|
(defun erc-compat--auth-source-backend-parser-functions ()
|
|
|
|
(if (memq 'password-store auth-sources)
|
|
|
|
(progn
|
|
|
|
(require 'auth-source-pass)
|
|
|
|
`(,@(unless (bound-and-true-p auth-source-pass-extra-query-keywords)
|
|
|
|
'(erc-compat--29-auth-source-pass-backend-parse))
|
|
|
|
,@auth-source-backend-parser-functions))
|
|
|
|
auth-source-backend-parser-functions))
|
|
|
|
|
|
|
|
|
2021-07-12 03:44:28 -07:00
|
|
|
;;;; SASL
|
|
|
|
|
|
|
|
(declare-function sasl-step-data "sasl" (step))
|
|
|
|
(declare-function sasl-error "sasl" (datum))
|
|
|
|
(declare-function sasl-client-property "sasl" (client property))
|
|
|
|
(declare-function sasl-client-set-property "sasl" (client property value))
|
|
|
|
(declare-function sasl-mechanism-name "sasl" (mechanism))
|
|
|
|
(declare-function sasl-client-name "sasl" (client))
|
|
|
|
(declare-function sasl-client-mechanism "sasl" (client))
|
|
|
|
(declare-function sasl-read-passphrase "sasl" (prompt))
|
|
|
|
(declare-function sasl-unique-id "sasl" nil)
|
|
|
|
(declare-function decode-hex-string "hex-util" (string))
|
|
|
|
(declare-function rfc2104-hash "rfc2104" (hash block-length hash-length
|
|
|
|
key text))
|
|
|
|
(declare-function sasl-scram--client-first-message-bare "sasl-scram-rfc"
|
|
|
|
(client))
|
|
|
|
(declare-function cl-mapcar "cl-lib" (cl-func cl-x &rest cl-rest))
|
|
|
|
|
|
|
|
(defun erc-compat--29-sasl-scram-construct-gs2-header (client)
|
|
|
|
(let ((authzid (sasl-client-property client 'authenticator-name)))
|
|
|
|
(concat "n," (and authzid "a=") authzid ",")))
|
|
|
|
|
|
|
|
(defun erc-compat--29-sasl-scram-client-first-message (client _step)
|
|
|
|
(let ((c-nonce (sasl-unique-id)))
|
|
|
|
(sasl-client-set-property client 'c-nonce c-nonce))
|
|
|
|
(concat (erc-compat--29-sasl-scram-construct-gs2-header client)
|
|
|
|
(sasl-scram--client-first-message-bare client)))
|
|
|
|
|
|
|
|
(defun erc-compat--29-sasl-scram--client-final-message
|
|
|
|
(hash-fun block-length hash-length client step)
|
|
|
|
(unless (string-match
|
|
|
|
"^r=\\([^,]+\\),s=\\([^,]+\\),i=\\([0-9]+\\)\\(?:$\\|,\\)"
|
|
|
|
(sasl-step-data step))
|
|
|
|
(sasl-error "Unexpected server response"))
|
|
|
|
(let* ((hmac-fun
|
|
|
|
(lambda (text key)
|
|
|
|
(decode-hex-string
|
|
|
|
(rfc2104-hash hash-fun block-length hash-length key text))))
|
|
|
|
(step-data (sasl-step-data step))
|
|
|
|
(nonce (match-string 1 step-data))
|
|
|
|
(salt-base64 (match-string 2 step-data))
|
|
|
|
(iteration-count (string-to-number (match-string 3 step-data)))
|
|
|
|
(c-nonce (sasl-client-property client 'c-nonce))
|
|
|
|
(cbind-input
|
|
|
|
(if (string-prefix-p c-nonce nonce)
|
|
|
|
(erc-compat--29-sasl-scram-construct-gs2-header client) ; *1
|
|
|
|
(sasl-error "Invalid nonce from server")))
|
|
|
|
(client-final-message-without-proof
|
|
|
|
(concat "c=" (base64-encode-string cbind-input t) "," ; *2
|
|
|
|
"r=" nonce))
|
|
|
|
(password
|
|
|
|
(sasl-read-passphrase
|
|
|
|
(format "%s passphrase for %s: "
|
|
|
|
(sasl-mechanism-name (sasl-client-mechanism client))
|
|
|
|
(sasl-client-name client))))
|
|
|
|
(salt (base64-decode-string salt-base64))
|
|
|
|
(string-xor (lambda (a b)
|
|
|
|
(apply #'unibyte-string (cl-mapcar #'logxor a b))))
|
|
|
|
(salted-password (let ((digest (concat salt (string 0 0 0 1)))
|
|
|
|
(xored nil))
|
|
|
|
(dotimes (_i iteration-count xored)
|
|
|
|
(setq digest (funcall hmac-fun digest password))
|
|
|
|
(setq xored (if (null xored)
|
|
|
|
digest
|
|
|
|
(funcall string-xor xored
|
|
|
|
digest))))))
|
|
|
|
(client-key (funcall hmac-fun "Client Key" salted-password))
|
|
|
|
(stored-key (decode-hex-string (funcall hash-fun client-key)))
|
|
|
|
(auth-message (concat "n=" (sasl-client-name client)
|
|
|
|
",r=" c-nonce "," step-data
|
|
|
|
"," client-final-message-without-proof))
|
|
|
|
(client-signature (funcall hmac-fun
|
|
|
|
(encode-coding-string auth-message 'utf-8)
|
|
|
|
stored-key))
|
|
|
|
(client-proof (funcall string-xor client-key client-signature))
|
|
|
|
(client-final-message
|
|
|
|
(concat client-final-message-without-proof ","
|
|
|
|
"p=" (base64-encode-string client-proof t)))) ; *3
|
|
|
|
(sasl-client-set-property client 'auth-message auth-message)
|
|
|
|
(sasl-client-set-property client 'salted-password salted-password)
|
|
|
|
client-final-message))
|
|
|
|
|
|
|
|
|
Move ERC's core dependencies to separate file
Asking people to order require's is about as effective
as asking kids to keep off the grass.
* lisp/erc/erc-backend.el (erc--target, erc-auto-query,
erc-channel-list, erc-channel-users, erc-default-nicks,
erc-default-recipients, erc-format-nick-function,
erc-format-query-as-channel-p, erc-hide-prompt, erc-input-marker,
erc-insert-marker, erc-invitation, erc-join-buffer,
erc-kill-buffer-on-part, erc-kill-server-buffer-on-quit, erc-log-p,
erc-minibuffer-ignored, erc-networks--id, erc-nick,
erc-nick-change-attempt-count, erc-prompt-for-channel-key,
erc-prompt-hidden, erc-reuse-buffers, erc-verbose-server-ping,
erc-whowas-on-nosuchnick): Forward-declare variables.
(erc--open-target, erc--target-from-string, erc-active-buffer,
erc-add-default-channel, erc-banlist-update, erc-buffer-filter,
erc-buffer-list-with-nick, erc-channel-begin-receiving-names,
erc-channel-end-receiving-names, erc-channel-p,
erc-channel-receive-names, erc-cmd-JOIN, erc-connection-established,
erc-current-nick, erc-current-nick-p, erc-current-time,
erc-default-target, erc-delete-default-channel,
erc-display-error-notice, erc-display-server-message,
erc-emacs-time-to-erc-time, erc-format-message,
erc-format-privmessage, erc-get-buffer, erc-handle-login,
erc-handle-user-status-change, erc-ignored-reply-p,
erc-ignored-user-p, erc-is-message-ctcp-and-not-action-p,
erc-is-message-ctcp-p, erc-log-irc-protocol, erc-login,
erc-make-notice, erc-network, erc-networks--id-given,
erc-networks--id-reload, erc-nickname-in-use, erc-parse-user,
erc-process-away, erc-process-ctcp-query, erc-query-buffer-p,
erc-remove-channel-member, erc-remove-channel-users, erc-remove-user,
erc-sec-to-time, erc-server-buffer, erc-set-active-buffer,
erc-set-current-nick, erc-set-modes, erc-time-diff, erc-trim-string,
erc-update-mode-line, erc-update-mode-line-buffer,
erc-wash-quit-reason, erc-display-message, erc-get-buffer-create,
erc-process-ctcp-reply, erc-update-channel-topic, erc-update-modes,
erc-update-user-nick, erc-open, erc-update-channel-member):
Forward-declare functions.
(erc-response): Move to lisp/erc/erc-common.el.
(erc-compat--with-memoization): Use "erc-compat-" prefixed macro.
* lisp/erc/erc-common.el: New file. Change indentation for
`erc-with-all-buffers-of-server' from 1 to 2.
* lisp/erc/erc-compat.el (erc-compat--with-memoization): Migrate macro
from `erc-backend' and rename.
* lisp/erc/erc-goodies.el: Require `erc-common' instead of `erc'.
(erc-controls-highlight-regexp, erc-controls-remove-regexp,
erc-input-marker, erc-insert-marker, erc-server-process, erc-modules,
erc-log-p): Forward declare variables.
(erc-buffer-list, erc-error, erc-extract-command-from-line):
Forward-declare functions.
* lisp/erc/erc-networks.el (erc--target, erc-insert-marker,
erc-kill-buffer-hook, erc-kill-server-hook, erc-modules,
erc-rename-buffers, erc-reuse-buffers, erc-server-announced-name,
erc-server-connected, erc-server-parameters, erc-server-process,
erc-session-server): Forward declare variables.
(erc--default-target, erc--get-isupport-entry, erc-buffer-filter,
erc-current-nick, erc-display-error-notice, erc-error, erc-get-buffer,
erc-server-buffer, erc-server-process-alive): Forward-declare
functions.
(erc-obsolete-var): Also suppress free-variable warnings.
* lisp/erc/erc.el: Require `erc-networks', `erc-goodies', and
`erc-backend' at top of file. Don't require `erc-compat'.
(erc--server-last-reconnect-count, erc--server-reconnecting,
erc-channel-members-changed-hook, erc-network, erc-networks--id,
erc-server-367-functions, erc-server-announced-name,
erc-server-connect-function, erc-server-connected,
erc-server-current-nick, erc-server-lag, erc-server-last-sent-time,
erc-server-process, erc-server-quitting, erc-server-reconnect-count,
erc-server-reconnecting, erc-session-client-certificate,
erc-session-connector, erc-session-port, erc-session-server,
erc-session-user-full-name) Remove superfluous forward declarations.
(erc-message-parsed, tabbar--local-hlf, motif-version-string):
Relocate forward declares to central location.
(erc-session-password): Move to `erc-backend'.
(erc-downcase, erc-with-server-buffer, erc-server-user,
erc-channel-user, erc-get-channel-user, erc-get-server-user): Move to
lisp/erc/erc-common.el.
(erc-add-server-user, erc-remove-server-user,
erc-channel-user-owner-p, erc-channel-user-admin-p,
erc-channel-user-op-p, erc-channel-user-halfop-p,
erc-channel-user-voice-p): Convert from inline functions to normal
functions.
(define-erc-module, erc--target, erc--target-channel,
erc--target-channel-local, erc-log, erc-log-aux, erc-with-buffer,
erc-with-all-buffers-of-server): Move to lisp/erc/erc-common.el.
(erc-channel-members-changed-hook): Relocate option to avoid compiler
warning.
(erc-input, erc--input-split): Move to lisp/erc/erc-common.el.
(erc-controls-strip): Remove forward declaration temporarily until
this file stops requiring `erc-goodies'.
* test/lisp/erc/erc-networks-tests.el: Require `erc' instead of
`erc-networks'.
* test/lisp/erc/erc.el (erc--meta--backend-dependencies): Remove
obsolete test. Don't require `erc-networks'. Bug#56340.
2022-07-01 11:06:51 -04:00
|
|
|
;;;; Misc 29.1
|
|
|
|
|
2022-07-11 05:14:57 -07:00
|
|
|
(defvar url-irc-function)
|
2022-12-29 06:43:19 -08:00
|
|
|
(declare-function url-type "url-parse" (cl-x))
|
2022-07-11 05:14:57 -07:00
|
|
|
|
|
|
|
(defun erc-compat--29-browse-url-irc (string &rest _)
|
|
|
|
(require 'url-irc)
|
|
|
|
(let* ((url (url-generic-parse-url string))
|
|
|
|
(url-irc-function
|
Make erc-fill-wrap work with left-sided stamps
* etc/ERC-NEWS: Remove all mention of option `erc-timestamp-align-to'
supporting a value of `margin', which has been abandoned. Do mention
leading white space before stamps now having stamp-related properties.
* lisp/erc/erc-backend.el (erc--reveal-prompt, erc--conceal-prompt):
New generic functions with default implementations factored out from
`erc--unhide-prompt' and `erc--hide-prompt'.
(erc--prompt-hidden-p): New internal predicate function.
(erc--unhide-prompt): Defer to `erc--reveal-prompt', and set
`erc-prompt' text property to t.
(erc--hide-prompt): Defer to `erc--conceal-prompt', and set
`erc-prompt' text property to `hidden'.
* lisp/erc/erc-compat.el (erc-compat--29-browse-url-irc): Don't
use `function-equal'.
* lisp/erc/erc-fill.el (erc-fill-wrap-margin-width,
erc-fill-wrap-margin-side): New options to control side and initial
width of `fill-wrap' margin.
(erc-fill--wrap-beginning-of-line): Fix bug involving non-string
valued `display' props.
(erc-fill-wrap-toggle-truncate-lines): New command to re-enable
`visual-line-mode' when toggling off `truncate-lines'.
(erc-fill-wrap-mode-map): Remap `toggle-truncate-lines' to
`erc-fill-wrap-toggle-truncate-lines'.
(erc-fill-wrap-mode, erc-fill-wrap-enable, erc-fill-wrap-disable):
Update doc string, persist a few local vars, and conditionally set
`erc-stamp--margin-left-p'. When deactivating, disable
`visual-line-mode' first.
(erc-fill--wrap-continued-message-p): Use `erc-speaker' instead of
heuristics when comparing nicks between consecutive messages.
(erc-fill-wrap-nudge): Update doc string and account for left-sided
stamps.
(erc-timestamp-offset): Add comment regarding conditional guard based
on function-valued option.
* lisp/erc/erc-stamp.el (erc-timestamp-use-align-to): Remove value
variant `margin', which was originally intended to be new in ERC 5.6.
This functionality was all but useless without the internal minor mode
`erc-stamp--display-margin-mode' active.
(erc-stamp-right-margin-width): Remove unused option new in 5.6.
(erc-stamp--display-margin-force): Remove unused function.
(erc-stamp--margin-width, erc-stamp--margin-left-p): New internal
variables.
(erc-stamp--init-margins-on-connect): New function for initializing
mode-managed margin after connecting.
(erc-stamp--adjust-right-margin, erc-stamp--adjust-margin): Rename
function to latter and accommodate left-hand stamps.
(erc-stamp--inherited-props): Move definition higher up in same file.
(erc-stamp--display-margin-mode): Update function name, and adjust
setup and teardown to accommodate left-handed stamps. Don't add
advice around `erc-insert-timestamp-function'.
(erc-stamp--last-prompt, erc-stamp--display-prompt-in-left-margin):
New function and helper var to convert a normal inserted prompt so
that it appears in the left margin.
(erc-stamp--refresh-left-margin-prompt): Helper for other modules to
quickly refresh prompt outside of insert hooks.
(erc--reveal-prompt, erc--conceal-prompt): New implementations for
when `erc-stamp--display-margin-mode' is active.
(erc-insert-timestamp-left): Convert to generic function and provide
implementation for `erc-stamp--display-margin-mode'.
(erc-stamp--omit-properties-on-folded-lines): New variable, an escape
hatch for propertizing white space before right-side stamps folded
over onto another line.
(erc-insert-timestamp-right): Don't expect `erc-timestamp-align-to' to
ever be the symbol `margin'. Move handling for that case to one
contingent on the internal minor mode `erc-stamp--display-margin-mode'
being active. Add text properties preceding stamps that occupy a line
by their lonesome. See related news entry for rationale. This is
arguably a breaking change.
* lisp/erc/erc.el (erc--refresh-prompt-hook): New hook variable for
modules to adjust prompt properties whenever it's refreshed.
(erc--refresh-prompt): Fix bug in which user-defined prompt functions
failed to hide when quitting in server buffers. Run new hook
`erc--refresh-prompt-hook'.
(erc-display-prompt): Add comment noting that the text property
`erc-prompt' now actually matters: it's t while a session is running
and `hidden' when disconnected.
* test/lisp/erc/erc-fill-tests.el (erc-fill--left-hand-stamps): New
test.
* test/lisp/erc/erc-stamp-tests.el
(erc-stamp-tests--use-align-to--nil,
erc-stamp-tests--use-align-to--t): New functions forged from old test
bodies to allow optionally asserting pre-5.6 behavior regarding
leading white space on right-hand stamps that exist on their own line.
(erc-timestamp-use-align-to--nil, erc-timestamp-use-align-to--t):
Parameterize with compatibility flag.
(erc-timestamp-use-align-to--margin,
erc-stamp--display-margin-mode--right): Rename test to latter.
* test/lisp/erc/erc-tests.el (erc-hide-prompt): Add some assertions
for new possible value of `erc-prompt' text property.
* test/lisp/erc/resources/fill/snapshots/stamps-left-01.eld: New test
data file. (Bug#60936)
2023-07-14 06:12:30 -07:00
|
|
|
(if (eq url-irc-function 'url-irc-erc)
|
2022-07-11 05:14:57 -07:00
|
|
|
(lambda (host port chan user pass)
|
|
|
|
(erc-handle-irc-url host port chan user pass (url-type url)))
|
|
|
|
url-irc-function)))
|
|
|
|
(url-irc url)))
|
|
|
|
|
|
|
|
(cond ((fboundp 'browse-url-irc)) ; 29
|
|
|
|
((boundp 'browse-url-default-handlers) ; 28
|
2022-12-11 19:16:07 -08:00
|
|
|
(add-to-list 'browse-url-default-handlers
|
|
|
|
'("\\`irc6?s?://" . erc-compat--29-browse-url-irc)
|
|
|
|
nil (lambda (_ a)
|
|
|
|
(and (stringp (car-safe a))
|
|
|
|
(string-match-p (car a) "irc://localhost")))))
|
2022-07-11 05:14:57 -07:00
|
|
|
((boundp 'browse-url-browser-function) ; 27
|
|
|
|
(require 'browse-url)
|
|
|
|
(let ((existing browse-url-browser-function))
|
|
|
|
(setq browse-url-browser-function
|
|
|
|
(if (functionp existing)
|
|
|
|
(lambda (u &rest r)
|
|
|
|
(apply (if (string-match-p "\\`irc6?s?://" u)
|
|
|
|
#'erc-compat--29-browse-url-irc
|
|
|
|
existing)
|
|
|
|
u r))
|
|
|
|
(cons '("\\`irc6?s?://" . erc-compat--29-browse-url-irc)
|
|
|
|
existing))))))
|
|
|
|
|
2023-09-18 22:50:28 -07:00
|
|
|
;; We can't store (TICKS . HZ) style timestamps on 27 and 28 because
|
|
|
|
;; `time-less-p' and friends do
|
|
|
|
;;
|
|
|
|
;; message("obsolete timestamp with cdr ...", ...)
|
|
|
|
;; decode_lisp_time(_, WARN_OBSOLETE_TIMESTAMPS, ...)
|
|
|
|
;; lisp_time_struct(...)
|
|
|
|
;; time_cmp(...)
|
|
|
|
;;
|
|
|
|
;; which spams *Messages* (and stderr when running the test suite).
|
|
|
|
(defmacro erc-compat--current-lisp-time ()
|
|
|
|
"Return `current-time' as a (TICKS . HZ) pair on 29+."
|
|
|
|
(if (>= emacs-major-version 29)
|
|
|
|
'(let (current-time-list) (current-time))
|
|
|
|
'(current-time)))
|
|
|
|
|
2021-10-07 14:26:36 +02:00
|
|
|
(defmacro erc-compat--defer-format-spec-in-buffer (&rest spec)
|
|
|
|
"Transform SPEC forms into functions that run in the current buffer.
|
|
|
|
For convenience, ensure function wrappers return \"\" as a
|
|
|
|
fallback."
|
|
|
|
(cl-check-type (car spec) cons)
|
|
|
|
(let ((buffer (make-symbol "buffer")))
|
|
|
|
`(let ((,buffer (current-buffer)))
|
|
|
|
,(list '\`
|
|
|
|
(mapcar
|
|
|
|
(pcase-lambda (`(,k . ,v))
|
|
|
|
(cons k
|
|
|
|
(list '\,(if (>= emacs-major-version 29)
|
|
|
|
`(lambda ()
|
|
|
|
(or (if (eq ,buffer (current-buffer))
|
|
|
|
,v
|
|
|
|
(with-current-buffer ,buffer
|
|
|
|
,v))
|
|
|
|
""))
|
|
|
|
`(or ,v "")))))
|
|
|
|
spec)))))
|
2023-03-25 09:13:40 -07:00
|
|
|
|
2006-01-29 13:08:58 +00:00
|
|
|
(provide 'erc-compat)
|
|
|
|
|
|
|
|
;;; erc-compat.el ends here
|
|
|
|
;;
|
|
|
|
;; Local Variables:
|
Put most erc autoloads in a dedicated file erc-loaddefs.el
These are features that are only useful after erc.el is loaded.
* lisp/erc/erc.el (top-level): Load erc-loaddefs.
* lisp/erc/erc-autoaway.el, lisp/erc/erc-button.el:
* lisp/erc/erc-capab.el, lisp/erc/erc-compat.el:
* lisp/erc/erc-dcc.el, lisp/erc/erc-desktop-notifications.el:
* lisp/erc/erc-ezbounce.el, lisp/erc/erc-fill.el:
* lisp/erc/erc-identd.el, lisp/erc/erc-imenu.el:
* lisp/erc/erc-join.el, lisp/erc/erc-list.el, lisp/erc/erc-log.el:
* lisp/erc/erc-match.el, lisp/erc/erc-menu.el:
* lisp/erc/erc-netsplit.el, lisp/erc/erc-notify.el:
* lisp/erc/erc-page.el, lisp/erc/erc-pcomplete.el:
* lisp/erc/erc-replace.el, lisp/erc/erc-ring.el:
* lisp/erc/erc-services.el, lisp/erc/erc-sound.el:
* lisp/erc/erc-speedbar.el, lisp/erc/erc-spelling.el:
* lisp/erc/erc-stamp.el, lisp/erc/erc-track.el:
* lisp/erc/erc-truncate.el, lisp/erc/erc-xdcc.el:
Set generated-autoload-file to "erc-loaddefs.el".
2017-11-28 21:16:02 -05:00
|
|
|
;; generated-autoload-file: "erc-loaddefs.el"
|
2006-01-29 13:08:58 +00:00
|
|
|
;; End:
|