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 | |
| 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)
| -rw-r--r-- | doc/misc/erc.texi | 129 | ||||
| -rw-r--r-- | lisp/erc/erc-goodies.el | 8 | ||||
| -rw-r--r-- | lisp/erc/erc-nicks.el | 4 | ||||
| -rw-r--r-- | lisp/erc/erc-notify.el | 6 | ||||
| -rw-r--r-- | lisp/erc/erc-sasl.el | 14 | ||||
| -rw-r--r-- | lisp/erc/erc-services.el | 6 | ||||
| -rw-r--r-- | lisp/erc/erc.el | 4 | ||||
| -rw-r--r-- | test/lisp/erc/erc-scenarios-base-local-modules.el | 16 |
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 | |||
| 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. |
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. |
| 373 | Play nice with global module `keep-place' but don't depend on it. | 373 | Play nice with global module `keep-place' but don't depend on it. |
| 374 | Expect that users may want different combinations of `keep-place' | 374 | Expect that users may want different combinations of `keep-place' |
| 375 | and `keep-place-indicator' in different buffers." | 375 | and `keep-place-indicator' in different buffers. |
| 376 | |||
| 377 | This 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." | |||
| 589 | Skip those appearing in `erc-noncommands-list'. | 591 | Skip those appearing in `erc-noncommands-list'. |
| 590 | 592 | ||
| 591 | Users can run \\[erc-command-indicator-toggle-hidden] to hide and | 593 | Users can run \\[erc-command-indicator-toggle-hidden] to hide and |
| 592 | reveal echoed command lines after they've been inserted." | 594 | reveal echoed command lines after they've been inserted. |
| 595 | |||
| 596 | This 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 | |||
| 546 | This 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. | |||
| 299 | Once ERC implements the `monitor' extension, this module will serve as | 299 | Once ERC implements the `monitor' extension, this module will serve as |
| 300 | an optional fallback for keeping query-participant rolls up to date on | 300 | an optional fallback for keeping query-participant rolls up to date on |
| 301 | servers that lack support or are stingy with their allotments. Until | 301 | servers that lack support or are stingy with their allotments. Until |
| 302 | such time, this module should be considered experimental. | 302 | such time, this module should be considered experimental and only really |
| 303 | useful for bots and other non-interactive Lisp programs. | ||
| 303 | 304 | ||
| 304 | This is a local ERC module, so selectively polling only a subset of | 305 | This is a local ERC module, so selectively polling only a subset of |
| 305 | query targets is possible but cumbersome. To do so, ensure | 306 | query targets is possible but cumbersome. To do so, ensure |
| @@ -307,7 +308,8 @@ query targets is possible but cumbersome. To do so, ensure | |||
| 307 | as appropriate in desired query buffers. To stop polling for the | 308 | as appropriate in desired query buffers. To stop polling for the |
| 308 | current connection, toggle off the command \\[erc-querypoll-mode] from a | 309 | current connection, toggle off the command \\[erc-querypoll-mode] from a |
| 309 | server buffer, or run \\`M-x C-u erc-querypoll-disable RET' from a | 310 | server buffer, or run \\`M-x C-u erc-querypoll-disable RET' from a |
| 310 | target buffer." | 311 | target buffer. Note that this module's minor mode must remain active in |
| 312 | at 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. |
| 318 | This doesn't solicit or validate a suite of supported mechanisms." | 311 | This local module only enables its minor mode in server buffers, and it |
| 319 | ;; See bug#49860 for a CAP 3.2-aware WIP implementation. | 312 | doesn'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 | |||
| 613 | somewhat experimental, is likely only useful in conjunction with | 613 | somewhat experimental, is likely only useful in conjunction with |
| 614 | SASL authentication or CertFP rather than the traditional approach | 614 | SASL authentication or CertFP rather than the traditional approach |
| 615 | provided by the `services' module it shares a library with (see Info | 615 | provided by the `services' module it shares a library with (see Info |
| 616 | node `(erc) SASL' for more)." | 616 | node `(erc) SASL' for more). |
| 617 | nil nil localp) | 617 | |
| 618 | This 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 "")) |