;;; The `custom-variable' Widget.
+(defface custom-variable-obsolete
+ '((((class color) (background dark))
+ :foreground "light blue")
+ (((min-colors 88) (class color) (background light))
+ :foreground "blue1")
+ (((class color) (background light))
+ :foreground "blue")
+ (t :slant italic))
+ "Face used for obsolete variables."
+ :version "27.1"
+ :group 'custom-faces)
+
(defface custom-variable-tag
`((((class color) (background dark))
:foreground "light blue" :weight bold)
(defun custom-variable-documentation (variable)
"Return documentation of VARIABLE for use in Custom buffer.
Normally just return the docstring. But if VARIABLE automatically
-becomes buffer local when set, append a message to that effect."
- (format "%s%s" (documentation-property variable 'variable-documentation t)
+becomes buffer local when set, append a message to that effect.
+Also append any obsolescence information."
+ (format "%s%s%s" (documentation-property variable 'variable-documentation t)
(if (and (local-variable-if-set-p variable)
(or (not (local-variable-p variable))
(with-temp-buffer
"\n
This variable automatically becomes buffer-local when set outside Custom.
However, setting it through Custom sets the default value."
- "")))
+ "")
+ ;; This duplicates some code from describe-variable.
+ ;; TODO extract to separate utility function?
+ (let* ((obsolete (get variable 'byte-obsolete-variable))
+ (use (car obsolete)))
+ (if obsolete
+ (concat "\n
+This variable is obsolete"
+ (if (nth 2 obsolete)
+ (format " since %s" (nth 2 obsolete)))
+ (cond ((stringp use) (concat ";\n" use))
+ (use (format-message ";\nuse `%s' instead."
+ (car obsolete)))
+ (t ".")))
+ ""))))
(define-widget 'custom-variable 'custom
"A widget for displaying a Custom variable.
(state (or (widget-get widget :custom-state)
(if (memq (custom-variable-state symbol value)
(widget-get widget :hidden-states))
- 'hidden))))
+ 'hidden)))
+ (obsolete (get symbol 'byte-obsolete-variable)))
;; If we don't know the state, see if we need to edit it in lisp form.
(unless state
(push (widget-create-child-and-convert
widget 'item
:format "%{%t%} "
- :sample-face 'custom-variable-tag
+ :sample-face (if obsolete
+ 'custom-variable-obsolete
+ 'custom-variable-tag)
:tag tag
:parent widget)
buttons))
:help-echo "Change value of this option."
:mouse-down-action 'custom-tag-mouse-down-action
:button-face 'custom-variable-button
- :sample-face 'custom-variable-tag
+ :sample-face (if obsolete
+ 'custom-variable-obsolete
+ 'custom-variable-tag)
tag)
buttons)
(push (widget-create-child-and-convert
:group 'custom-buffer
:version "20.3")
+(defun custom-face-documentation (face)
+ "Return documentation of FACE for use in Custom buffer."
+ (format "%s%s" (face-documentation face)
+ ;; This duplicates some code from describe-face.
+ ;; TODO extract to separate utility function?
+ ;; In practice this does not get used, because M-x customize-face
+ ;; follows aliases.
+ (let ((alias (get face 'face-alias))
+ (obsolete (get face 'obsolete-face)))
+ (if (and alias obsolete)
+ (format "\nThis face is obsolete%s; use `%s' instead.\n"
+ (if (stringp obsolete)
+ (format " since %s" obsolete)
+ "")
+ alias)
+ ""))))
+
(define-widget 'custom-face 'custom
"Widget for customizing a face.
The following properties have special meanings for this widget:
of the widget, instead of the current face spec."
:sample-face 'custom-face-tag
:help-echo "Set or reset this face."
- :documentation-property #'face-doc-string
+ :documentation-property #'custom-face-documentation
:value-create 'custom-face-value-create
:action 'custom-face-action
:custom-category 'face