Function: widget-character-notify

widget-character-notify is a byte-compiled function defined in wid-edit.el.gz.

Signature

(widget-character-notify WIDGET CHILD &optional EVENT)

Documentation

Notify function for the character widget.

This function allows the widget character to better display some characters, like the newline character or the tab character.

Source Code

;; Defined in /usr/src/emacs/lisp/wid-edit.el.gz
(defun widget-character-notify (widget child &optional event)
  "Notify function for the character widget.

This function allows the widget character to better display some characters,
like the newline character or the tab character."
  (when (eq (car-safe event) 'after-change)
    (let* ((start (nth 1 event))
           (end (nth 2 event))
           str)
      (if (eql start end)
          (when (char-equal (widget-value widget) ?\s)
            ;; The character widget is not really empty:
            ;; its value is a single space character.
            ;; We need to propertize it again, if it became empty for a while.
            (let ((ov (widget-get widget :field-overlay)))
              (put-text-property
               (overlay-start ov) (overlay-end ov)
               'display (widget-character--change-character-display ?\s))))
        (setq str (buffer-substring-no-properties start end))
        ;; This assumes the user enters one character at a time,
        ;; and does nothing crazy, like yanking a long string.
        (let ((disp (widget-character--change-character-display (aref str 0))))
          (when disp
            (put-text-property start end 'display disp))))))
  (widget-default-notify widget child event))