comparison lisp/bytecomp.el @ 4289:20accccbebd6

[xemacs-hg @ 2007-11-27 22:15:32 by aidan] Byte compile defcustom init values; save the Lisp values for correct editing, correct some comments and indentation, and expose some lambda expressions to the byte compile; make custom-initialize-changed a defubst, since it's only called from one place and calls to that place cluster.
author aidan
date Tue, 27 Nov 2007 22:15:34 +0000
parents adecfd791c9b
children 27150c937a22
comparison
equal deleted inserted replaced
4288:9eb558ffe8ff 4289:20accccbebd6
2374 2374
2375 ;; This is part of bytecomp.el in 19.35: 2375 ;; This is part of bytecomp.el in 19.35:
2376 (put 'custom-declare-variable 'byte-hunk-handler 2376 (put 'custom-declare-variable 'byte-hunk-handler
2377 'byte-compile-file-form-custom-declare-variable) 2377 'byte-compile-file-form-custom-declare-variable)
2378 (defun byte-compile-file-form-custom-declare-variable (form) 2378 (defun byte-compile-file-form-custom-declare-variable (form)
2379 (if (memq 'free-vars byte-compile-warnings) 2379 ;; XEmacs change; our implementation byte compiles and gives warnings
2380 (setq byte-compile-bound-variables 2380 ;; about the default value code, which GNU's doesn't.
2381 (cons (cons (nth 1 (nth 1 form)) 2381 (let* ((quoted-default (car-safe (cdr-safe (cdr-safe form))))
2382 byte-compile-global-bit) 2382 (to-examine (car-safe (cdr-safe quoted-default))))
2383 byte-compile-bound-variables))) 2383 (if (memq 'free-vars byte-compile-warnings)
2384 form) 2384 (setq byte-compile-bound-variables
2385 2385 (cons (cons (nth 1 (nth 1 form))
2386 byte-compile-global-bit)
2387 byte-compile-bound-variables)))
2388 ;; Byte compile anything that smells like a lambda. I initially
2389 ;; considered limiting it to the :initialize, :set and :get args, but
2390 ;; that's not amazingly forward-compatible, and anyone expecting other
2391 ;; things to be stored as data, not code, is unrealistic.
2392 (loop
2393 for entry in-ref (nthcdr 4 form)
2394 do (cond ((and (eq 'function (car-safe entry))
2395 (consp (car-safe (cdr-safe entry))))
2396 (setf entry (copy-sequence entry))
2397 (setcar (cdr entry) (byte-compile-lambda (car (cdr entry)))))
2398 ((and (eq 'lambda (car-safe entry)))
2399 (setf entry (byte-compile-lambda entry)))))
2400 ;; Byte compile the default value, as we do for defvar.
2401 (when (consp (cdr-safe to-examine))
2402 (setq form (copy-sequence form))
2403 (setcdr (third form)
2404 (list (byte-compile-top-level to-examine nil 'file)))
2405 ;; And save a value to be examined in the custom UI, if that differs
2406 ;; from the init value.
2407 (unless (equal to-examine (car-safe (cdr (third form))))
2408 (setf (nthcdr 4 form) (nconc
2409 (list :default
2410 (list 'quote to-examine))
2411 (nthcdr 4 form)))))
2412 form))
2386 2413
2387 ;;;###autoload 2414 ;;;###autoload
2388 (defun byte-compile (form) 2415 (defun byte-compile (form)
2389 "If FORM is a symbol, byte-compile its function definition. 2416 "If FORM is a symbol, byte-compile its function definition.
2390 If FORM is a lambda or a macro, byte-compile it as a function." 2417 If FORM is a lambda or a macro, byte-compile it as a function."