Function: custom-magic-value-create

custom-magic-value-create is a byte-compiled function defined in cus-edit.el.gz.

Signature

(custom-magic-value-create WIDGET)

Documentation

Create compact status report for WIDGET.

Source Code

;; Defined in /usr/src/emacs/lisp/cus-edit.el.gz
(defun custom-magic-value-create (widget)
  "Create compact status report for WIDGET."
  (let* ((parent (widget-get widget :parent))
	 (state (widget-get parent :custom-state))
	 (hidden (eq state 'hidden))
	 (entry (assq state custom-magic-alist))
	 (magic (nth 1 entry))
	 (face (nth 2 entry))
	 (category (widget-get parent :custom-category))
	 (text (or (and (eq category 'group)
			(nth 4 entry))
		   (nth 3 entry)))
	 (form (widget-get parent :custom-form))
	 children)
    (unless (eq state 'hidden)
      (while (string-match "\\`\\(.*\\)%c\\(.*\\)\\'" text)
	(setq text (concat (match-string 1 text)
			   (symbol-name category)
			   (match-string 2 text))))
      (when (and custom-magic-show
		 (or (not hidden)
		     (memq category custom-magic-show-hidden)))
	(insert "   ")
	(when (and (eq category 'group)
		   (not (and (eq custom-buffer-style 'links)
			     (> (widget-get parent :custom-level) 1))))
	  (insert-char ?\s (* custom-buffer-indent
			      (widget-get parent :custom-level))))
	(push (widget-create-child-and-convert
	       widget 'choice-item
	       :help-echo "Change the state of this item."
	       :format (if hidden "%t" "%[%t%]")
	       :button-prefix 'widget-push-button-prefix
	       :button-suffix 'widget-push-button-suffix
	       :mouse-down-action 'widget-magic-mouse-down-action
	       :tag " State ")
	      children)
	(insert ": ")
	(let ((start (point)))
	  (if (eq custom-magic-show 'long)
	      (insert text)
	    (insert (symbol-name state)))
	  (cond ((eq form 'lisp)
		 (insert " (lisp)"))
		((eq form 'mismatch)
		 (insert " (mismatch)")))
	  (put-text-property start (point) 'face 'custom-state))
	(insert "\n"))
      (when (and (eq category 'group)
		 (not (and (eq custom-buffer-style 'links)
			   (> (widget-get parent :custom-level) 1))))
	(insert-char ?\s (* custom-buffer-indent
			    (widget-get parent :custom-level))))
      (when custom-magic-show-button
	(when custom-magic-show
	  (let ((indent (widget-get parent :indent)))
	    (when indent
	      (insert-char ?  indent))))
	(push (widget-create-child-and-convert
	       widget 'choice-item
	       :mouse-down-action 'widget-magic-mouse-down-action
	       :button-face face
	       :button-prefix ""
	       :button-suffix ""
	       :help-echo "Change the state."
	       :format (if hidden "%t" "%[%t%]")
	       :tag (if (memq form '(lisp mismatch))
			(concat "(" magic ")")
		      (concat "[" magic "]")))
	      children)
	(insert " "))
      (widget-put widget :children children))))