Function: forms--make-format-elt-using-text-properties

forms--make-format-elt-using-text-properties is a byte-compiled function defined in forms.el.gz.

Signature

(forms--make-format-elt-using-text-properties EL)

Documentation

Helper routine to generate format function.

Source Code

;; Defined in /usr/src/emacs/lisp/forms.el.gz
(defun forms--make-format-elt-using-text-properties (el)
  "Helper routine to generate format function."

  ;; The format routine `forms--format' will look like
  ;;
  ;; ;; preamble
  ;; (lambda (arg)
  ;;   (let ((inhibit-read-only t))
  ;;
  ;;     ;; A string, e.g. "text: ".
  ;;     (set-text-properties
  ;;      (point)
  ;;      (progn (insert "text: ") (point))
  ;;      (list 'face forms--ro-face
  ;;		'read-only 1
  ;;		'insert-in-front-hooks 'forms--iif-hook
  ;;		'rear-nonsticky '(read-only face insert-in-front-hooks)))
  ;;
  ;;     ;; A field, e.g. 6.
  ;;     (let ((here (point)))
  ;;       (aset forms--markers 0 (point-marker))
  ;;       (insert (elt arg 5))
  ;;       (or (= (point) here)
  ;;      (set-text-properties
  ;;       here (point)
  ;;       (list 'face forms--rw-face
  ;;		 'front-sticky '(face))))
  ;;
  ;;     ;; Another string, e.g. "\nmore text: ".
  ;;     (set-text-properties
  ;;      (point)
  ;;      (progn (insert "\nmore text: ") (point))
  ;;      (list 'face forms--ro-face
  ;;		'read-only 2
  ;;		'insert-in-front-hooks 'forms--iif-hook
  ;;		'rear-nonsticky '(read-only face insert-in-front-hooks)))
  ;;
  ;;     ;; A function, e.g. (tocol 40).
  ;;     (set-text-properties
  ;;      (point)
  ;;      (progn
  ;;        (insert (aset forms--dyntexts 0 (tocol 40)))
  ;;        (point))
  ;;      (list 'face forms--ro-face
  ;;		'read-only 2
  ;;		'insert-in-front-hooks 'forms--iif-hook
  ;;		'rear-nonsticky '(read-only face insert-in-front-hooks)))
  ;;
  ;;	 ;; Prevent insertion before the first text.
  ;;	 (add-text-properties (point-min) (1+ (point-min))
  ;;			      '(front-sticky (read-only))))))
  ;;	 ;; Prevent insertion after the last text.
  ;;	 (remove-text-properties (1- (point)) (point)
  ;;                             '(rear-nonsticky nil)))
  ;;
  ;;     ;; wrap up
  ;;     (setq forms--iif-start nil)
  ;;     ))

  (cond
   ((stringp el)

    `((set-text-properties
       (point)				; start at point
       (progn				; until after insertion
	 (insert ,el)
	 (point))
       (list 'face forms--ro-face	; read-only appearance
	     'read-only ,@(list (1+ forms--marker))
	     'cursor-intangible ,@(list (1+ forms--marker))
	     'insert-in-front-hooks '(forms--iif-hook)
	     'rear-nonsticky '(face read-only insert-in-front-hooks
				    cursor-intangible)))))

   ((numberp el)
    `((let ((here (point)))
	(aset forms--markers
	      ,(prog1 forms--marker
		 (setq forms--marker (1+ forms--marker)))
	      (point-marker))
	(insert (elt arg ,(1- el)))
	(or (= (point) here)
	    (set-text-properties
	     here (point)
	     (list 'face forms--rw-face
		   'front-sticky '(face)))))))

   ((listp el)
    `((set-text-properties
       (point)
       (progn
	 (insert (aset forms--dyntexts
		       ,(prog1 forms--dyntext
			  (setq forms--dyntext (1+ forms--dyntext)))
		       ,el))
	 (point))
       (list 'face forms--ro-face
	     'read-only ,@(list (1+ forms--marker))
	     'cursor-intangible ,@(list (1+ forms--marker))
	     'insert-in-front-hooks '(forms--iif-hook)
	     'rear-nonsticky '(read-only face insert-in-front-hooks
					 cursor-intangible)))))

   ;; end of cond
   ))