mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 22:41:06 -08:00
Fix comparison of current values for the key-sequence :type
* lisp/cus-edit.el (custom-variable-modified-p): Round-trip the option value before comparing it against the widget's value. This mostly fixes comparison against the obsolete key-sequence widget, but could fix other corner cases, when the widget accepts different types as values. (Bug#76156) * test/lisp/cus-edit-tests.el (cus-edit-test-bug76156) (cus-edit-test-bug76156-2): New test options. (cus-edit-test-unedited-option): New test.
This commit is contained in:
parent
2044f6d959
commit
f549cedaa2
2 changed files with 30 additions and 5 deletions
|
|
@ -3054,11 +3054,18 @@ To check for other states, call `custom-variable-state'."
|
||||||
(let* ((form (widget-get widget :custom-form))
|
(let* ((form (widget-get widget :custom-form))
|
||||||
(symbol (widget-get widget :value))
|
(symbol (widget-get widget :value))
|
||||||
(get (or (get symbol 'custom-get) 'default-value))
|
(get (or (get symbol 'custom-get) 'default-value))
|
||||||
(value (if (default-boundp symbol)
|
(value-widget (car (widget-get widget :children)))
|
||||||
(condition-case nil
|
;; Round-trip the value, for the sake of widgets that accept
|
||||||
(funcall get symbol)
|
;; values of different types (e.g., the obsolete key-sequence widget
|
||||||
(error (throw 'get-error t)))
|
;; which takes either strings or vectors. (Bug#76156)
|
||||||
(symbol-value symbol)))
|
(value
|
||||||
|
(widget-apply value-widget :value-to-external
|
||||||
|
(widget-apply value-widget :value-to-internal
|
||||||
|
(if (default-boundp symbol)
|
||||||
|
(condition-case nil
|
||||||
|
(funcall get symbol)
|
||||||
|
(error (throw 'get-error t)))
|
||||||
|
(symbol-value symbol)))))
|
||||||
(orig-value (widget-value (car (widget-get widget :children)))))
|
(orig-value (widget-value (car (widget-get widget :children)))))
|
||||||
(not (equal (if (memq form '(lisp mismatch))
|
(not (equal (if (memq form '(lisp mismatch))
|
||||||
;; Mimic `custom-variable-value-create'.
|
;; Mimic `custom-variable-value-create'.
|
||||||
|
|
|
||||||
|
|
@ -134,5 +134,23 @@
|
||||||
;; No empty key/value pairs should show up.
|
;; No empty key/value pairs should show up.
|
||||||
(should-not (search-forward "key" nil t)))
|
(should-not (search-forward "key" nil t)))
|
||||||
|
|
||||||
|
(defcustom cus-edit-test-bug76156 "\C-c "
|
||||||
|
"Key-sequence option that might show up as EDITED even though it's not."
|
||||||
|
:type 'key-sequence)
|
||||||
|
|
||||||
|
(defcustom cus-edit-test-bug76156-2 [(control ?z)]
|
||||||
|
"Key-sequence option that might show up as EDITED even though it's not."
|
||||||
|
:type 'key-sequence)
|
||||||
|
|
||||||
|
(ert-deftest cus-edit-test-unedited-option ()
|
||||||
|
"Test that customizing unedited options doesn't show up as EDITED."
|
||||||
|
(dolist (option '(cus-edit-test-bug76156
|
||||||
|
cus-edit-test-bug76156-2
|
||||||
|
cus-edit-test-foo1))
|
||||||
|
(customize-option option)
|
||||||
|
(let ((widget (car custom-options)))
|
||||||
|
(should (eq (widget-get widget :custom-state) 'standard)))
|
||||||
|
(kill-buffer)))
|
||||||
|
|
||||||
(provide 'cus-edit-tests)
|
(provide 'cus-edit-tests)
|
||||||
;;; cus-edit-tests.el ends here
|
;;; cus-edit-tests.el ends here
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue