diff options
| author | Richard M. Stallman | 1998-07-31 03:21:07 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-07-31 03:21:07 +0000 |
| commit | bbf1ae49ae6aca81dcef3771cfbe6e796ea987f6 (patch) | |
| tree | c4ef66a86eb662c4109b6eefd7702268c97af33e | |
| parent | ae659ad5e261d4510759c9b27864b67aa398bb2d (diff) | |
| download | emacs-bbf1ae49ae6aca81dcef3771cfbe6e796ea987f6.tar.gz emacs-bbf1ae49ae6aca81dcef3771cfbe6e796ea987f6.zip | |
(lisp-indent-defun-method): New variable.
(common-lisp-indent-function): Use it.
(lisp-indent-259): Uncomment the `&lambda' code.
(top-level let): Remove duplicate `catch' and `block'. Use
`&lambda' when appropriate. Now the lambda lists are indented appropriately.
| -rw-r--r-- | lisp/emacs-lisp/cl-indent.el | 71 |
1 files changed, 34 insertions, 37 deletions
diff --git a/lisp/emacs-lisp/cl-indent.el b/lisp/emacs-lisp/cl-indent.el index 04f89c2b0ce..0b0de868811 100644 --- a/lisp/emacs-lisp/cl-indent.el +++ b/lisp/emacs-lisp/cl-indent.el | |||
| @@ -80,6 +80,7 @@ by `lisp-body-indent'." | |||
| 80 | 80 | ||
| 81 | 81 | ||
| 82 | (defvar lisp-indent-error-function) | 82 | (defvar lisp-indent-error-function) |
| 83 | (defvar lisp-indent-defun-method '(4 &lambda &body)) | ||
| 83 | 84 | ||
| 84 | ;;;###autoload | 85 | ;;;###autoload |
| 85 | (defun common-lisp-indent-function (indent-point state) | 86 | (defun common-lisp-indent-function (indent-point state) |
| @@ -114,7 +115,8 @@ by `lisp-body-indent'." | |||
| 114 | (setq function nil method nil) | 115 | (setq function nil method nil) |
| 115 | (setq tem (point)) | 116 | (setq tem (point)) |
| 116 | (forward-sexp 1) | 117 | (forward-sexp 1) |
| 117 | (setq function (downcase (buffer-substring tem (point)))) | 118 | (setq function (downcase (buffer-substring-no-properties |
| 119 | tem (point)))) | ||
| 118 | (goto-char tem) | 120 | (goto-char tem) |
| 119 | (setq tem (intern-soft function) | 121 | (setq tem (intern-soft function) |
| 120 | method (get tem 'common-lisp-indent-function)) | 122 | method (get tem 'common-lisp-indent-function)) |
| @@ -146,17 +148,17 @@ by `lisp-body-indent'." | |||
| 146 | ;; backwards compatibility. | 148 | ;; backwards compatibility. |
| 147 | (cond ((null function)) | 149 | (cond ((null function)) |
| 148 | ((null method) | 150 | ((null method) |
| 149 | (if (null (cdr path)) | 151 | (when (null (cdr path)) |
| 150 | ;; (package prefix was stripped off above) | 152 | ;; (package prefix was stripped off above) |
| 151 | (setq method (cond ((string-match "\\`def" | 153 | (setq method (cond ((string-match "\\`def" |
| 152 | function) | 154 | function) |
| 153 | '(4 (&whole 4 &rest 1) &body)) | 155 | lisp-indent-defun-method) |
| 154 | ((string-match "\\`\\(with\\|do\\)-" | 156 | ((string-match "\\`\\(with\\|do\\)-" |
| 155 | function) | 157 | function) |
| 156 | '(4 &body)))))) | 158 | '(&lambda &body)))))) |
| 157 | ;; backwards compatibility. Bletch. | 159 | ;; backwards compatibility. Bletch. |
| 158 | ((eq method 'defun) | 160 | ((eq method 'defun) |
| 159 | (setq method '(4 (&whole 4 &rest 1) &body)))) | 161 | (setq method lisp-indent-defun-method))) |
| 160 | 162 | ||
| 161 | (cond ((and (memq (char-after (1- containing-sexp)) '(?\' ?\`)) | 163 | (cond ((and (memq (char-after (1- containing-sexp)) '(?\' ?\`)) |
| 162 | (not (eql (char-after (- containing-sexp 2)) ?\#))) | 164 | (not (eql (char-after (- containing-sexp 2)) ?\#))) |
| @@ -201,7 +203,7 @@ by `lisp-body-indent'." | |||
| 201 | sexp-column normal-indent)))))) | 203 | sexp-column normal-indent)))))) |
| 202 | (goto-char containing-sexp) | 204 | (goto-char containing-sexp) |
| 203 | (setq last-point containing-sexp) | 205 | (setq last-point containing-sexp) |
| 204 | (if (not calculated) | 206 | (unless calculated |
| 205 | (condition-case () | 207 | (condition-case () |
| 206 | (progn (backward-up-list 1) | 208 | (progn (backward-up-list 1) |
| 207 | (setq depth (1+ depth))) | 209 | (setq depth (1+ depth))) |
| @@ -239,15 +241,15 @@ by `lisp-body-indent'." | |||
| 239 | (setq tem (car method)) | 241 | (setq tem (car method)) |
| 240 | 242 | ||
| 241 | (or (eq tem 'nil) ;default indentation | 243 | (or (eq tem 'nil) ;default indentation |
| 242 | ; (eq tem '&lambda) ;abbrev for (&whole 4 (&rest 1)) | 244 | (eq tem '&lambda) ;lambda list |
| 243 | (and (eq tem '&body) (null (cdr method))) | 245 | (and (eq tem '&body) (null (cdr method))) |
| 244 | (and (eq tem '&rest) | 246 | (and (eq tem '&rest) |
| 245 | (consp (cdr method)) (null (cdr (cdr method)))) | 247 | (consp (cdr method)) (null (cddr method))) |
| 246 | (integerp tem) ;explicit indentation specified | 248 | (integerp tem) ;explicit indentation specified |
| 247 | (and (consp tem) ;destructuring | 249 | (and (consp tem) ;destructuring |
| 248 | (eq (car tem) '&whole) | 250 | (eq (car tem) '&whole) |
| 249 | (or (symbolp (car (cdr tem))) | 251 | (or (symbolp (cadr tem)) |
| 250 | (integerp (car (cdr tem))))) | 252 | (integerp (cadr tem)))) |
| 251 | (and (symbolp tem) ;a function to call to do the work. | 253 | (and (symbolp tem) ;a function to call to do the work. |
| 252 | (null (cdr method))) | 254 | (null (cdr method))) |
| 253 | (lisp-indent-report-bad-format method)) | 255 | (lisp-indent-report-bad-format method)) |
| @@ -277,14 +279,13 @@ by `lisp-body-indent'." | |||
| 277 | (throw 'exit normal-indent))) | 279 | (throw 'exit normal-indent))) |
| 278 | ((eq tem 'nil) | 280 | ((eq tem 'nil) |
| 279 | (throw 'exit (list normal-indent containing-form-start))) | 281 | (throw 'exit (list normal-indent containing-form-start))) |
| 280 | ; ((eq tem '&lambda) | 282 | ((eq tem '&lambda) |
| 281 | ; ;; abbrev for (&whole 4 &rest 1) | 283 | (throw 'exit |
| 282 | ; (throw 'exit | 284 | (cond ((null p) |
| 283 | ; (cond ((null p) | 285 | (list (+ sexp-column 4) containing-form-start)) |
| 284 | ; (list (+ sexp-column 4) containing-form-start)) | 286 | ((null (cdr p)) |
| 285 | ; ((null (cdr p)) | 287 | (+ sexp-column 1)) |
| 286 | ; (+ sexp-column 1)) | 288 | (t normal-indent)))) |
| 287 | ; (t normal-indent)))) | ||
| 288 | ((integerp tem) | 289 | ((integerp tem) |
| 289 | (throw 'exit | 290 | (throw 'exit |
| 290 | (if (null p) ;not in subforms | 291 | (if (null p) ;not in subforms |
| @@ -298,9 +299,9 @@ by `lisp-body-indent'." | |||
| 298 | ;; must be a destructing frob | 299 | ;; must be a destructing frob |
| 299 | (if (not (null p)) | 300 | (if (not (null p)) |
| 300 | ;; descend | 301 | ;; descend |
| 301 | (setq method (cdr (cdr tem)) | 302 | (setq method (cddr tem) |
| 302 | n nil) | 303 | n nil) |
| 303 | (setq tem (car (cdr tem))) | 304 | (setq tem (cadr tem)) |
| 304 | (throw 'exit | 305 | (throw 'exit |
| 305 | (cond (tail | 306 | (cond (tail |
| 306 | normal-indent) | 307 | normal-indent) |
| @@ -373,22 +374,21 @@ by `lisp-body-indent'." | |||
| 373 | 374 | ||
| 374 | 375 | ||
| 375 | (let ((l '((block 1) | 376 | (let ((l '((block 1) |
| 376 | (catch 1) | ||
| 377 | (case (4 &rest (&whole 2 &rest 1))) | 377 | (case (4 &rest (&whole 2 &rest 1))) |
| 378 | (ccase . case) (ecase . case) | 378 | (ccase . case) (ecase . case) |
| 379 | (typecase . case) (etypecase . case) (ctypecase . case) | 379 | (typecase . case) (etypecase . case) (ctypecase . case) |
| 380 | (catch 1) | 380 | (catch 1) |
| 381 | (cond (&rest (&whole 2 &rest 1))) | 381 | (cond (&rest (&whole 2 &rest 1))) |
| 382 | (block 1) | ||
| 383 | (defvar (4 2 2)) | 382 | (defvar (4 2 2)) |
| 384 | (defconstant . defvar) | 383 | (defconstant . defvar) |
| 384 | (defcustom (4 2 2 2)) | ||
| 385 | (defparameter . defvar) | 385 | (defparameter . defvar) |
| 386 | (define-modify-macro | 386 | (define-modify-macro |
| 387 | (4 &body)) | 387 | (4 &body)) |
| 388 | (define-setf-method | 388 | (defsetf (4 &lambda 4 &body)) |
| 389 | (4 (&whole 4 &rest 1) &body)) | 389 | (defun (4 &lambda &body)) |
| 390 | (defsetf (4 (&whole 4 &rest 1) 4 &body)) | 390 | (define-setf-method . defun) |
| 391 | (defun (4 (&whole 4 &rest 1) &body)) | 391 | (define-setf-expander . defun) |
| 392 | (defmacro . defun) (deftype . defun) | 392 | (defmacro . defun) (deftype . defun) |
| 393 | (defpackage (4 2)) | 393 | (defpackage (4 2)) |
| 394 | (defstruct ((&whole 4 &rest (&whole 2 &rest 1)) | 394 | (defstruct ((&whole 4 &rest (&whole 2 &rest 1)) |
| @@ -400,19 +400,16 @@ by `lisp-body-indent'." | |||
| 400 | (dolist ((&whole 4 2 1) &body)) | 400 | (dolist ((&whole 4 2 1) &body)) |
| 401 | (dotimes . dolist) | 401 | (dotimes . dolist) |
| 402 | (eval-when 1) | 402 | (eval-when 1) |
| 403 | (flet ((&whole 4 &rest (&whole 1 (&whole 4 &rest 1) &body)) | 403 | (flet ((&whole 4 &rest (&whole 1 &lambda &body)) &body)) |
| 404 | &body)) | ||
| 405 | (labels . flet) | 404 | (labels . flet) |
| 406 | (macrolet . flet) | 405 | (macrolet . flet) |
| 407 | (handler-case (4 &rest (&whole 2 (&whole 4 &rest 1) &body))) | 406 | (handler-case (4 &rest (&whole 2 &lambda &body))) |
| 408 | (restart-case . handler-case) | 407 | (restart-case . handler-case) |
| 409 | ;; `else-body' style | 408 | ;; `else-body' style |
| 410 | (if (nil nil &body)) | 409 | (if (nil nil &body)) |
| 411 | ;; single-else style (then and else equally indented) | 410 | ;; single-else style (then and else equally indented) |
| 412 | (if (&rest nil)) | 411 | (if (&rest nil)) |
| 413 | ;; (lambda ((&whole 4 &rest 1) &body)) | 412 | (lambda (&lambda &rest lisp-indent-function-lambda-hack)) |
| 414 | (lambda ((&whole 4 &rest 1) | ||
| 415 | &rest lisp-indent-function-lambda-hack)) | ||
| 416 | (let ((&whole 4 &rest (&whole 1 1 2)) &body)) | 413 | (let ((&whole 4 &rest (&whole 1 1 2)) &body)) |
| 417 | (let* . let) | 414 | (let* . let) |
| 418 | (compiler-let . let) ;barf | 415 | (compiler-let . let) ;barf |
| @@ -428,7 +425,7 @@ by `lisp-body-indent'." | |||
| 428 | (4 2)) | 425 | (4 2)) |
| 429 | (multiple-value-setf . multiple-value-setq) | 426 | (multiple-value-setf . multiple-value-setq) |
| 430 | ;; Combines the worst features of BLOCK, LET and TAGBODY | 427 | ;; Combines the worst features of BLOCK, LET and TAGBODY |
| 431 | (prog ((&whole 4 &rest 1) &rest lisp-indent-tagbody)) | 428 | (prog (&lambda &rest lisp-indent-tagbody)) |
| 432 | (prog* . prog) | 429 | (prog* . prog) |
| 433 | (prog1 1) | 430 | (prog1 1) |
| 434 | (prog2 2) | 431 | (prog2 2) |
| @@ -443,10 +440,10 @@ by `lisp-body-indent'." | |||
| 443 | (when 1) | 440 | (when 1) |
| 444 | (with-standard-io-syntax (2))))) | 441 | (with-standard-io-syntax (2))))) |
| 445 | (while l | 442 | (while l |
| 446 | (put (car (car l)) 'common-lisp-indent-function | 443 | (put (caar l) 'common-lisp-indent-function |
| 447 | (if (symbolp (cdr (car l))) | 444 | (if (symbolp (cdar l)) |
| 448 | (get (cdr (car l)) 'common-lisp-indent-function) | 445 | (get (cdar l) 'common-lisp-indent-function) |
| 449 | (car (cdr (car l))))) | 446 | (car (cdar l)))) |
| 450 | (setq l (cdr l)))) | 447 | (setq l (cdr l)))) |
| 451 | 448 | ||
| 452 | 449 | ||