⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cl-indent.el

📁 早期freebsd实现
💻 EL
📖 第 1 页 / 共 2 页
字号:
                       normal-indent)))                ((eq tem '&rest)                 ;; this pattern holds for all remaining forms                 (setq tail (> n 0)                       n 0                       method (cdr method)))                ((> n 0)                 ;; try next element of pattern                 (setq n (1- n)                       method (cdr method))                 (if (< n 0)                     ;; Too few elements in pattern.                     (throw 'exit normal-indent)))                ((eq tem 'nil)                 (throw 'exit (list normal-indent containing-form-start)));               ((eq tem '&lambda);                ;; abbrev for (&whole 4 &rest 1);                (throw 'exit;                  (cond ((null p);                         (list (+ sexp-column 4) containing-form-start));                        ((null (cdr p));                         (+ sexp-column 1));                        (t normal-indent))))                ((integerp tem)                 (throw 'exit                   (if (null p)         ;not in subforms                       (list (+ sexp-column tem) containing-form-start)                       normal-indent)))                ((symbolp tem)          ;a function to call                 (throw 'exit                   (funcall tem path state indent-point                            sexp-column normal-indent)))                (t                 ;; must be a destructing frob                 (if (not (null p))                     ;; descend                     (setq method (cdr (cdr tem))                           n nil)                   (setq tem (car (cdr tem)))                   (throw 'exit                     (cond (tail                            normal-indent)                           ((eq tem 'nil)                            (list normal-indent                                  containing-form-start))                           ((integerp tem)                            (list (+ sexp-column tem)                                  containing-form-start))                           (t                            (funcall tem path state indent-point                                     sexp-column normal-indent))))))))))))(defun lisp-indent-tagbody (path state indent-point sexp-column normal-indent)  (if (not (null (cdr path)))      normal-indent    (save-excursion      (goto-char indent-point)      (beginning-of-line)      (skip-chars-forward " \t")      (list (cond ((looking-at "\\sw\\|\\s_")                   ;; a tagbody tag                   (+ sexp-column lisp-tag-indentation))                  ((integerp lisp-tag-body-indentation)                   (+ sexp-column lisp-tag-body-indentation))                  ((eq lisp-tag-body-indentation 't)                   (condition-case ()                       (progn (backward-sexp 1) (current-column))                     (error (1+ sexp-column))))                  (t (+ sexp-column lisp-body-indent)));            (cond ((integerp lisp-tag-body-indentation);                   (+ sexp-column lisp-tag-body-indentation));                  ((eq lisp-tag-body-indentation 't);                   normal-indent);                  (t;                   (+ sexp-column lisp-body-indent)))            (elt state 1)            ))))(defun lisp-indent-do (path state indent-point sexp-column normal-indent)  (if (>= (car path) 3)      (let ((lisp-tag-body-indentation lisp-body-indent))        (funcall (function lisp-indent-tagbody)		 path state indent-point sexp-column normal-indent))    (funcall (function lisp-indent-259)	     '((&whole nil &rest 		;; the following causes wierd indentation 		;;(&whole 1 1 2 nil)		)	       (&whole nil &rest 1))	     path state indent-point sexp-column normal-indent)))(defun lisp-indent-function-lambda-hack (path state indent-point                                         sexp-column normal-indent)  ;; indent (function (lambda () <newline> <body-forms>)) kludgily.  (if (or (cdr path) ; wtf?          (> (car path) 3))      ;; line up under previous body form      normal-indent    ;; line up under function rather than under lambda in order to    ;;  conserve horizontal space.  (Which is what #' is for.)    (condition-case ()        (save-excursion          (backward-up-list 2)          (forward-char 1)          (if (looking-at "\\(lisp:+\\)?function\\(\\Sw\\|\\S_\\)")              (+ lisp-body-indent -1 (current-column))              (+ sexp-column lisp-body-indent)))       (error (+ sexp-column lisp-body-indent)))))(let ((l '((block 1)	   (catch 1)           (case        (4 &rest (&whole 2 &rest 1)))           (ccase . case) (ecase . case)           (typecase . case) (etypecase . case) (ctypecase . case)           (catch 1)           (cond        (&rest (&whole 2 &rest 1)))           (block 1)           (defvar      (4 2 2))           (defconstant . defvar) (defparameter . defvar)           (define-modify-macro                        (4 &body))           (define-setf-method                        (4 (&whole 4 &rest 1) &body))           (defsetf     (4 (&whole 4 &rest 1) 4 &body))           (defun       (4 (&whole 4 &rest 1) &body))           (defmacro . defun) (deftype . defun)           (defstruct   ((&whole 4 &rest (&whole 2 &rest 1))                         &rest (&whole 2 &rest 1)))           (destructuring-bind                        ((&whole 6 &rest 1) 4 &body))           (do          lisp-indent-do)           (do* . do)           (dolist      ((&whole 4 2 1) &body))           (dotimes . dolist)           (eval-when	1)           (flet        ((&whole 4 &rest (&whole 1 (&whole 4 &rest 1) &body))                         &body))           (labels . flet)           (macrolet . flet)           ;; `else-body' style           (if          (nil nil &body))           ;; single-else style (then and else equally indented)           (if          (&rest nil))           ;(lambda     ((&whole 4 &rest 1) &body))           (lambda      ((&whole 4 &rest 1)                         &rest lisp-indent-function-lambda-hack))           (let         ((&whole 4 &rest (&whole 1 1 2)) &body))           (let* . let)           (locally	1)           ;(loop ...)           (multiple-value-bind                        ((&whole 6 &rest 1) 4 &body))           (multiple-value-call			(4 &body))           (multiple-value-list 1)           (multiple-value-prog1 1)           (multiple-value-setq			(4 2))           ;; Combines the worst features of BLOCK, LET and TAGBODY           (prog        ((&whole 4 &rest 1) &rest lisp-indent-tagbody))           (prog* . prog)           (prog1 1)           (prog2 2)           (progn 0)           (progv       (4 4 &body))           (return 0)           (return-from (nil &body))           (tagbody     lisp-indent-tagbody)           (throw 1)           (unless 1)           (unwind-protect                        (5 &body))           (when 1))))  (while l    (put (car (car l)) 'common-lisp-indent-hook         (if (symbolp (cdr (car l)))             (get (cdr (car l)) 'common-lisp-indent-hook)             (car (cdr (car l)))))    (setq l (cdr l))));(defun foo (x);  (tagbody;   foo;     (bar);   baz;     (when (losing);       (with-big-loser;           (yow);         ((lambda ();            foo);          big)));     (flet ((foo (bar baz zap);              (zip));            (zot ();              quux));       (do ();           ((lose);            (foo 1));         (quux);        foo;         (lose));       (cond ((x);              (win 1 2;                   (foo)));             (t;              (lose;                3))))))          ;(put 'while    'common-lisp-indent-hook 1);(put 'defwrapper'common-lisp-indent-hook ...);(put 'def 'common-lisp-indent-hook ...);(put 'defflavor        'common-lisp-indent-hook ...);(put 'defsubst 'common-lisp-indent-hook ...);;(put 'define-restart-name 'common-lisp-indent-hook '1);(put 'with-restart 'common-lisp-indent-hook '((1 4 ((* 1))) (2 &body)));(put 'restart-case 'common-lisp-indent-hook '((1 4) (* 2 ((0 1) (* 1)))));(put 'define-condition 'common-lisp-indent-hook '((1 6) (2 6 ((* 1))) (3 4 ((* 1))) (4 &body)));(put 'with-condition-handler 'common-lisp-indent-hook '((1 4 ((* 1))) (2 &body)));(put 'condition-case 'common-lisp-indent-hook '((1 4) (* 2 ((0 1) (1 3) (2 &body)))));;;; Turn it on.;(setq lisp-indent-hook 'common-lisp-indent-hook);; To disable this stuff, (setq lisp-indent-hook 'lisp-indent-hook)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -