diff options
| author | Mauro Aranda | 2019-09-27 18:06:36 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-09-27 18:06:36 +0200 |
| commit | 283fd5f2f6f3fa1f650c5a77f9e3587faddd6881 (patch) | |
| tree | bbb25ef172b502812844b6a01061f8b56491f8a2 /test/lisp | |
| parent | 9ba907a5fbafaa323402ec1cfe4239ebf87a8a0a (diff) | |
| download | emacs-283fd5f2f6f3fa1f650c5a77f9e3587faddd6881.tar.gz emacs-283fd5f2f6f3fa1f650c5a77f9e3587faddd6881.zip | |
Don't discard customizations in progress when adding comments (Bug#5358)
* lisp/cus-edit.el (custom-comment-show): Add docstring. Save the
widget value in the :shown-value property, before redrawing.
(custom-variable-modified-p): New function, to complement the return
values of custom-variable-state.
(custom-variable-state-set): Use it.
(custom-face-value-create): Add children to the custom-face widget
before setting the state, to be able to check for user edits.
(custom-face-state-set): Check for user edits before calling
custom-face-state (bug#5358).
* test/lisp/custom-tests.el
(custom-test-show-comment-preserves-changes): New test.
Diffstat (limited to 'test/lisp')
| -rw-r--r-- | test/lisp/custom-tests.el | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/lisp/custom-tests.el b/test/lisp/custom-tests.el index 0c49db6c76d..270acda292c 100644 --- a/test/lisp/custom-tests.el +++ b/test/lisp/custom-tests.el | |||
| @@ -21,6 +21,10 @@ | |||
| 21 | 21 | ||
| 22 | (require 'ert) | 22 | (require 'ert) |
| 23 | 23 | ||
| 24 | (require 'wid-edit) | ||
| 25 | (require 'cus-edit) | ||
| 26 | (require 'seq) ; For `seq-find'. | ||
| 27 | |||
| 24 | (ert-deftest custom-theme--load-path () | 28 | (ert-deftest custom-theme--load-path () |
| 25 | "Test `custom-theme--load-path' behavior." | 29 | "Test `custom-theme--load-path' behavior." |
| 26 | (let ((tmpdir (file-name-as-directory (make-temp-file "custom-tests-" t)))) | 30 | (let ((tmpdir (file-name-as-directory (make-temp-file "custom-tests-" t)))) |
| @@ -123,4 +127,28 @@ | |||
| 123 | (should (equal custom--test-user-option 'baz)) | 127 | (should (equal custom--test-user-option 'baz)) |
| 124 | (should (equal custom--test-variable 'baz)))) | 128 | (should (equal custom--test-variable 'baz)))) |
| 125 | 129 | ||
| 130 | ;; This tests Bug#5358. | ||
| 131 | (ert-deftest custom-test-show-comment-preserves-changes () | ||
| 132 | "Test that adding a comment doesn't discard modifications in progress." | ||
| 133 | (customize-option 'custom--test-user-option) | ||
| 134 | (let* ((field (seq-find (lambda (widget) | ||
| 135 | (eq custom--test-user-option (widget-value widget))) | ||
| 136 | widget-field-list)) | ||
| 137 | (parent (widget-get field :parent)) | ||
| 138 | (origvalue (widget-value field))) | ||
| 139 | ;; Move to the end of the text of the widget, and modify it. This | ||
| 140 | ;; modification should be preserved after showing the comment field. | ||
| 141 | (goto-char (widget-field-text-end field)) | ||
| 142 | (insert "bar") | ||
| 143 | (custom-comment-show parent) | ||
| 144 | ;; From now on, must use `widget-at' to get the value of the widget. | ||
| 145 | (should-not (eq origvalue (widget-value (widget-at)))) | ||
| 146 | (should (eq (widget-get parent :custom-state) 'modified)) | ||
| 147 | (should (eq (widget-value (widget-at)) | ||
| 148 | (widget-apply field | ||
| 149 | :value-to-external | ||
| 150 | (concat | ||
| 151 | (widget-apply field :value-to-internal origvalue) | ||
| 152 | "bar")))))) | ||
| 153 | |||
| 126 | ;;; custom-tests.el ends here | 154 | ;;; custom-tests.el ends here |