Mercurial > emacs
comparison lisp/emacs-lisp/cl-indent.el @ 29797:3bf98b923af0
handle print-unreadable-object
author | Sam Steingold <sds@gnu.org> |
---|---|
date | Tue, 20 Jun 2000 15:01:59 +0000 |
parents | 277f4365f2fa |
children | 61c2f9fcb8f6 |
comparison
equal
deleted
inserted
replaced
29796:94ec83a6a42c | 29797:3bf98b923af0 |
---|---|
162 | 162 |
163 (cond ((and (memq (char-after (1- containing-sexp)) '(?\' ?\`)) | 163 (cond ((and (memq (char-after (1- containing-sexp)) '(?\' ?\`)) |
164 (not (eq (char-after (- containing-sexp 2)) ?\#))) | 164 (not (eq (char-after (- containing-sexp 2)) ?\#))) |
165 ;; No indentation for "'(...)" elements | 165 ;; No indentation for "'(...)" elements |
166 (setq calculated (1+ sexp-column))) | 166 (setq calculated (1+ sexp-column))) |
167 ((or (eq (char-after (1- containing-sexp)) ?\,) | 167 ((or (eq (char-after (1- containing-sexp)) ?\,) |
168 (and (eq (char-after (1- containing-sexp)) ?\@) | 168 (and (eq (char-after (1- containing-sexp)) ?\@) |
169 (eq (char-after (- containing-sexp 2)) ?\,))) | 169 (eq (char-after (- containing-sexp 2)) ?\,))) |
170 ;; ",(...)" or ",@(...)" | 170 ;; ",(...)" or ",@(...)" |
171 (setq calculated normal-indent)) | 171 (setq calculated normal-indent)) |
172 ((eq (char-after (1- containing-sexp)) ?\#) | 172 ((eq (char-after (1- containing-sexp)) ?\#) |
173 ;; "#(...)" | 173 ;; "#(...)" |
174 (setq calculated (1+ sexp-column))) | 174 (setq calculated (1+ sexp-column))) |
175 ((null method)) | 175 ((null method)) |
176 ((integerp method) | 176 ((integerp method) |
190 (+ sexp-column lisp-body-indent)) | 190 (+ sexp-column lisp-body-indent)) |
191 (t | 191 (t |
192 ;; other body form | 192 ;; other body form |
193 normal-indent)))) | 193 normal-indent)))) |
194 ((symbolp method) | 194 ((symbolp method) |
195 (let ((lisp-indent-error-function function)) | 195 (let ((lisp-indent-error-function function)) |
196 (setq calculated (funcall method | 196 (setq calculated (funcall method |
197 path state indent-point | 197 path state indent-point |
198 sexp-column normal-indent)))) | 198 sexp-column normal-indent)))) |
199 (t | 199 (t |
200 (let ((lisp-indent-error-function function)) | 200 (let ((lisp-indent-error-function function)) |
201 (setq calculated (lisp-indent-259 | 201 (setq calculated (lisp-indent-259 |
202 method path state indent-point | 202 method path state indent-point |
203 sexp-column normal-indent)))))) | 203 sexp-column normal-indent)))))) |
204 (goto-char containing-sexp) | 204 (goto-char containing-sexp) |
205 (setq last-point containing-sexp) | 205 (setq last-point containing-sexp) |
206 (unless calculated | 206 (unless calculated |
207 (condition-case () | 207 (condition-case () |
208 (progn (backward-up-list 1) | 208 (progn (backward-up-list 1) |
239 ;; n is set to (1- n) and method to (cdr method) | 239 ;; n is set to (1- n) and method to (cdr method) |
240 ;; each iteration. | 240 ;; each iteration. |
241 (setq tem (car method)) | 241 (setq tem (car method)) |
242 | 242 |
243 (or (eq tem 'nil) ;default indentation | 243 (or (eq tem 'nil) ;default indentation |
244 (eq tem '&lambda) ;lambda list | 244 (eq tem '&lambda) ;lambda list |
245 (and (eq tem '&body) (null (cdr method))) | 245 (and (eq tem '&body) (null (cdr method))) |
246 (and (eq tem '&rest) | 246 (and (eq tem '&rest) |
247 (consp (cdr method)) | 247 (consp (cdr method)) |
248 (null (cddr method))) | 248 (null (cddr method))) |
249 (integerp tem) ;explicit indentation specified | 249 (integerp tem) ;explicit indentation specified |
250 (and (consp tem) ;destructuring | 250 (and (consp tem) ;destructuring |
251 (eq (car tem) '&whole) | 251 (eq (car tem) '&whole) |
252 (or (symbolp (cadr tem)) | 252 (or (symbolp (cadr tem)) |
253 (integerp (cadr tem)))) | 253 (integerp (cadr tem)))) |
254 (and (symbolp tem) ;a function to call to do the work. | 254 (and (symbolp tem) ;a function to call to do the work. |
255 (null (cdr method))) | 255 (null (cdr method))) |
256 (lisp-indent-report-bad-format method)) | 256 (lisp-indent-report-bad-format method)) |
257 | 257 |
258 (cond ((and tail (not (consp tem))) | 258 (cond ((and tail (not (consp tem))) |
344 | 344 |
345 (defun lisp-indent-do (path state indent-point sexp-column normal-indent) | 345 (defun lisp-indent-do (path state indent-point sexp-column normal-indent) |
346 (if (>= (car path) 3) | 346 (if (>= (car path) 3) |
347 (let ((lisp-tag-body-indentation lisp-body-indent)) | 347 (let ((lisp-tag-body-indentation lisp-body-indent)) |
348 (funcall (function lisp-indent-tagbody) | 348 (funcall (function lisp-indent-tagbody) |
349 path state indent-point sexp-column normal-indent)) | 349 path state indent-point sexp-column normal-indent)) |
350 (funcall (function lisp-indent-259) | 350 (funcall (function lisp-indent-259) |
351 '((&whole nil &rest | 351 '((&whole nil &rest |
352 ;; the following causes weird indentation | 352 ;; the following causes weird indentation |
353 ;;(&whole 1 1 2 nil) | 353 ;;(&whole 1 1 2 nil) |
354 ) | 354 ) |
355 (&whole nil &rest 1)) | 355 (&whole nil &rest 1)) |
356 path state indent-point sexp-column normal-indent))) | 356 path state indent-point sexp-column normal-indent))) |
357 | 357 |
358 (defun lisp-indent-function-lambda-hack (path state indent-point | 358 (defun lisp-indent-function-lambda-hack (path state indent-point |
359 sexp-column normal-indent) | 359 sexp-column normal-indent) |
360 ;; indent (function (lambda () <newline> <body-forms>)) kludgily. | 360 ;; indent (function (lambda () <newline> <body-forms>)) kludgily. |
361 (if (or (cdr path) ; wtf? | 361 (if (or (cdr path) ; wtf? |
373 (+ sexp-column lisp-body-indent))) | 373 (+ sexp-column lisp-body-indent))) |
374 (error (+ sexp-column lisp-body-indent))))) | 374 (error (+ sexp-column lisp-body-indent))))) |
375 | 375 |
376 | 376 |
377 (let ((l '((block 1) | 377 (let ((l '((block 1) |
378 (case (4 &rest (&whole 2 &rest 1))) | 378 (case (4 &rest (&whole 2 &rest 1))) |
379 (ccase . case) (ecase . case) | 379 (ccase . case) (ecase . case) |
380 (condition-case ((1 4) (&whole 2 ((0 1) (1 3) (2 &body))))) | 380 (condition-case ((1 4) (&whole 2 ((0 1) (1 3) (2 &body))))) |
381 (typecase . case) (etypecase . case) (ctypecase . case) | 381 (typecase . case) (etypecase . case) (ctypecase . case) |
382 (catch 1) | 382 (catch 1) |
383 (cond (&rest (&whole 2 &rest 1))) | 383 (cond (&rest (&whole 2 &rest 1))) |
384 (defvar (4 2 2)) | 384 (defvar (4 2 2)) |
385 (defclass ((&whole 4 &rest (&whole 2 &rest 1)) | 385 (defclass ((&whole 4 &rest (&whole 2 &rest 1)) |
386 &rest (&whole 2 &rest 1))) | 386 &rest (&whole 2 &rest 1))) |
387 (defconstant . defvar) | 387 (defconstant . defvar) |
388 (defcustom (4 2 2 2)) | 388 (defcustom (4 2 2 2)) |
389 (defparameter . defvar) | 389 (defparameter . defvar) |
390 (define-modify-macro | 390 (define-modify-macro |
391 (4 &body)) | 391 (4 &body)) |
392 (defsetf (4 &lambda 4 &body)) | 392 (defsetf (4 &lambda 4 &body)) |
393 (defun (4 &lambda &body)) | 393 (defun (4 &lambda &body)) |
394 (define-setf-method . defun) | 394 (define-setf-method . defun) |
395 (define-setf-expander . defun) | 395 (define-setf-expander . defun) |
396 (defmacro . defun) (defsubst . defun) (deftype . defun) | 396 (defmacro . defun) (defsubst . defun) (deftype . defun) |
397 (defmethod (4 4 (&whole 4 &rest 1) &body)) | 397 (defmethod (4 4 (&whole 4 &rest 1) &body)) |
398 (defpackage (4 2)) | 398 (defpackage (4 2)) |
399 (defstruct ((&whole 4 &rest (&whole 2 &rest 1)) | 399 (defstruct ((&whole 4 &rest (&whole 2 &rest 1)) |
400 &rest (&whole 2 &rest 1))) | 400 &rest (&whole 2 &rest 1))) |
401 (destructuring-bind | 401 (destructuring-bind |
402 ((&whole 6 &rest 1) 4 &body)) | 402 ((&whole 6 &rest 1) 4 &body)) |
403 (do lisp-indent-do) | 403 (do lisp-indent-do) |
404 (do* . do) | 404 (do* . do) |
405 (dolist ((&whole 4 2 1) &body)) | 405 (dolist ((&whole 4 2 1) &body)) |
406 (dotimes . dolist) | 406 (dotimes . dolist) |
407 (eval-when 1) | 407 (eval-when 1) |
408 (flet ((&whole 4 &rest (&whole 1 &lambda &body)) &body)) | 408 (flet ((&whole 4 &rest (&whole 1 &lambda &body)) &body)) |
409 (labels . flet) | 409 (labels . flet) |
410 (macrolet . flet) | 410 (macrolet . flet) |
411 (handler-case (4 &rest (&whole 2 &lambda &body))) | 411 (handler-case (4 &rest (&whole 2 &lambda &body))) |
412 (restart-case . handler-case) | 412 (restart-case . handler-case) |
413 ;; `else-body' style | 413 ;; `else-body' style |
414 (if (nil nil &body)) | 414 (if (nil nil &body)) |
415 ;; single-else style (then and else equally indented) | 415 ;; single-else style (then and else equally indented) |
416 (if (&rest nil)) | 416 (if (&rest nil)) |
417 (lambda (&lambda &rest lisp-indent-function-lambda-hack)) | 417 (lambda (&lambda &rest lisp-indent-function-lambda-hack)) |
418 (let ((&whole 4 &rest (&whole 1 1 2)) &body)) | 418 (let ((&whole 4 &rest (&whole 1 1 2)) &body)) |
419 (let* . let) | 419 (let* . let) |
420 (compiler-let . let) ;barf | 420 (compiler-let . let) ;barf |
421 (handler-bind . let) (restart-bind . let) | 421 (handler-bind . let) (restart-bind . let) |
422 (locally 1) | 422 (locally 1) |
423 ;(loop ...) | 423 ;(loop ...) |
424 (multiple-value-bind | 424 (multiple-value-bind |
425 ((&whole 6 &rest 1) 4 &body)) | 425 ((&whole 6 &rest 1) 4 &body)) |
426 (multiple-value-call | 426 (multiple-value-call |
427 (4 &body)) | 427 (4 &body)) |
428 (multiple-value-prog1 1) | 428 (multiple-value-prog1 1) |
429 (multiple-value-setq | 429 (multiple-value-setq (4 2)) |
430 (4 2)) | 430 (multiple-value-setf . multiple-value-setq) |
431 (multiple-value-setf . multiple-value-setq) | |
432 (pprint-logical-block (4 2)) | 431 (pprint-logical-block (4 2)) |
433 ;; Combines the worst features of BLOCK, LET and TAGBODY | 432 (print-unreadable-object ((&whole 4 1 &rest 1) &body)) |
434 (prog (&lambda &rest lisp-indent-tagbody)) | 433 ;; Combines the worst features of BLOCK, LET and TAGBODY |
435 (prog* . prog) | 434 (prog (&lambda &rest lisp-indent-tagbody)) |
436 (prog1 1) | 435 (prog* . prog) |
437 (prog2 2) | 436 (prog1 1) |
438 (progn 0) | 437 (prog2 2) |
439 (progv (4 4 &body)) | 438 (progn 0) |
440 (return 0) | 439 (progv (4 4 &body)) |
441 (return-from (nil &body)) | 440 (return 0) |
442 (symbol-macrolet . multiple-value-bind) | 441 (return-from (nil &body)) |
443 (tagbody lisp-indent-tagbody) | 442 (symbol-macrolet . multiple-value-bind) |
444 (throw 1) | 443 (tagbody lisp-indent-tagbody) |
445 (unless 1) | 444 (throw 1) |
446 (unwind-protect (5 &body)) | 445 (unless 1) |
446 (unwind-protect (5 &body)) | |
447 (when 1) | 447 (when 1) |
448 (with-output-to-string (4 2)) | 448 (with-output-to-string (4 2)) |
449 (with-standard-io-syntax (2))))) | 449 (with-standard-io-syntax (2))))) |
450 (while l | 450 (while l |
451 (put (caar l) 'common-lisp-indent-function | 451 (put (caar l) 'common-lisp-indent-function |
452 (if (symbolp (cdar l)) | 452 (if (symbolp (cdar l)) |
453 (get (cdar l) 'common-lisp-indent-function) | 453 (get (cdar l) 'common-lisp-indent-function) |
454 (car (cdar l)))) | 454 (car (cdar l)))) |
455 (setq l (cdr l)))) | 455 (setq l (cdr l)))) |
456 | 456 |
457 | 457 |
458 ;(defun foo (x) | 458 ;(defun foo (x) |
459 ; (tagbody | 459 ; (tagbody |
480 ; (win 1 2 | 480 ; (win 1 2 |
481 ; (foo))) | 481 ; (foo))) |
482 ; (t | 482 ; (t |
483 ; (lose | 483 ; (lose |
484 ; 3)))))) | 484 ; 3)))))) |
485 | 485 |
486 | 486 |
487 ;(put 'while 'common-lisp-indent-function 1) | 487 ;(put 'while 'common-lisp-indent-function 1) |
488 ;(put 'defwrapper'common-lisp-indent-function ...) | 488 ;(put 'defwrapper'common-lisp-indent-function ...) |
489 ;(put 'def 'common-lisp-indent-function ...) | 489 ;(put 'def 'common-lisp-indent-function ...) |
490 ;(put 'defflavor 'common-lisp-indent-function ...) | 490 ;(put 'defflavor 'common-lisp-indent-function ...) |