aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2017-12-14 20:22:08 -0500
committerGlenn Morris2017-12-14 20:22:08 -0500
commitddcd6e63d1624c03a227c5ae4abca2443c28430d (patch)
treef62edc1223dfa674d923f7737ff10592e95386d5
parent94b52207cf0bd25d3e8052b01bda945e8718bd12 (diff)
downloademacs-ddcd6e63d1624c03a227c5ae4abca2443c28430d.tar.gz
emacs-ddcd6e63d1624c03a227c5ae4abca2443c28430d.zip
Improve Custom's treatment of obsolete options (bug#5742)
* lisp/cus-edit.el (custom-variable-obsolete): New face. (custom-variable-documentation): Include obsolescence information. (custom-variable-value-create): Use different face for obsolete items. (custom-face-documentation): New function. (custom-face): Use custom-face-documentation. * lisp/info-look.el (info-lookup-guess-custom-symbol): Add custom-variable-obsolete face.
-rw-r--r--lisp/cus-edit.el63
-rw-r--r--lisp/info-look.el3
2 files changed, 58 insertions, 8 deletions
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index 4965adfd56c..e0a00d4337f 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -2431,6 +2431,18 @@ If INITIAL-STRING is non-nil, use that rather than \"Parent groups:\"."
2431 2431
2432;;; The `custom-variable' Widget. 2432;;; The `custom-variable' Widget.
2433 2433
2434(defface custom-variable-obsolete
2435 '((((class color) (background dark))
2436 :foreground "light blue")
2437 (((min-colors 88) (class color) (background light))
2438 :foreground "blue1")
2439 (((class color) (background light))
2440 :foreground "blue")
2441 (t :slant italic))
2442 "Face used for obsolete variables."
2443 :version "27.1"
2444 :group 'custom-faces)
2445
2434(defface custom-variable-tag 2446(defface custom-variable-tag
2435 `((((class color) (background dark)) 2447 `((((class color) (background dark))
2436 :foreground "light blue" :weight bold) 2448 :foreground "light blue" :weight bold)
@@ -2456,8 +2468,9 @@ If INITIAL-STRING is non-nil, use that rather than \"Parent groups:\"."
2456(defun custom-variable-documentation (variable) 2468(defun custom-variable-documentation (variable)
2457 "Return documentation of VARIABLE for use in Custom buffer. 2469 "Return documentation of VARIABLE for use in Custom buffer.
2458Normally just return the docstring. But if VARIABLE automatically 2470Normally just return the docstring. But if VARIABLE automatically
2459becomes buffer local when set, append a message to that effect." 2471becomes buffer local when set, append a message to that effect.
2460 (format "%s%s" (documentation-property variable 'variable-documentation t) 2472Also append any obsolescence information."
2473 (format "%s%s%s" (documentation-property variable 'variable-documentation t)
2461 (if (and (local-variable-if-set-p variable) 2474 (if (and (local-variable-if-set-p variable)
2462 (or (not (local-variable-p variable)) 2475 (or (not (local-variable-p variable))
2463 (with-temp-buffer 2476 (with-temp-buffer
@@ -2465,7 +2478,21 @@ becomes buffer local when set, append a message to that effect."
2465 "\n 2478 "\n
2466This variable automatically becomes buffer-local when set outside Custom. 2479This variable automatically becomes buffer-local when set outside Custom.
2467However, setting it through Custom sets the default value." 2480However, setting it through Custom sets the default value."
2468 ""))) 2481 "")
2482 ;; This duplicates some code from describe-variable.
2483 ;; TODO extract to separate utility function?
2484 (let* ((obsolete (get variable 'byte-obsolete-variable))
2485 (use (car obsolete)))
2486 (if obsolete
2487 (concat "\n
2488This variable is obsolete"
2489 (if (nth 2 obsolete)
2490 (format " since %s" (nth 2 obsolete)))
2491 (cond ((stringp use) (concat ";\n" use))
2492 (use (format-message ";\nuse `%s' instead."
2493 (car obsolete)))
2494 (t ".")))
2495 ""))))
2469 2496
2470(define-widget 'custom-variable 'custom 2497(define-widget 'custom-variable 'custom
2471 "A widget for displaying a Custom variable. 2498 "A widget for displaying a Custom variable.
@@ -2549,7 +2576,8 @@ try matching its doc string against `custom-guess-doc-alist'."
2549 (state (or (widget-get widget :custom-state) 2576 (state (or (widget-get widget :custom-state)
2550 (if (memq (custom-variable-state symbol value) 2577 (if (memq (custom-variable-state symbol value)
2551 (widget-get widget :hidden-states)) 2578 (widget-get widget :hidden-states))
2552 'hidden)))) 2579 'hidden)))
2580 (obsolete (get symbol 'byte-obsolete-variable)))
2553 2581
2554 ;; If we don't know the state, see if we need to edit it in lisp form. 2582 ;; If we don't know the state, see if we need to edit it in lisp form.
2555 (unless state 2583 (unless state
@@ -2581,7 +2609,9 @@ try matching its doc string against `custom-guess-doc-alist'."
2581 (push (widget-create-child-and-convert 2609 (push (widget-create-child-and-convert
2582 widget 'item 2610 widget 'item
2583 :format "%{%t%} " 2611 :format "%{%t%} "
2584 :sample-face 'custom-variable-tag 2612 :sample-face (if obsolete
2613 'custom-variable-obsolete
2614 'custom-variable-tag)
2585 :tag tag 2615 :tag tag
2586 :parent widget) 2616 :parent widget)
2587 buttons)) 2617 buttons))
@@ -2639,7 +2669,9 @@ try matching its doc string against `custom-guess-doc-alist'."
2639 :help-echo "Change value of this option." 2669 :help-echo "Change value of this option."
2640 :mouse-down-action 'custom-tag-mouse-down-action 2670 :mouse-down-action 'custom-tag-mouse-down-action
2641 :button-face 'custom-variable-button 2671 :button-face 'custom-variable-button
2642 :sample-face 'custom-variable-tag 2672 :sample-face (if obsolete
2673 'custom-variable-obsolete
2674 'custom-variable-tag)
2643 tag) 2675 tag)
2644 buttons) 2676 buttons)
2645 (push (widget-create-child-and-convert 2677 (push (widget-create-child-and-convert
@@ -3322,6 +3354,23 @@ Only match frames that support the specified face attributes.")
3322 :group 'custom-buffer 3354 :group 'custom-buffer
3323 :version "20.3") 3355 :version "20.3")
3324 3356
3357(defun custom-face-documentation (face)
3358 "Return documentation of FACE for use in Custom buffer."
3359 (format "%s%s" (face-documentation face)
3360 ;; This duplicates some code from describe-face.
3361 ;; TODO extract to separate utility function?
3362 ;; In practice this does not get used, because M-x customize-face
3363 ;; follows aliases.
3364 (let ((alias (get face 'face-alias))
3365 (obsolete (get face 'obsolete-face)))
3366 (if (and alias obsolete)
3367 (format "\nThis face is obsolete%s; use `%s' instead.\n"
3368 (if (stringp obsolete)
3369 (format " since %s" obsolete)
3370 "")
3371 alias)
3372 ""))))
3373
3325(define-widget 'custom-face 'custom 3374(define-widget 'custom-face 'custom
3326 "Widget for customizing a face. 3375 "Widget for customizing a face.
3327The following properties have special meanings for this widget: 3376The following properties have special meanings for this widget:
@@ -3345,7 +3394,7 @@ The following properties have special meanings for this widget:
3345 of the widget, instead of the current face spec." 3394 of the widget, instead of the current face spec."
3346 :sample-face 'custom-face-tag 3395 :sample-face 'custom-face-tag
3347 :help-echo "Set or reset this face." 3396 :help-echo "Set or reset this face."
3348 :documentation-property #'face-doc-string 3397 :documentation-property #'custom-face-documentation
3349 :value-create 'custom-face-value-create 3398 :value-create 'custom-face-value-create
3350 :action 'custom-face-action 3399 :action 'custom-face-action
3351 :custom-category 'face 3400 :custom-category 'face
diff --git a/lisp/info-look.el b/lisp/info-look.el
index f52f48edec2..04a890e2b7a 100644
--- a/lisp/info-look.el
+++ b/lisp/info-look.el
@@ -619,7 +619,8 @@ Return nil if there is nothing appropriate in the buffer near point."
619 beg end) 619 beg end)
620 (cond 620 (cond
621 ((and (memq (get-char-property (point) 'face) 621 ((and (memq (get-char-property (point) 'face)
622 '(custom-variable-tag custom-variable-tag-face)) 622 '(custom-variable-tag custom-variable-obsolete
623 custom-variable-tag-face))
623 (setq beg (previous-single-char-property-change 624 (setq beg (previous-single-char-property-change
624 (point) 'face nil (line-beginning-position))) 625 (point) 'face nil (line-beginning-position)))
625 (setq end (next-single-char-property-change 626 (setq end (next-single-char-property-change