aboutsummaryrefslogtreecommitdiffstats
path: root/doc/misc
diff options
context:
space:
mode:
authorF. Jason Park2025-02-04 06:11:50 -0800
committerF. Jason Park2025-02-07 20:21:36 -0800
commite9408918f4e7fe00eb4e25e1e5428fb26c4ad847 (patch)
tree646d187e5252a184e3303fb00dbe1809a093847c /doc/misc
parent0e4883f18eecea59e537e2368a0f5674888a1af7 (diff)
downloademacs-e9408918f4e7fe00eb4e25e1e5428fb26c4ad847.tar.gz
emacs-e9408918f4e7fe00eb4e25e1e5428fb26c4ad847.zip
More clearly define local module behavior in ERC
* doc/misc/erc.texi (Modules): Label all local modules as being such. Move `querypoll' to the auxiliary section. Rework entire "Local Modules" portion. * lisp/erc/erc-goodies.el (erc-keep-place-indicator-mode) (erc-command-indicator-mode): Mention what buffer types they operate in. * lisp/erc/erc-nicks.el (erc-nicks-mode): Mention the mode is enabled in all buffers. * lisp/erc/erc-notify.el (erc-querypoll-mode): Mention which buffers it operates in. * lisp/erc/erc-sasl.el (erc-sasl-mode): Disable completely in target buffers so its mode variable is nil. * lisp/erc/erc-services.el (erc-services-regain-mode): Disable in target buffers. * lisp/erc/erc.el (erc-open): When activating local modules, skip those that have just been enabled by a fellow module. Do this even though their setup code is meant to be idempotent. * test/lisp/erc/erc-scenarios-base-local-modules.el (erc-scenarios-base-local-modules--toggle-helpers): Revise to assert current behavior. (Bug#57955)
Diffstat (limited to 'doc/misc')
-rw-r--r--doc/misc/erc.texi129
1 files changed, 81 insertions, 48 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.