diff options
| author | F. Jason Park | 2025-02-04 06:11:50 -0800 |
|---|---|---|
| committer | F. Jason Park | 2025-02-07 20:21:36 -0800 |
| commit | e9408918f4e7fe00eb4e25e1e5428fb26c4ad847 (patch) | |
| tree | 646d187e5252a184e3303fb00dbe1809a093847c /doc/misc | |
| parent | 0e4883f18eecea59e537e2368a0f5674888a1af7 (diff) | |
| download | emacs-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.texi | 129 |
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 | |||
| 452 | Mark unidentified users on freenode and other servers supporting CAPAB. | 452 | Mark 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) |
| 456 | Echo command lines for ``slash commands'', like @kbd{/JOIN #erc} and | 456 | Echo 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 | |||
| 494 | Detect netsplits | 494 | Detect netsplits |
| 495 | 495 | ||
| 496 | @cindex modules, nicks | 496 | @cindex modules, nicks |
| 497 | @item nicks | 497 | @item nicks (local) |
| 498 | Automatically colorize nicks | 498 | Automatically 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 |
| 520 | Process CTCP PAGE requests from IRC | 520 | Process CTCP PAGE requests from IRC |
| 521 | 521 | ||
| 522 | @cindex modules, querypoll | ||
| 523 | @item querypoll | ||
| 524 | Update query participant data by continually polling the server | ||
| 525 | |||
| 526 | @cindex modules, readonly | 522 | @cindex modules, readonly |
| 527 | @item readonly | 523 | @item readonly |
| 528 | Make displayed lines read-only | 524 | Make displayed lines read-only |
| @@ -536,7 +532,7 @@ Replace text in messages | |||
| 536 | Enable an input history | 532 | Enable an input history |
| 537 | 533 | ||
| 538 | @cindex modules, sasl | 534 | @cindex modules, sasl |
| 539 | @item sasl | 535 | @item sasl (local) |
| 540 | Enable SASL authentication | 536 | Enable SASL authentication |
| 541 | 537 | ||
| 542 | @cindex modules, scrolltobottom | 538 | @cindex modules, scrolltobottom |
| @@ -583,22 +579,26 @@ Translate morse code in messages | |||
| 583 | 579 | ||
| 584 | For various reasons, the following modules aren't currently listed in | 580 | For various reasons, the following modules aren't currently listed in |
| 585 | the Custom interface for @code{erc-modules}, but feel free to add them | 581 | the Custom interface for @code{erc-modules}, but feel free to add them |
| 586 | explicitly. They may be managed by another module or considered more | 582 | explicitly. They may be managed by another module or just deemed too |
| 587 | useful when toggled interactively or just deemed experimental. | 583 | niche 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) |
| 593 | Wrap long lines using @code{visual-line-mode} | 589 | Wrap 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) |
| 597 | Remember your place in buffers with a visible reminder; activated | 593 | Remember your place in buffers with a visible reminder; activated |
| 598 | interactively or via something like @code{erc-join-hook} | 594 | interactively or via something like @code{erc-join-hook} |
| 599 | 595 | ||
| 596 | @cindex modules, querypoll | ||
| 597 | @item querypoll (local) | ||
| 598 | Update 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) |
| 602 | Automatically ask NickServ to reclaim your nick when reconnecting; | 602 | Automatically ask NickServ to reclaim your nick when reconnecting; |
| 603 | experimental as of ERC 5.6 | 603 | experimental 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 | ||
| 621 | All modules operate as minor modes under the hood, and some newer ones | 621 | @c Earlier language in code comments, commit messages, and tracker |
| 622 | may 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 |
| 623 | a 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 |
| 624 | change. 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 | |||
| 628 | All modules operate as minor modes under the hood, and newer ones are | ||
| 629 | mostly defined as buffer-local. These so-called @dfn{local modules} are | ||
| 630 | a work in progress, and their behavior and interface are subject to | ||
| 631 | change. 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 |
| 629 | across IRC sessions and override @code{erc-module} membership when | 636 | @code{erc-sasl-mode}, retain their values across IRC sessions. |
| 630 | influencing module activation. | ||
| 631 | @item | 637 | @item |
| 632 | Removing a local module from @code{erc-modules} via Customize not only | 638 | Removing a local module from @code{erc-modules} via Customize not only |
| 633 | disables its mode but also kills its control variable in all ERC | 639 | disables its mode but also kills its mode variable in all ERC buffers. |
| 634 | buffers. | ||
| 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 |
| 638 | differently than their global counterparts. | 643 | than their global counterparts. |
| 639 | @end enumerate | 644 | @end enumerate |
| 640 | 645 | ||
| 641 | In target buffers, a local module's activation state survives | 646 | To detect whether a module is local, examine its mode variable. For |
| 642 | ``reassociation'' by default, but modules themselves always have the | 647 | example, if you run @kbd{C-h v erc-sasl-mode @key{RET}}, you'll notice |
| 643 | final say. For example, a module may reset all instances of itself in | 648 | it says ``Automatically becomes buffer-local when set''. You can do the |
| 644 | its network context upon reconnecting. Moreover, the value of a mode | 649 | same in Lisp code with @code{(local-variable-if-set-p 'erc-sasl-mode)}. |
| 645 | variable may be meaningless in buffers that its module has no interest | 650 | |
| 646 | in. For example, the value of @code{erc-sasl-mode} doesn't matter in | 651 | In an ERC buffer, a local module is either enabled or disabled if its |
| 647 | target buffers and may even remain non-@code{nil} after SASL has been | 652 | mode variable has a local binding. This @dfn{activation state} may |
| 648 | disabled for the current connection (and vice versa). | 653 | contradict a module's presence in @code{erc-modules}, namely, in buffers |
| 649 | 654 | where it isn't applicable or has otherwise been disabled. In fact, a | |
| 650 | When it comes to server buffers, a module's activation state only | 655 | local module's membership in @code{erc-modules} does nothing more than |
| 651 | persists for sessions revived via the automatic reconnection mechanism | 656 | guarantee |
| 652 | or a manual @samp{/reconnect} issued at the prompt. In other words, | 657 | |
| 653 | this doesn't apply to sessions revived by an entry-point command, such | 658 | @enumerate |
| 654 | as @code{erc-tls}, because such commands always ensure a clean slate | 659 | @item |
| 655 | by looking only to @code{erc-modules}. Although a session revived in | 660 | its setup code runs in @emph{new} buffers |
| 656 | this manner may indeed harvest other information from a previous | 661 | @item |
| 657 | server buffer, it simply doesn't care which modules might have been | 662 | its mode variable has a local binding in all affected buffers |
| 658 | active during that connection. | 663 | @end enumerate |
| 659 | 664 | ||
| 660 | Lastly, a local mode's toggle command, like @code{erc-sasl-mode}, only | 665 | In keeping with this, all built-in local modules disable themselves in |
| 661 | affects the current buffer, but its ``non-mode'' cousins, like | 666 | nonapplicable buffers rather than remain no-ops. Some also take strides |
| 667 | to enable themselves elsewhere when needed or at least emit a helpful | ||
| 668 | error. For example, the @samp{nicks} module does both in server | ||
| 669 | buffers, where it shares resources among the target buffers it primarily | ||
| 670 | services. ERC expects third-party local modules to mimic this pattern | ||
| 671 | and to document what buffer types they operate in: server, query, or | ||
| 672 | channel. (In the case of @samp{nicks}, it would be all three: it's | ||
| 673 | @dfn{session-local}.) | ||
| 674 | |||
| 675 | In ERC, you can think of an IRC session as a group of buffers sharing | ||
| 676 | the same connection to a server. After a connection ends, this | ||
| 677 | association endures so that ERC can revive the session when | ||
| 678 | reconnecting. As it does with connection parameters, ERC therefore | ||
| 679 | persists a local module's activation state through reconnections, | ||
| 680 | reenabling modules that were previously active while ensuring others are | ||
| 681 | disabled. A couple related things to note here are | ||
| 682 | |||
| 683 | @enumerate | ||
| 684 | @item | ||
| 685 | each module must manage its own application data and restore or reset | ||
| 686 | its environment accordingly | ||
| 687 | @item | ||
| 688 | session persistence is less predictable if a user changes the makeup of | ||
| 689 | @code{erc-modules} between sessions | ||
| 690 | @end enumerate | ||
| 691 | |||
| 692 | When it comes to a local module's various activation commands, the | ||
| 693 | primary mode command, like @code{erc-sasl-mode}, for example, only | ||
| 694 | affects 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 |
| 663 | buffers belonging to their connection (when called interactively). | 696 | buffers belonging to their connection (when called interactively). And |
| 664 | And unlike global toggles, none of these ever mutates | 697 | unlike 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. |