aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/misc/erc.texi129
-rw-r--r--lisp/erc/erc-goodies.el8
-rw-r--r--lisp/erc/erc-nicks.el4
-rw-r--r--lisp/erc/erc-notify.el6
-rw-r--r--lisp/erc/erc-sasl.el14
-rw-r--r--lisp/erc/erc-services.el6
-rw-r--r--lisp/erc/erc.el4
-rw-r--r--test/lisp/erc/erc-scenarios-base-local-modules.el16
8 files changed, 116 insertions, 71 deletions
diff --git a/doc/misc/erc.texi b/doc/misc/erc.texi
index 7c934d8bb3a..1c0afa3b300 100644
--- a/doc/misc/erc.texi
+++ b/doc/misc/erc.texi
@@ -452,7 +452,7 @@ Buttonize URLs, nicknames, and other text
452Mark unidentified users on freenode and other servers supporting CAPAB. 452Mark unidentified users on freenode and other servers supporting CAPAB.
453 453
454@cindex modules, command-indicator 454@cindex modules, command-indicator
455@item command-indicator 455@item command-indicator (local)
456Echo command lines for ``slash commands'', like @kbd{/JOIN #erc} and 456Echo command lines for ``slash commands'', like @kbd{/JOIN #erc} and
457@kbd{/HELP join} 457@kbd{/HELP join}
458 458
@@ -494,7 +494,7 @@ Display a menu in ERC buffers
494Detect netsplits 494Detect netsplits
495 495
496@cindex modules, nicks 496@cindex modules, nicks
497@item nicks 497@item nicks (local)
498Automatically colorize nicks 498Automatically colorize nicks
499 499
500@cindex modules, nickbar 500@cindex modules, nickbar
@@ -519,10 +519,6 @@ or your nickname is mentioned
519@item page 519@item page
520Process CTCP PAGE requests from IRC 520Process CTCP PAGE requests from IRC
521 521
522@cindex modules, querypoll
523@item querypoll
524Update query participant data by continually polling the server
525
526@cindex modules, readonly 522@cindex modules, readonly
527@item readonly 523@item readonly
528Make displayed lines read-only 524Make displayed lines read-only
@@ -536,7 +532,7 @@ Replace text in messages
536Enable an input history 532Enable an input history
537 533
538@cindex modules, sasl 534@cindex modules, sasl
539@item sasl 535@item sasl (local)
540Enable SASL authentication 536Enable SASL authentication
541 537
542@cindex modules, scrolltobottom 538@cindex modules, scrolltobottom
@@ -583,22 +579,26 @@ Translate morse code in messages
583 579
584For various reasons, the following modules aren't currently listed in 580For various reasons, the following modules aren't currently listed in
585the Custom interface for @code{erc-modules}, but feel free to add them 581the Custom interface for @code{erc-modules}, but feel free to add them
586explicitly. They may be managed by another module or considered more 582explicitly. They may be managed by another module or just deemed too
587useful when toggled interactively or just deemed experimental. 583niche or experimental.
588 584
589@table @code 585@table @code
590 586
591@cindex modules, fill-wrap 587@cindex modules, fill-wrap
592@item fill-wrap 588@item fill-wrap (local)
593Wrap long lines using @code{visual-line-mode} 589Wrap long lines using @code{visual-line-mode}
594 590
595@cindex modules, keep-place-indicator 591@cindex modules, keep-place-indicator
596@item keep-place-indicator 592@item keep-place-indicator (local)
597Remember your place in buffers with a visible reminder; activated 593Remember your place in buffers with a visible reminder; activated
598interactively or via something like @code{erc-join-hook} 594interactively or via something like @code{erc-join-hook}
599 595
596@cindex modules, querypoll
597@item querypoll (local)
598Update query participant data by continually polling the server
599
600@cindex modules, services-regain 600@cindex modules, services-regain
601@item services-regain 601@item services-regain (local)
602Automatically ask NickServ to reclaim your nick when reconnecting; 602Automatically ask NickServ to reclaim your nick when reconnecting;
603experimental as of ERC 5.6 603experimental as of ERC 5.6
604 604
@@ -618,51 +618,84 @@ always loads anyway.
618@subheading Local Modules 618@subheading Local Modules
619@cindex local modules 619@cindex local modules
620 620
621All modules operate as minor modes under the hood, and some newer ones 621@c Earlier language in code comments, commit messages, and tracker
622may be defined as buffer-local. These so-called ``local modules'' are 622@c discussions used to describe a local module as being "active" in a
623a work in progress and their behavior and interface are subject to 623@c buffer if it had a local binding but "disabled" if that binding's
624change. As of ERC 5.5, the only practical differences are as follows: 624@c value was nil. For better or worse, ERC has since abandoned that
625@c distinction and now considers "active" to be synonymous with
626@c "enabled".
627
628All modules operate as minor modes under the hood, and newer ones are
629mostly defined as buffer-local. These so-called @dfn{local modules} are
630a work in progress, and their behavior and interface are subject to
631change. As of ERC 5.6, the only practical differences are as follows:
625 632
626@enumerate 633@enumerate
627@item 634@item
628``Control variables,'' like @code{erc-sasl-mode}, retain their values 635@dfn{Mode variables}, a.k.a. @dfn{control variables}, like
629across IRC sessions and override @code{erc-module} membership when 636@code{erc-sasl-mode}, retain their values across IRC sessions.
630influencing module activation.
631@item 637@item
632Removing a local module from @code{erc-modules} via Customize not only 638Removing a local module from @code{erc-modules} via Customize not only
633disables its mode but also kills its control variable in all ERC 639disables its mode but also kills its mode variable in all ERC buffers.
634buffers.
635@item 640@item
636``Mode toggles,'' like @code{erc-sasl-mode} and the complementary 641@dfn{Mode commands}, like @code{erc-sasl-mode} and its one-way variants
637@code{erc-sasl-enable}/@code{erc-sasl-disable} pairing, behave 642@code{erc-sasl-enable} and @code{erc-sasl-disable}, behave differently
638differently than their global counterparts. 643than their global counterparts.
639@end enumerate 644@end enumerate
640 645
641In target buffers, a local module's activation state survives 646To detect whether a module is local, examine its mode variable. For
642``reassociation'' by default, but modules themselves always have the 647example, if you run @kbd{C-h v erc-sasl-mode @key{RET}}, you'll notice
643final say. For example, a module may reset all instances of itself in 648it says ``Automatically becomes buffer-local when set''. You can do the
644its network context upon reconnecting. Moreover, the value of a mode 649same in Lisp code with @code{(local-variable-if-set-p 'erc-sasl-mode)}.
645variable may be meaningless in buffers that its module has no interest 650
646in. For example, the value of @code{erc-sasl-mode} doesn't matter in 651In an ERC buffer, a local module is either enabled or disabled if its
647target buffers and may even remain non-@code{nil} after SASL has been 652mode variable has a local binding. This @dfn{activation state} may
648disabled for the current connection (and vice versa). 653contradict a module's presence in @code{erc-modules}, namely, in buffers
649 654where it isn't applicable or has otherwise been disabled. In fact, a
650When it comes to server buffers, a module's activation state only 655local module's membership in @code{erc-modules} does nothing more than
651persists for sessions revived via the automatic reconnection mechanism 656guarantee
652or a manual @samp{/reconnect} issued at the prompt. In other words, 657
653this doesn't apply to sessions revived by an entry-point command, such 658@enumerate
654as @code{erc-tls}, because such commands always ensure a clean slate 659@item
655by looking only to @code{erc-modules}. Although a session revived in 660its setup code runs in @emph{new} buffers
656this manner may indeed harvest other information from a previous 661@item
657server buffer, it simply doesn't care which modules might have been 662its mode variable has a local binding in all affected buffers
658active during that connection. 663@end enumerate
659 664
660Lastly, a local mode's toggle command, like @code{erc-sasl-mode}, only 665In keeping with this, all built-in local modules disable themselves in
661affects the current buffer, but its ``non-mode'' cousins, like 666nonapplicable buffers rather than remain no-ops. Some also take strides
667to enable themselves elsewhere when needed or at least emit a helpful
668error. For example, the @samp{nicks} module does both in server
669buffers, where it shares resources among the target buffers it primarily
670services. ERC expects third-party local modules to mimic this pattern
671and to document what buffer types they operate in: server, query, or
672channel. (In the case of @samp{nicks}, it would be all three: it's
673@dfn{session-local}.)
674
675In ERC, you can think of an IRC session as a group of buffers sharing
676the same connection to a server. After a connection ends, this
677association endures so that ERC can revive the session when
678reconnecting. As it does with connection parameters, ERC therefore
679persists a local module's activation state through reconnections,
680reenabling modules that were previously active while ensuring others are
681disabled. A couple related things to note here are
682
683@enumerate
684@item
685each module must manage its own application data and restore or reset
686its environment accordingly
687@item
688session persistence is less predictable if a user changes the makeup of
689@code{erc-modules} between sessions
690@end enumerate
691
692When it comes to a local module's various activation commands, the
693primary mode command, like @code{erc-sasl-mode}, for example, only
694affects the current buffer, but its unidirectional cousins, like
662@code{erc-sasl-enable} and @code{erc-sasl-disable}, operate on all 695@code{erc-sasl-enable} and @code{erc-sasl-disable}, operate on all
663buffers belonging to their connection (when called interactively). 696buffers belonging to their connection (when called interactively). And
664And unlike global toggles, none of these ever mutates 697unlike global toggles, none of these ever mutates @code{erc-modules}.
665@code{erc-modules}. 698
666 699
667@c FIXME add section to Advanced chapter for creating modules, and 700@c FIXME add section to Advanced chapter for creating modules, and
668@c move this there. 701@c move this there.
diff --git a/lisp/erc/erc-goodies.el b/lisp/erc/erc-goodies.el
index cfd0d3415ea..24a3205e0cd 100644
--- a/lisp/erc/erc-goodies.el
+++ b/lisp/erc/erc-goodies.el
@@ -372,7 +372,9 @@ than the indicator's position."
372 "Buffer-local `keep-place' with fringe arrow and/or highlighted face. 372 "Buffer-local `keep-place' with fringe arrow and/or highlighted face.
373Play nice with global module `keep-place' but don't depend on it. 373Play nice with global module `keep-place' but don't depend on it.
374Expect that users may want different combinations of `keep-place' 374Expect that users may want different combinations of `keep-place'
375and `keep-place-indicator' in different buffers." 375and `keep-place-indicator' in different buffers.
376
377This module is local to individual buffers."
376 ((cond (erc-keep-place-mode) 378 ((cond (erc-keep-place-mode)
377 ((memq 'keep-place erc-modules) 379 ((memq 'keep-place erc-modules)
378 (erc-keep-place-mode +1)) 380 (erc-keep-place-mode +1))
@@ -589,7 +591,9 @@ message's speaker."
589Skip those appearing in `erc-noncommands-list'. 591Skip those appearing in `erc-noncommands-list'.
590 592
591Users can run \\[erc-command-indicator-toggle-hidden] to hide and 593Users can run \\[erc-command-indicator-toggle-hidden] to hide and
592reveal echoed command lines after they've been inserted." 594reveal echoed command lines after they've been inserted.
595
596This module is local to individual buffers."
593 ((add-hook 'erc--input-review-functions 597 ((add-hook 'erc--input-review-functions
594 #'erc--command-indicator-permit-insertion 80 t) 598 #'erc--command-indicator-permit-insertion 80 t)
595 (erc-command-indicator-toggle-hidden -1)) 599 (erc-command-indicator-toggle-hidden -1))
diff --git a/lisp/erc/erc-nicks.el b/lisp/erc/erc-nicks.el
index b0629f7754c..a3e9b1f7b46 100644
--- a/lisp/erc/erc-nicks.el
+++ b/lisp/erc/erc-nicks.el
@@ -541,7 +541,9 @@ Abandon search after examining LIMIT faces."
541 nick-object) 541 nick-object)
542 542
543(define-erc-module nicks nil 543(define-erc-module nicks nil
544 "Uniquely colorize nicknames in target buffers." 544 "Uniquely colorize nicknames in target buffers.
545
546This module is local per connection."
545 ((if erc--target 547 ((if erc--target
546 (progn 548 (progn
547 (erc-with-server-buffer 549 (erc-with-server-buffer
diff --git a/lisp/erc/erc-notify.el b/lisp/erc/erc-notify.el
index 82754cb1989..1e04c90177e 100644
--- a/lisp/erc/erc-notify.el
+++ b/lisp/erc/erc-notify.el
@@ -299,7 +299,8 @@ like `nickbar', to provide UI feedback when changes occur.
299Once ERC implements the `monitor' extension, this module will serve as 299Once ERC implements the `monitor' extension, this module will serve as
300an optional fallback for keeping query-participant rolls up to date on 300an optional fallback for keeping query-participant rolls up to date on
301servers that lack support or are stingy with their allotments. Until 301servers that lack support or are stingy with their allotments. Until
302such time, this module should be considered experimental. 302such time, this module should be considered experimental and only really
303useful for bots and other non-interactive Lisp programs.
303 304
304This is a local ERC module, so selectively polling only a subset of 305This is a local ERC module, so selectively polling only a subset of
305query targets is possible but cumbersome. To do so, ensure 306query targets is possible but cumbersome. To do so, ensure
@@ -307,7 +308,8 @@ query targets is possible but cumbersome. To do so, ensure
307as appropriate in desired query buffers. To stop polling for the 308as appropriate in desired query buffers. To stop polling for the
308current connection, toggle off the command \\[erc-querypoll-mode] from a 309current connection, toggle off the command \\[erc-querypoll-mode] from a
309server buffer, or run \\`M-x C-u erc-querypoll-disable RET' from a 310server buffer, or run \\`M-x C-u erc-querypoll-disable RET' from a
310target buffer." 311target buffer. Note that this module's minor mode must remain active in
312at least the server buffer."
311 ((if erc--target 313 ((if erc--target
312 (if (erc-query-buffer-p) 314 (if (erc-query-buffer-p)
313 (progn ; accommodate those who eschew `erc-modules' 315 (progn ; accommodate those who eschew `erc-modules'
diff --git a/lisp/erc/erc-sasl.el b/lisp/erc/erc-sasl.el
index a16f554f2d1..5228fc5e5aa 100644
--- a/lisp/erc/erc-sasl.el
+++ b/lisp/erc/erc-sasl.el
@@ -34,13 +34,6 @@
34;; 34;;
35;; - Implement a proxy mechanism that chooses the strongest available 35;; - Implement a proxy mechanism that chooses the strongest available
36;; mechanism for you. Requires CAP 3.2 (see bug#49860). 36;; mechanism for you. Requires CAP 3.2 (see bug#49860).
37;;
38;; - Integrate with whatever solution ERC eventually settles on to
39;; handle user options for different network contexts. At the
40;; moment, this does its own thing for stashing and restoring
41;; session options, but ERC should make abstractions available for
42;; all local modules to use, possibly based on connection-local
43;; variables.
44 37
45;;; Code: 38;;; Code:
46(require 'erc) 39(require 'erc)
@@ -315,9 +308,10 @@ If necessary, pass PROMPT to `read-passwd'."
315 308
316(define-erc-module sasl nil 309(define-erc-module sasl nil
317 "Non-IRCv3 SASL support for ERC. 310 "Non-IRCv3 SASL support for ERC.
318This doesn't solicit or validate a suite of supported mechanisms." 311This local module only enables its minor mode in server buffers, and it
319 ;; See bug#49860 for a CAP 3.2-aware WIP implementation. 312doesn't currently solicit or validate supported mechanisms."
320 ((unless erc--target 313 ((if erc--target
314 (erc-sasl-mode -1)
321 (setq erc-sasl--state (make-erc-sasl--state)) 315 (setq erc-sasl--state (make-erc-sasl--state))
322 ;; If the previous attempt failed during registration, this may be 316 ;; If the previous attempt failed during registration, this may be
323 ;; non-nil and contain erroneous values, but how can we detect that? 317 ;; non-nil and contain erroneous values, but how can we detect that?
diff --git a/lisp/erc/erc-services.el b/lisp/erc/erc-services.el
index 429424117eb..25da873076e 100644
--- a/lisp/erc/erc-services.el
+++ b/lisp/erc/erc-services.el
@@ -613,8 +613,10 @@ In practical terms, this means that this module, which is still
613somewhat experimental, is likely only useful in conjunction with 613somewhat experimental, is likely only useful in conjunction with
614SASL authentication or CertFP rather than the traditional approach 614SASL authentication or CertFP rather than the traditional approach
615provided by the `services' module it shares a library with (see Info 615provided by the `services' module it shares a library with (see Info
616node `(erc) SASL' for more)." 616node `(erc) SASL' for more).
617 nil nil localp) 617
618This local module's minor mode is only active in server buffers."
619 ((when erc--target (erc-services-regain-mode -1))) nil localp)
618 620
619(cl-defmethod erc--nickname-in-use-make-request 621(cl-defmethod erc--nickname-in-use-make-request
620 ((want string) temp &context (erc-server-connected null) 622 ((want string) temp &context (erc-server-connected null)
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index afa8e0a7b72..0d72b46360e 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -2662,7 +2662,9 @@ side effect of setting the current buffer to the one it returns. Use
2662 (erc--initialize-markers old-point continued-session) 2662 (erc--initialize-markers old-point continued-session)
2663 (erc-determine-parameters server port nick full-name user passwd) 2663 (erc-determine-parameters server port nick full-name user passwd)
2664 (save-excursion (run-mode-hooks) 2664 (save-excursion (run-mode-hooks)
2665 (dolist (mod (car delayed-modules)) (funcall mod +1)) 2665 (dolist (mod (car delayed-modules))
2666 (unless (and (boundp mod) (symbol-value mod))
2667 (funcall mod +1)))
2666 (dolist (var (cdr delayed-modules)) (set var nil))) 2668 (dolist (var (cdr delayed-modules)) (set var nil)))
2667 2669
2668 ;; Saving log file on exit 2670 ;; Saving log file on exit
diff --git a/test/lisp/erc/erc-scenarios-base-local-modules.el b/test/lisp/erc/erc-scenarios-base-local-modules.el
index 71923cc11f2..1d670b8f508 100644
--- a/test/lisp/erc/erc-scenarios-base-local-modules.el
+++ b/test/lisp/erc/erc-scenarios-base-local-modules.el
@@ -117,20 +117,25 @@
117 (erc-cmd-QUIT "") 117 (erc-cmd-QUIT "")
118 (funcall expect 10 "finished"))) 118 (funcall expect 10 "finished")))
119 119
120 (ert-info ("Disabling works from a target buffer") 120 (ert-info ("Explicit disabling affects entire session")
121 ;; Even though the mode variable is nil (but locally bound) in
122 ;; this target buffer, disabling interactively with
123 ;; `erc-sasl-disable', deactivates the module session-wide.
121 (with-current-buffer "#chan" 124 (with-current-buffer "#chan"
122 (should erc-sasl-mode)
123 (call-interactively #'erc-sasl-disable)
124 (should-not erc-sasl-mode) 125 (should-not erc-sasl-mode)
125 (should (local-variable-p 'erc-sasl-mode)) 126 (should (local-variable-p 'erc-sasl-mode))
127 (should (buffer-local-value 'erc-sasl-mode (get-buffer "foonet")))
128 (call-interactively #'erc-sasl-disable)
126 (should-not (buffer-local-value 'erc-sasl-mode (get-buffer "foonet"))) 129 (should-not (buffer-local-value 'erc-sasl-mode (get-buffer "foonet")))
130 (should-not erc-sasl-mode)
127 (erc-cmd-RECONNECT) 131 (erc-cmd-RECONNECT)
128 (funcall expect 10 "Some enigma, some riddle") 132 (funcall expect 10 "Some enigma, some riddle")
129 (should-not erc-sasl-mode) ; regression 133 (should-not erc-sasl-mode)
130 (should (local-variable-p 'erc-sasl-mode))) 134 (should (local-variable-p 'erc-sasl-mode)))
131 135
132 (with-current-buffer "foonet" 136 (with-current-buffer "foonet"
133 (should (local-variable-p 'erc-sasl-mode)) 137 (should (local-variable-p 'erc-sasl-mode))
138 (should-not erc-sasl-mode)
134 (funcall expect 10 "User modes for tester`") 139 (funcall expect 10 "User modes for tester`")
135 (erc-cmd-QUIT "") 140 (erc-cmd-QUIT "")
136 (funcall expect 10 "finished"))) 141 (funcall expect 10 "finished")))
@@ -139,7 +144,8 @@
139 (with-current-buffer "#chan" 144 (with-current-buffer "#chan"
140 (call-interactively #'erc-sasl-enable) 145 (call-interactively #'erc-sasl-enable)
141 (should (local-variable-p 'erc-sasl-mode)) 146 (should (local-variable-p 'erc-sasl-mode))
142 (should erc-sasl-mode) 147 (should-not erc-sasl-mode)
148 (should (buffer-local-value 'erc-sasl-mode (get-buffer "foonet")))
143 (erc-cmd-RECONNECT) 149 (erc-cmd-RECONNECT)
144 (funcall expect 10 "Well met; good morrow, Titus and Hortensius.") 150 (funcall expect 10 "Well met; good morrow, Titus and Hortensius.")
145 (erc-cmd-QUIT "")) 151 (erc-cmd-QUIT ""))