| 1001 | | ;;;_ > allout-resumptions (name &optional value) |
|---|
| 1002 | | (defun allout-resumptions (name &optional value) |
|---|
| 1003 | | |
|---|
| 1004 | | "Registers or resumes settings over `allout-mode' activation/deactivation. |
|---|
| 1005 | | |
|---|
| 1006 | | First arg is NAME of variable affected. Optional second arg is list |
|---|
| 1007 | | containing allout-mode-specific VALUE to be imposed on named |
|---|
| 1008 | | variable, and to be registered. \(It's a list so you can specify |
|---|
| 1009 | | registrations of null values.) If no value is specified, the |
|---|
| 1010 | | registered value is returned (encapsulated in the list, so the caller |
|---|
| 1011 | | can distinguish nil vs no value), and the registration is popped |
|---|
| 1012 | | from the list." |
|---|
| 1013 | | |
|---|
| 1014 | | (let ((on-list (assq name allout-mode-prior-settings)) |
|---|
| 1015 | | prior-capsule ; By `capsule' i mean a list |
|---|
| 1016 | | ; containing a value, so we can |
|---|
| 1017 | | ; distinguish nil from no value. |
|---|
| 1018 | | ) |
|---|
| 1019 | | |
|---|
| 1020 | | (if value |
|---|
| 1021 | | |
|---|
| 1022 | | ;; Registering: |
|---|
| 1023 | | (progn |
|---|
| 1024 | | (if on-list |
|---|
| 1025 | | nil ; Already preserved prior value - don't mess with it. |
|---|
| 1026 | | ;; Register the old value, or nil if previously unbound: |
|---|
| 1027 | | (setq allout-mode-prior-settings |
|---|
| 1028 | | (cons (list name |
|---|
| 1029 | | (if (boundp name) (list (symbol-value name)))) |
|---|
| 1030 | | allout-mode-prior-settings))) |
|---|
| 1031 | | ; And impose the new value, locally: |
|---|
| 1032 | | (progn (make-local-variable name) |
|---|
| 1033 | | (set name (car value)))) |
|---|
| 1034 | | |
|---|
| 1035 | | ;; Relinquishing: |
|---|
| 1036 | | (if (not on-list) |
|---|
| 1037 | | |
|---|
| 1038 | | ;; Oops, not registered - leave it be: |
|---|
| 1039 | | nil |
|---|
| 1040 | | |
|---|
| 1041 | | ;; Some registration: |
|---|
| 1042 | | ; reestablish it: |
|---|
| 1043 | | (setq prior-capsule (car (cdr on-list))) |
|---|
| 1044 | | (if prior-capsule |
|---|
| 1045 | | (set name (car prior-capsule)) ; Some prior value - reestablish it. |
|---|
| 1046 | | (makunbound name)) ; Previously unbound - demolish var. |
|---|
| 1047 | | ; Remove registration: |
|---|
| 1048 | | (let (rebuild) |
|---|
| 1049 | | (while allout-mode-prior-settings |
|---|
| 1050 | | (if (not (eq (car allout-mode-prior-settings) |
|---|
| 1051 | | on-list)) |
|---|
| 1052 | | (setq rebuild |
|---|
| 1053 | | (cons (car allout-mode-prior-settings) |
|---|
| 1054 | | rebuild))) |
|---|
| 1055 | | (setq allout-mode-prior-settings |
|---|
| 1056 | | (cdr allout-mode-prior-settings))) |
|---|
| 1057 | | (setq allout-mode-prior-settings rebuild))))) |
|---|
| 1058 | | ) |
|---|
| | 1051 | ;;;_ > allout-add-resumptions (&rest pairs) |
|---|
| | 1052 | (defun allout-add-resumptions (&rest pairs) |
|---|
| | 1053 | "Set name/value pairs. |
|---|
| | 1054 | |
|---|
| | 1055 | Old settings are preserved for later resumption using `allout-do-resumptions'. |
|---|
| | 1056 | |
|---|
| | 1057 | The pairs are lists whose car is the name of the variable and car of the |
|---|
| | 1058 | cdr is the new value: '(some-var some-value)'. |
|---|
| | 1059 | |
|---|
| | 1060 | The new value is set as a buffer local. |
|---|
| | 1061 | |
|---|
| | 1062 | If the variable was not previously buffer-local, then that is noted and the |
|---|
| | 1063 | `allout-do-resumptions' will just `kill-local-variable' of that binding. |
|---|
| | 1064 | |
|---|
| | 1065 | If it previously was buffer-local, the old value is noted and resurrected |
|---|
| | 1066 | by `allout-do-resumptions'. \(If the local value was previously void, then |
|---|
| | 1067 | it is left as nil on resumption.\) |
|---|
| | 1068 | |
|---|
| | 1069 | The settings are stored on `allout-mode-prior-settings'." |
|---|
| | 1070 | (while pairs |
|---|
| | 1071 | (let* ((pair (pop pairs)) |
|---|
| | 1072 | (name (car pair)) |
|---|
| | 1073 | (value (cadr pair))) |
|---|
| | 1074 | (if (not (symbolp name)) |
|---|
| | 1075 | (error "Pair's name, %S, must be a symbol, not %s" |
|---|
| | 1076 | name (type-of name))) |
|---|
| | 1077 | (when (not (assoc name allout-mode-prior-settings)) |
|---|
| | 1078 | ;; Not already added as a resumption, create the prior setting entry. |
|---|
| | 1079 | (if (local-variable-p name) |
|---|
| | 1080 | ;; is already local variable - preserve the prior value: |
|---|
| | 1081 | (push (list name (condition-case err |
|---|
| | 1082 | (symbol-value name) |
|---|
| | 1083 | (void-variable nil))) |
|---|
| | 1084 | allout-mode-prior-settings) |
|---|
| | 1085 | ;; wasn't local variable, indicate so for resumption by killing |
|---|
| | 1086 | ;; local value, and make it local: |
|---|
| | 1087 | (push (list name) allout-mode-prior-settings) |
|---|
| | 1088 | (make-local-variable name))) |
|---|
| | 1089 | (set name value)))) |
|---|
| | 1090 | ;;;_ > allout-do-resumptions () |
|---|
| | 1091 | (defun allout-do-resumptions () |
|---|
| | 1092 | "Resume all name/value settings registered by `allout-add-resumptions'. |
|---|
| | 1093 | |
|---|
| | 1094 | This is used when concluding allout-mode, to resume selected variables to |
|---|
| | 1095 | their settings before allout-mode was started." |
|---|
| | 1096 | |
|---|
| | 1097 | (while allout-mode-prior-settings |
|---|
| | 1098 | (let* ((pair (pop allout-mode-prior-settings)) |
|---|
| | 1099 | (name (car pair)) |
|---|
| | 1100 | (value-cell (cdr pair))) |
|---|
| | 1101 | (if (not value-cell) |
|---|
| | 1102 | ;; Prior value was global: |
|---|
| | 1103 | (kill-local-variable name) |
|---|
| | 1104 | ;; Prior value was explicit: |
|---|
| | 1105 | (set name (car value-cell)))))) |
|---|
| 1626 | | ; Produce map from current version |
|---|
| 1627 | | ; of allout-keybindings-list: |
|---|
| 1628 | | (if (boundp 'minor-mode-map-alist) |
|---|
| 1629 | | |
|---|
| 1630 | | (progn ; V19, and maybe lucid and |
|---|
| 1631 | | ; epoch, minor-mode key bindings: |
|---|
| 1632 | | (setq allout-mode-map |
|---|
| 1633 | | (produce-allout-mode-map allout-keybindings-list)) |
|---|
| 1634 | | (substitute-key-definition 'beginning-of-line |
|---|
| 1635 | | 'move-beginning-of-line |
|---|
| 1636 | | allout-mode-map global-map) |
|---|
| 1637 | | (substitute-key-definition 'end-of-line |
|---|
| 1638 | | 'move-end-of-line |
|---|
| 1639 | | allout-mode-map global-map) |
|---|
| 1640 | | (produce-allout-mode-menubar-entries) |
|---|
| 1641 | | (fset 'allout-mode-map allout-mode-map) |
|---|
| 1642 | | ; Include on minor-mode-map-alist, |
|---|
| 1643 | | ; if not already there: |
|---|
| 1644 | | (if (not (member '(allout-mode . allout-mode-map) |
|---|
| 1645 | | minor-mode-map-alist)) |
|---|
| 1646 | | (setq minor-mode-map-alist |
|---|
| 1647 | | (cons '(allout-mode . allout-mode-map) |
|---|
| 1648 | | minor-mode-map-alist)))) |
|---|
| 1649 | | |
|---|
| 1650 | | ; V18 minor-mode key bindings: |
|---|
| 1651 | | ; Stash record of added bindings |
|---|
| 1652 | | ; for later revocation: |
|---|
| 1653 | | (allout-resumptions 'allout-added-bindings |
|---|
| 1654 | | (list allout-keybindings-list)) |
|---|
| 1655 | | (allout-resumptions 'allout-prior-bindings |
|---|
| 1656 | | (list (current-local-map))) |
|---|
| 1657 | | ; and add them: |
|---|
| 1658 | | (use-local-map (produce-allout-mode-map allout-keybindings-list |
|---|
| 1659 | | (current-local-map))) |
|---|
| 1660 | | ) |
|---|
| | 1657 | ;; Produce map from current version of allout-keybindings-list: |
|---|
| | 1658 | (setq allout-mode-map |
|---|
| | 1659 | (produce-allout-mode-map allout-keybindings-list)) |
|---|
| | 1660 | (substitute-key-definition 'beginning-of-line |
|---|
| | 1661 | 'move-beginning-of-line |
|---|
| | 1662 | allout-mode-map global-map) |
|---|
| | 1663 | (substitute-key-definition 'end-of-line |
|---|
| | 1664 | 'move-end-of-line |
|---|
| | 1665 | allout-mode-map global-map) |
|---|
| | 1666 | (produce-allout-mode-menubar-entries) |
|---|
| | 1667 | (fset 'allout-mode-map allout-mode-map) |
|---|
| | 1668 | |
|---|
| | 1669 | ;; Include on minor-mode-map-alist, if not already there: |
|---|
| | 1670 | (if (not (member '(allout-mode . allout-mode-map) |
|---|
| | 1671 | minor-mode-map-alist)) |
|---|
| | 1672 | (setq minor-mode-map-alist |
|---|
| | 1673 | (cons '(allout-mode . allout-mode-map) |
|---|
| | 1674 | minor-mode-map-alist))) |
|---|
| 1663 | | (make-local-variable 'line-move-ignore-invisible) |
|---|
| 1664 | | (setq line-move-ignore-invisible t) |
|---|
| 1665 | | (add-hook 'pre-command-hook 'allout-pre-command-business) |
|---|
| 1666 | | (add-hook 'post-command-hook 'allout-post-command-business) |
|---|
| 1667 | | (add-hook 'isearch-mode-end-hook 'allout-isearch-end-handler) |
|---|
| 1668 | | (add-hook write-file-hook-var-name 'allout-write-file-hook-handler) |
|---|
| 1669 | | (add-hook 'auto-save-hook 'allout-auto-save-hook-handler) |
|---|
| 1670 | | ; Custom auto-fill func, to support |
|---|
| 1671 | | ; respect for topic headline, |
|---|
| 1672 | | ; hanging-indents, etc: |
|---|
| 1673 | | ;; Register prevailing fill func for use by allout-auto-fill: |
|---|
| 1674 | | (allout-resumptions 'allout-former-auto-filler (list auto-fill-function)) |
|---|
| 1675 | | ;; Register allout-auto-fill to be used if filling is active: |
|---|
| 1676 | | (allout-resumptions 'auto-fill-function '(allout-auto-fill)) |
|---|
| 1677 | | (allout-resumptions 'allout-outside-normal-auto-fill-function |
|---|
| 1678 | | (list normal-auto-fill-function)) |
|---|
| 1679 | | (allout-resumptions 'normal-auto-fill-function '(allout-auto-fill)) |
|---|
| 1680 | | ;; Paragraphs are broken by topic headlines. |
|---|
| 1681 | | (make-local-variable 'paragraph-start) |
|---|
| 1682 | | (allout-resumptions 'paragraph-start |
|---|
| 1683 | | (list (concat paragraph-start "\\|^\\(" |
|---|
| 1684 | | allout-regexp "\\)"))) |
|---|
| 1685 | | (make-local-variable 'paragraph-separate) |
|---|
| 1686 | | (allout-resumptions 'paragraph-separate |
|---|
| 1687 | | (list (concat paragraph-separate "\\|^\\(" |
|---|
| 1688 | | allout-regexp "\\)"))) |
|---|
| 1689 | | |
|---|
| | 1677 | (allout-add-resumptions '(line-move-ignore-invisible t)) |
|---|
| | 1678 | (add-hook 'pre-command-hook 'allout-pre-command-business nil t) |
|---|
| | 1679 | (add-hook 'post-command-hook 'allout-post-command-business nil t) |
|---|
| | 1680 | (when (featurep 'xemacs) |
|---|
| | 1681 | (add-hook 'before-change-functions 'allout-before-change-handler |
|---|
| | 1682 | nil t)) |
|---|
| | 1683 | (add-hook 'isearch-mode-end-hook 'allout-isearch-end-handler nil t) |
|---|
| | 1684 | (add-hook write-file-hook-var-name 'allout-write-file-hook-handler |
|---|
| | 1685 | nil t) |
|---|
| | 1686 | (add-hook 'auto-save-hook 'allout-auto-save-hook-handler |
|---|
| | 1687 | nil t) |
|---|
| | 1688 | |
|---|
| | 1689 | ;; Stash auto-fill settings and adjust so custom allout auto-fill |
|---|
| | 1690 | ;; func will be used if auto-fill is active or activated. (The |
|---|
| | 1691 | ;; custom func respects topic headline, maintains hanging-indents, |
|---|
| | 1692 | ;; etc.) |
|---|
| | 1693 | (if (and auto-fill-function (not allout-inhibit-auto-fill)) |
|---|
| | 1694 | ;; allout-auto-fill will use the stashed values and so forth. |
|---|
| | 1695 | (allout-add-resumptions '(auto-fill-function allout-auto-fill))) |
|---|
| | 1696 | (allout-add-resumptions (list 'allout-former-auto-filler |
|---|
| | 1697 | auto-fill-function) |
|---|
| | 1698 | ;; Register allout-auto-fill to be used if |
|---|
| | 1699 | ;; filling is active: |
|---|
| | 1700 | (list 'allout-outside-normal-auto-fill-function |
|---|
| | 1701 | normal-auto-fill-function) |
|---|
| | 1702 | '(normal-auto-fill-function allout-auto-fill) |
|---|
| | 1703 | ;; Paragraphs are broken by topic headlines. |
|---|
| | 1704 | (list 'paragraph-start |
|---|
| | 1705 | (concat paragraph-start "\\|^\\(" |
|---|
| | 1706 | allout-regexp "\\)")) |
|---|
| | 1707 | (list 'paragraph-separate |
|---|
| | 1708 | (concat paragraph-separate "\\|^\\(" |
|---|
| | 1709 | allout-regexp "\\)"))) |
|---|
| 2694 | | (let* ((this-key-num (cond |
|---|
| 2695 | | ((numberp last-command-char) |
|---|
| 2696 | | last-command-char) |
|---|
| 2697 | | ;; Only xemacs has characterp. |
|---|
| 2698 | | ((and (fboundp 'characterp) |
|---|
| 2699 | | (apply 'characterp |
|---|
| 2700 | | (list last-command-char))) |
|---|
| 2701 | | (apply 'char-to-int (list last-command-char))) |
|---|
| 2702 | | (t 0))) |
|---|
| 2703 | | mapped-binding) |
|---|
| 2704 | | (if (zerop this-key-num) |
|---|
| 2705 | | nil |
|---|
| 2706 | | ; Map upper-register literals |
|---|
| 2707 | | ; to lower register: |
|---|
| 2708 | | (if (<= 96 this-key-num) |
|---|
| 2709 | | (setq this-key-num (- this-key-num 32))) |
|---|
| 2710 | | ; Check if we have a literal: |
|---|
| 2711 | | (if (and (<= 64 this-key-num) |
|---|
| 2712 | | (>= 96 this-key-num)) |
|---|
| 2713 | | (setq mapped-binding |
|---|
| 2714 | | (lookup-key 'allout-mode-map |
|---|
| 2715 | | (concat allout-command-prefix |
|---|
| 2716 | | (char-to-string (- this-key-num |
|---|
| 2717 | | 64)))))) |
|---|
| 2718 | | (if mapped-binding |
|---|
| 2719 | | (setq allout-post-goto-bullet t |
|---|
| 2720 | | this-command mapped-binding))))))) |
|---|
| | 2719 | (allout-hotspot-key-handler)))) |
|---|
| | 2720 | ;;;_ > allout-hotspot-key-handler () |
|---|
| | 2721 | (defun allout-hotspot-key-handler () |
|---|
| | 2722 | "Catchall handling of key bindings in hot-spots. |
|---|
| | 2723 | |
|---|
| | 2724 | Translates unmodified keystrokes to corresponding allout commands, when |
|---|
| | 2725 | they would qualify if prefixed with the allout-command-prefix, and sets |
|---|
| | 2726 | this-command accordingly. |
|---|
| | 2727 | |
|---|
| | 2728 | Returns the qualifying command, if any, else nil." |
|---|
| | 2729 | (interactive) |
|---|
| | 2730 | (let* ((key-num (cond ((numberp last-command-char) last-command-char) |
|---|
| | 2731 | ;; for XEmacs character type: |
|---|
| | 2732 | ((and (fboundp 'characterp) |
|---|
| | 2733 | (apply 'characterp (list last-command-char))) |
|---|
| | 2734 | (apply 'char-to-int (list last-command-char))) |
|---|
| | 2735 | (t 0))) |
|---|
| | 2736 | mapped-binding |
|---|
| | 2737 | (on-bullet (eq (point) (allout-current-bullet-pos)))) |
|---|
| | 2738 | |
|---|
| | 2739 | (if (zerop key-num) |
|---|
| | 2740 | nil |
|---|
| | 2741 | |
|---|
| | 2742 | (if (and (<= 33 key-num) |
|---|
| | 2743 | (setq mapped-binding |
|---|
| | 2744 | (key-binding (concat allout-command-prefix |
|---|
| | 2745 | (char-to-string |
|---|
| | 2746 | (if (and (<= 97 key-num) ; "a" |
|---|
| | 2747 | (>= 122 key-num)) ; "z" |
|---|
| | 2748 | (- key-num 96) key-num))) |
|---|
| | 2749 | t))) |
|---|
| | 2750 | ;; Qualified with the allout prefix - do hot-spot operation. |
|---|
| | 2751 | (setq allout-post-goto-bullet t) |
|---|
| | 2752 | ;; accept-defaults nil, or else we'll get allout-item-icon-key-handler. |
|---|
| | 2753 | (setq mapped-binding (key-binding (char-to-string key-num)))) |
|---|
| | 2754 | |
|---|
| | 2755 | (while (keymapp mapped-binding) |
|---|
| | 2756 | (setq mapped-binding |
|---|
| | 2757 | (lookup-key mapped-binding (read-key-sequence-vector nil t)))) |
|---|
| | 2758 | |
|---|
| | 2759 | (if mapped-binding |
|---|
| | 2760 | (setq allout-post-goto-bullet on-bullet |
|---|
| | 2761 | this-command mapped-binding))))) |
|---|
| | 2762 | |
|---|
| 5922 | | ;;;_ #11 Provide |
|---|
| | 5967 | ;;;_ #11 Unit tests - this should be last item before "Provide" |
|---|
| | 5968 | ;;;_ > allout-run-unit-tests () |
|---|
| | 5969 | (defun allout-run-unit-tests () |
|---|
| | 5970 | "Run the various allout unit tests." |
|---|
| | 5971 | (message "Running allout tests...") |
|---|
| | 5972 | (allout-test-resumptions) |
|---|
| | 5973 | (message "Running allout tests... Done.") |
|---|
| | 5974 | (sit-for .5)) |
|---|
| | 5975 | ;;;_ : test resumptions: |
|---|
| | 5976 | ;;;_ > allout-tests-obliterate-variable (name) |
|---|
| | 5977 | (defun allout-tests-obliterate-variable (name) |
|---|
| | 5978 | "Completely unbind variable with NAME." |
|---|
| | 5979 | (if (local-variable-p name) (kill-local-variable name)) |
|---|
| | 5980 | (while (boundp name) (makunbound name))) |
|---|
| | 5981 | ;;;_ > allout-test-resumptions () |
|---|
| | 5982 | (defvar allout-tests-globally-unbound nil |
|---|
| | 5983 | "Fodder for allout resumptions tests - defvar just for byte compiler.") |
|---|
| | 5984 | (defvar allout-tests-globally-true nil |
|---|
| | 5985 | "Fodder for allout resumptions tests - defvar just just for byte compiler.") |
|---|
| | 5986 | (defvar allout-tests-locally-true nil |
|---|
| | 5987 | "Fodder for allout resumptions tests - defvar just for byte compiler.") |
|---|
| | 5988 | (defun allout-test-resumptions () |
|---|
| | 5989 | "Exercise allout resumptions." |
|---|
| | 5990 | ;; for each resumption case, we also test that the right local/global |
|---|
| | 5991 | ;; scopes are affected during resumption effects: |
|---|
| | 5992 | |
|---|
| | 5993 | ;; ensure that previously unbound variables return to the unbound state. |
|---|
| | 5994 | (with-temp-buffer |
|---|
| | 5995 | (allout-tests-obliterate-variable 'allout-tests-globally-unbound) |
|---|
| | 5996 | (allout-add-resumptions '(allout-tests-globally-unbound t)) |
|---|
| | 5997 | (assert (not (default-boundp 'allout-tests-globally-unbound))) |
|---|
| | 5998 | (assert (local-variable-p 'allout-tests-globally-unbound)) |
|---|
| | 5999 | (assert (boundp 'allout-tests-globally-unbound)) |
|---|
| | 6000 | (assert (equal allout-tests-globally-unbound t)) |
|---|
| | 6001 | (allout-do-resumptions) |
|---|
| | 6002 | (assert (not (local-variable-p 'allout-tests-globally-unbound))) |
|---|
| | 6003 | (assert (not (boundp 'allout-tests-globally-unbound)))) |
|---|
| | 6004 | |
|---|
| | 6005 | ;; ensure that variable with prior global value is resumed |
|---|
| | 6006 | (with-temp-buffer |
|---|
| | 6007 | (allout-tests-obliterate-variable 'allout-tests-globally-true) |
|---|
| | 6008 | (setq allout-tests-globally-true t) |
|---|
| | 6009 | (allout-add-resumptions '(allout-tests-globally-true nil)) |
|---|
| | 6010 | (assert (equal (default-value 'allout-tests-globally-true) t)) |
|---|
| | 6011 | (assert (local-variable-p 'allout-tests-globally-true)) |
|---|
| | 6012 | (assert (equal allout-tests-globally-true nil)) |
|---|
| | 6013 | (allout-do-resumptions) |
|---|
| | 6014 | (assert (not (local-variable-p 'allout-tests-globally-true))) |
|---|
| | 6015 | (assert (boundp 'allout-tests-globally-true)) |
|---|
| | 6016 | (assert (equal allout-tests-globally-true t))) |
|---|
| | 6017 | |
|---|
| | 6018 | ;; ensure that prior local value is resumed |
|---|
| | 6019 | (with-temp-buffer |
|---|
| | 6020 | (allout-tests-obliterate-variable 'allout-tests-locally-true) |
|---|
| | 6021 | (set (make-local-variable 'allout-tests-locally-true) t) |
|---|
| | 6022 | (assert (not (default-boundp 'allout-tests-locally-true)) |
|---|
| | 6023 | nil (concat "Test setup mistake - variable supposed to" |
|---|
| | 6024 | " not have global binding, but it does.")) |
|---|
| | 6025 | (assert (local-variable-p 'allout-tests-locally-true) |
|---|
| | 6026 | nil (concat "Test setup mistake - variable supposed to have" |
|---|
| | 6027 | " local binding, but it lacks one.")) |
|---|
| | 6028 | (allout-add-resumptions '(allout-tests-locally-true nil)) |
|---|
| | 6029 | (assert (not (default-boundp 'allout-tests-locally-true))) |
|---|
| | 6030 | (assert (local-variable-p 'allout-tests-locally-true)) |
|---|
| | 6031 | (assert (equal allout-tests-locally-true nil)) |
|---|
| | 6032 | (allout-do-resumptions) |
|---|
| | 6033 | (assert (boundp 'allout-tests-locally-true)) |
|---|
| | 6034 | (assert (local-variable-p 'allout-tests-locally-true)) |
|---|
| | 6035 | (assert (equal allout-tests-locally-true t)) |
|---|
| | 6036 | (assert (not (default-boundp 'allout-tests-locally-true)))) |
|---|
| | 6037 | |
|---|
| | 6038 | ;; ensure that last of multiple resumptions holds, for various scopes. |
|---|
| | 6039 | (with-temp-buffer |
|---|
| | 6040 | (allout-tests-obliterate-variable 'allout-tests-globally-unbound) |
|---|
| | 6041 | (allout-tests-obliterate-variable 'allout-tests-globally-true) |
|---|
| | 6042 | (setq allout-tests-globally-true t) |
|---|
| | 6043 | (allout-tests-obliterate-variable 'allout-tests-locally-true) |
|---|
| | 6044 | (set (make-local-variable 'allout-tests-locally-true) t) |
|---|
| | 6045 | (allout-add-resumptions '(allout-tests-globally-unbound t) |
|---|
| | 6046 | '(allout-tests-globally-true nil) |
|---|
| | 6047 | '(allout-tests-locally-true nil)) |
|---|
| | 6048 | (allout-add-resumptions '(allout-tests-globally-unbound 2) |
|---|
| | 6049 | '(allout-tests-globally-true 3) |
|---|
| | 6050 | '(allout-tests-locally-true 4)) |
|---|
| | 6051 | ;; reestablish many of the basic conditions are maintained after re-add: |
|---|
| | 6052 | (assert (not (default-boundp 'allout-tests-globally-unbound))) |
|---|
| | 6053 | (assert (local-variable-p 'allout-tests-globally-unbound)) |
|---|
| | 6054 | (assert (equal allout-tests-globally-unbound 2)) |
|---|
| | 6055 | (assert (default-boundp 'allout-tests-globally-true)) |
|---|
| | 6056 | (assert (local-variable-p 'allout-tests-globally-true)) |
|---|
| | 6057 | (assert (equal allout-tests-globally-true 3)) |
|---|
| | 6058 | (assert (not (default-boundp 'allout-tests-locally-true))) |
|---|
| | 6059 | (assert (local-variable-p 'allout-tests-locally-true)) |
|---|
| | 6060 | (assert (equal allout-tests-locally-true 4)) |
|---|
| | 6061 | (allout-do-resumptions) |
|---|
| | 6062 | (assert (not (local-variable-p 'allout-tests-globally-unbound))) |
|---|
| | 6063 | (assert (not (boundp 'allout-tests-globally-unbound))) |
|---|
| | 6064 | (assert (not (local-variable-p 'allout-tests-globally-true))) |
|---|
| | 6065 | (assert (boundp 'allout-tests-globally-true)) |
|---|
| | 6066 | (assert (equal allout-tests-globally-true t)) |
|---|
| | 6067 | (assert (boundp 'allout-tests-locally-true)) |
|---|
| | 6068 | (assert (local-variable-p 'allout-tests-locally-true)) |
|---|
| | 6069 | (assert (equal allout-tests-locally-true t)) |
|---|
| | 6070 | (assert (not (default-boundp 'allout-tests-locally-true)))) |
|---|
| | 6071 | |
|---|
| | 6072 | ;; ensure that deliberately unbinding registered variables doesn't foul things |
|---|
| | 6073 | (with-temp-buffer |
|---|
| | 6074 | (allout-tests-obliterate-variable 'allout-tests-globally-unbound) |
|---|
| | 6075 | (allout-tests-obliterate-variable 'allout-tests-globally-true) |
|---|
| | 6076 | (setq allout-tests-globally-true t) |
|---|
| | 6077 | (allout-tests-obliterate-variable 'allout-tests-locally-true) |
|---|
| | 6078 | (set (make-local-variable 'allout-tests-locally-true) t) |
|---|
| | 6079 | (allout-add-resumptions '(allout-tests-globally-unbound t) |
|---|
| | 6080 | '(allout-tests-globally-true nil) |
|---|
| | 6081 | '(allout-tests-locally-true nil)) |
|---|
| | 6082 | (allout-tests-obliterate-variable 'allout-tests-globally-unbound) |
|---|
| | 6083 | (allout-tests-obliterate-variable 'allout-tests-globally-true) |
|---|
| | 6084 | (allout-tests-obliterate-variable 'allout-tests-locally-true) |
|---|
| | 6085 | (allout-do-resumptions)) |
|---|
| | 6086 | ) |
|---|
| | 6087 | ;;;_ % Run unit tests if `allout-run-unit-tests-after-load' is true: |
|---|
| | 6088 | (when allout-run-unit-tests-on-load |
|---|
| | 6089 | (allout-run-unit-tests)) |
|---|
| | 6090 | |
|---|
| | 6091 | ;;;_ #12 Provide |
|---|