comparison lisp/erc/erc.el @ 68719:2de3fcf69715

Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55 Creator: Michael Olson <mwolson@gnu.org> Merge from erc--emacs--0
author Miles Bader <miles@gnu.org>
date Wed, 08 Feb 2006 02:41:23 +0000
parents 86c478cccc57
children fe9073ac802e
comparison
equal deleted inserted replaced
68718:c6e88dc95401 68719:2de3fcf69715
1714 1714
1715 (defvar erc-nick-change-attempt-count 0 1715 (defvar erc-nick-change-attempt-count 0
1716 "Used to keep track of how many times an attempt at changing nick is made.") 1716 "Used to keep track of how many times an attempt at changing nick is made.")
1717 (make-variable-buffer-local 'erc-nick-change-attempt-count) 1717 (make-variable-buffer-local 'erc-nick-change-attempt-count)
1718 1718
1719 (defun erc-migrate-modules (mods)
1720 "Migrate old names of ERC modules to new ones."
1721 ;; modify `transforms' to specify what needs to be changed
1722 ;; each item is in the format '(new .old)
1723 (let ((transforms '((pcomplete . completion)))
1724 (modules (copy-alist mods)))
1725 (dolist (transform transforms)
1726 (let ((addp nil))
1727 (setq modules (erc-delete-if `(lambda (val)
1728 (and (eq val ',(car transform))
1729 (setq addition t)))
1730 modules))
1731 (when addp
1732 (add-to-list 'modules (cdr transform)))))
1733 (erc-delete-dups modules)))
1734
1719 (defcustom erc-modules '(netsplit fill button match track pcomplete readonly 1735 (defcustom erc-modules '(netsplit fill button match track pcomplete readonly
1720 ring autojoin noncommands irccontrols 1736 ring autojoin noncommands irccontrols
1721 stamp) 1737 stamp)
1722 "A list of modules which erc should enable. 1738 "A list of modules which erc should enable.
1723 If you set the value of this without using `customize' remember to call 1739 If you set the value of this without using `customize' remember to call
1724 \(erc-update-modules) after you change it. When using `customize', modules 1740 \(erc-update-modules) after you change it. When using `customize', modules
1725 removed from the list will be disabled." 1741 removed from the list will be disabled."
1742 :get (lambda (sym)
1743 ;; replace outdated names with their newer equivalents
1744 (erc-migrate-modules (symbol-value sym)))
1726 :set (lambda (sym val) 1745 :set (lambda (sym val)
1727 ;; disable modules which have just been removed 1746 ;; disable modules which have just been removed
1728 (when (and (boundp 'erc-modules) erc-modules val) 1747 (when (and (boundp 'erc-modules) erc-modules val)
1729 (dolist (module erc-modules) 1748 (dolist (module erc-modules)
1730 (unless (member module val) 1749 (unless (member module val)
1731 (let ((f (intern-soft (format "erc-%s-mode" module)))) 1750 (let ((f (intern-soft (format "erc-%s-mode" module))))
1732 (when (and (fboundp f) (boundp f) (symbol-value f)) 1751 (when (and (fboundp f) (boundp f) (symbol-value f))
1733 (message "Disabling `erc-%s'" module) 1752 (message "Disabling `erc-%s'" module)
1734 (funcall f 0)))))) 1753 (funcall f 0))))))
1735 (set-default sym val) 1754 (set sym val)
1736 ;; this test is for the case where erc hasn't been loaded yet 1755 ;; this test is for the case where erc hasn't been loaded yet
1737 (when (fboundp 'erc-update-modules) 1756 (when (fboundp 'erc-update-modules)
1738 (erc-update-modules))) 1757 (erc-update-modules)))
1739 :type '(set :greedy t 1758 :type '(set :greedy t
1740 (const :tag "Set away status automatically" autoaway) 1759 (const :tag "Set away status automatically" autoaway)
1751 noncommands) 1770 noncommands)
1752 (const :tag 1771 (const :tag
1753 "Notify when the online status of certain users changes" 1772 "Notify when the online status of certain users changes"
1754 notify) 1773 notify)
1755 (const :tag "Complete nicknames and commands (programmable)" 1774 (const :tag "Complete nicknames and commands (programmable)"
1756 pcomplete) 1775 completion)
1757 (const :tag "Complete nicknames and commands (old)" completion) 1776 (const :tag "Complete nicknames and commands (old)" hecomplete)
1758 (const :tag "Make displayed lines read-only" readonly) 1777 (const :tag "Make displayed lines read-only" readonly)
1759 (const :tag "Replace text in messages" replace) 1778 (const :tag "Replace text in messages" replace)
1760 (const :tag "Enable an input history" ring) 1779 (const :tag "Enable an input history" ring)
1761 (const :tag "Scroll to the bottom of the buffer" scrolltobottom) 1780 (const :tag "Scroll to the bottom of the buffer" scrolltobottom)
1762 (const :tag "Identify to Nickserv (IRC Services) automatically" 1781 (const :tag "Identify to Nickserv (IRC Services) automatically"
1779 (setq req (concat "erc-" (symbol-name mod))) 1798 (setq req (concat "erc-" (symbol-name mod)))
1780 (cond 1799 (cond
1781 ;; yuck. perhaps we should bring the filenames into sync? 1800 ;; yuck. perhaps we should bring the filenames into sync?
1782 ((string= req "erc-completion") 1801 ((string= req "erc-completion")
1783 (setq req "erc-pcomplete") 1802 (setq req "erc-pcomplete")
1784 (setq mod 'pcomplete)) 1803 (setq mod 'completion))
1785 ((string= req "erc-services") 1804 ((string= req "erc-pcomplete")
1786 (setq req "erc-nickserv") 1805 (setq req "erc-pcomplete")
1787 (setq mod 'services))) 1806 (setq mod 'completion))
1807 ((string= req "erc-autojoin")
1808 (setq req "erc-join")
1809 (setq mod 'autojoin)))
1788 (condition-case nil 1810 (condition-case nil
1789 (require (intern req)) 1811 (require (intern req))
1790 (error nil)) 1812 (error nil))
1791 (funcall (or (intern-soft (concat "erc-" (symbol-name mod) "-mode")) 1813 (funcall (or (intern-soft (concat "erc-" (symbol-name mod) "-mode"))
1792 (error "`%s' is not a known ERC module" mod)) 1814 (error "`%s' is not a known ERC module" mod))
3138 3160
3139 (defun erc-cmd-SM () 3161 (defun erc-cmd-SM ()
3140 "Say the current ERC modes into channel." 3162 "Say the current ERC modes into channel."
3141 (erc-send-message (format "I'm using the following modules: %s!" 3163 (erc-send-message (format "I'm using the following modules: %s!"
3142 (erc-modes))) 3164 (erc-modes)))
3143 t)
3144
3145 (defun erc-cmd-SMV ()
3146 "Say the current ERC module versions into channel."
3147 (erc-send-message (format "I'm using the following module revisions: %s!"
3148 (erc-version-modules)))
3149 t) 3165 t)
3150 3166
3151 (defun erc-cmd-DEOP (&rest people) 3167 (defun erc-cmd-DEOP (&rest people)
3152 "Remove the operator setting from user(s) given in PEOPLE." 3168 "Remove the operator setting from user(s) given in PEOPLE."
3153 (when (> (length people) 0) 3169 (when (> (length people) 0)