@@ -2330,6 +2330,7 @@ and `face'."
2330
2330
(from (marker-position (widget-get widget :from )))
2331
2331
(to (marker-position (widget-get widget :to ))))
2332
2332
(save-excursion
2333
+ (custom-comment-preserve widget)
2333
2334
(widget-value-set widget (widget-value widget))
2334
2335
(custom-redraw-magic widget))
2335
2336
(when (and (>= pos from) (<= pos to))
@@ -2509,7 +2510,9 @@ If INITIAL-STRING is non-nil, use that rather than \"Parent groups:\"."
2509
2510
(let* ((null-comment (equal " " (widget-value widget))))
2510
2511
(if (or (widget-get (widget-get widget :parent ) :comment-shown )
2511
2512
(not null-comment))
2512
- (widget-default-create widget)
2513
+ (progn
2514
+ (widget-default-create widget)
2515
+ (widget-put (widget-get widget :parent ) :comment-shown t ))
2513
2516
; ; `widget-default-delete' expects markers in these slots --
2514
2517
; ; maybe it shouldn't.
2515
2518
(widget-put widget :from (point-marker ))
@@ -2542,6 +2545,14 @@ If INITIAL-STRING is non-nil, use that rather than \"Parent groups:\"."
2542
2545
(and (equal " " val)
2543
2546
(not (widget-get widget :comment-shown )))))
2544
2547
2548
+ ; ; This is useful when we want to redraw a widget, but we want to preserve
2549
+ ; ; edits made by the user in the comment widget. (See Bug#64649)
2550
+ (defun custom-comment-preserve (widget )
2551
+ " Preserve the comment that belongs to WIDGET."
2552
+ (when (widget-get widget :comment-shown )
2553
+ (let ((comment-widget (widget-get widget :comment-widget )))
2554
+ (widget-put comment-widget :value (widget-value comment-widget)))))
2555
+
2545
2556
; ;; The `custom-variable' Widget.
2546
2557
2547
2558
(defface custom-variable-obsolete
@@ -2821,12 +2832,16 @@ try matching its doc string against `custom-guess-doc-alist'."
2821
2832
2822
2833
; ; The comment field
2823
2834
(unless (eq state 'hidden )
2824
- (let* ((comment (get symbol 'variable-comment ))
2825
- (comment-widget
2826
- (widget-create-child-and-convert
2827
- widget 'custom-comment
2828
- :parent widget
2829
- :value (or comment " " ))))
2835
+ (let ((comment-widget
2836
+ (widget-create-child-and-convert
2837
+ widget 'custom-comment
2838
+ :parent widget
2839
+ :value (or
2840
+ (and
2841
+ (widget-get widget :comment-shown )
2842
+ (widget-value (widget-get widget :comment-widget )))
2843
+ (get symbol 'variable-comment )
2844
+ " " ))))
2830
2845
(widget-put widget :comment-widget comment-widget)
2831
2846
; ; Don't push it !!! Custom assumes that the first child is the
2832
2847
; ; value one.
@@ -3840,12 +3855,16 @@ the present value is saved to its :shown-value property instead."
3840
3855
widget :visibility-widget 'custom-visibility )
3841
3856
; ; The comment field
3842
3857
(unless hiddenp
3843
- (let* ((comment (get symbol 'face-comment ))
3844
- (comment-widget
3845
- (widget-create-child-and-convert
3846
- widget 'custom-comment
3847
- :parent widget
3848
- :value (or comment " " ))))
3858
+ (let ((comment-widget
3859
+ (widget-create-child-and-convert
3860
+ widget 'custom-comment
3861
+ :parent widget
3862
+ :value (or
3863
+ (and
3864
+ (widget-get widget :comment-shown )
3865
+ (widget-value (widget-get widget :comment-widget )))
3866
+ (get symbol 'face-comment )
3867
+ " " ))))
3849
3868
(widget-put widget :comment-widget comment-widget)
3850
3869
(push comment-widget children))))
3851
3870
0 commit comments