;;;; -*- mode: lisp -*-
;;;;
;;;; This file is .txt, because it's not meant to be evaluated.
;;;; common-lisp-run-indentation-tests in slime-cl-ident.el
;;;; parses this and runs the specified tests.

;;; Test: 1

(defun foo ()
  t)

;;; Test: 2
;;
;; lisp-lambda-list-keyword-parameter-alignment: nil
;; lisp-lambda-list-keyword-alignment: nil

(defun foo (foo &optional opt1
                  opt2
            &rest rest)
  (list foo opt1 opt2
        rest))

;;; Test: 3
;;
;; lisp-lambda-list-keyword-parameter-alignment: t
;; lisp-lambda-list-keyword-alignment: nil

(defun foo (foo &optional opt1
                          opt2
            &rest rest)
  (list foo opt1 opt2
        rest))

;;; Test: 4
;;
;; lisp-lambda-list-keyword-parameter-alignment: nil
;; lisp-lambda-list-keyword-alignment: t

(defun foo (foo &optional opt1
                  opt2
                &rest rest)
  (list foo opt1 opt2
        rest))

;;; Test: 5
;;
;; lisp-lambda-list-keyword-parameter-alignment: t
;; lisp-lambda-list-keyword-alignment: t

(defun foo (foo &optional opt1
                          opt2
                &rest rest)
  (list foo opt1 opt2
        rest))

;;; Test: 6
;;
;; lisp-lambda-list-keyword-parameter-alignment: nil
;; lisp-lambda-list-keyword-alignment: nil

(defmacro foo ((foo &optional opt1
                      opt2
                &rest rest))
  (list foo opt1 opt2
        rest))

;;; Test: 7
;;
;; lisp-lambda-list-keyword-parameter-alignment: t
;; lisp-lambda-list-keyword-alignment: nil

(defmacro foo ((foo &optional opt1
                              opt2
                &rest rest))
  (list foo opt1 opt2
        rest))

;;; Test: 8
;;
;; lisp-lambda-list-keyword-parameter-alignment: nil
;; lisp-lambda-list-keyword-alignment: t

(defmacro foo ((foo &optional opt1
                      opt2
                    &rest rest))
  (list foo opt1 opt2
        rest))

;;; Test: 9
;;
;; lisp-lambda-list-keyword-parameter-alignment: t
;; lisp-lambda-list-keyword-alignment: t

(defmacro foo ((foo &optional opt1
                              opt2
                    &rest rest))
  (list foo opt1 opt2
        rest))

;;; Test: 10

(let ((x y)
      (foo #-foo (no-foo)
           #+foo (yes-foo))
      (bar #-bar
           (no-bar)
           #+bar
           (yes-bar)))
  (list foo bar
        x))

;;; Test: 11
;;
;; lisp-loop-indent-subclauses: t

(loop for i from 0 below 2
      for j from 0 below 2
      when foo
        do (fubar)
           (bar)
           (moo)
        and collect cash
              into honduras
      else do ;; this is the body of the first else
              ;; the body is ...
              (indented to the above comment)
              (ZMACS gets this wrong)
           and do this
           and do that
           and when foo
                 do the-other
                 and cry
      when this-is-a-short-condition do
        (body code of the when)
      when here's something I used to botch do (here is a body)
                                               (rest of body indented same)
      do
         (exdented loop body)
         (I'm not sure I like this but it's compatible)
      when funny-predicate do ;; Here's a comment
                              (body filled to comment))

;;; Test: 12

(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))))))

;;; Test: 13

(if* (eq t nil)
   then ()
        ()
 elseif (dsf)
   thenret x
   else (balbkj)
        (sdf))

;;; Test: 14

(list foo #+foo (foo)
          #-foo (no-foo))

;;; Test: 15
;;
;; lisp-loop-indent-subclauses: t

(loop for x in foo1
      for y in quux1
      )

;;; Test: 16
;;
;; lisp-loop-indent-subclauses: nil

(loop for x in foo1
      for y in quux1
      )

;;; Test: 17
;;
;; lisp-loop-indent-subclauses: nil
;; lisp-loop-indent-forms-like-keywords: t

(loop for x in foo
      for y in quux
      finally (foo)
              (fo)
              (zoo)
      do
      (print x)
      (print y)
      (print 'ok!))

;;; Test: 18
;;
;; lisp-loop-indent-subclauses: nil
;; lisp-loop-indent-forms-like-keywords: nil

(loop for x in foo
      for y in quux
      finally (foo)
              (fo)
              (zoo)
      do
         (print x)
         (print y)
         (print 'ok!))

;;; Test: 19
;;
;; lisp-loop-indent-subclauses: t
;; lisp-loop-indent-forms-like-keywords: nil

(loop for x in foo
      for y in quux
      finally (foo)
              (fo)
              (zoo)
      do
         (print x)
         (print y)
         (print 'ok!))

;;; Test: 20
;;
;; lisp-loop-indent-subclauses: nil
;; lisp-loop-indent-forms-like-keywords: nil

(loop for f in files
      collect (open f
                    :direction :output)
      do (foo) (bar)
         (quux))

;;; Test: 21
;;
;; lisp-loop-indent-subclauses: t

(loop for f in files
      collect (open f
                    :direction :output)
      do (foo) (bar)
         (quux))

;;; Test: 22

(defsetf foo bar
  "the doc string")

;;; Test: 23

(defsetf foo
    bar
  "the doc string")

;;; Test: 24
;;
;; lisp-lambda-list-keyword-parameter-alignment: t

(defsetf foo (x y &optional a
                            z)
    (a b c)
  stuff)

;;; Test: 25
;;
;; lisp-align-keywords-in-calls: t

(make-instance 'foo :bar t :quux t
                    :zot t)

;;; Test: 26
;;
;; lisp-align-keywords-in-calls: nil

(make-instance 'foo :bar t :quux t
               :zot t)

;;; Test: 27
;;
;; lisp-lambda-list-indentation: nil

(defun example (a b &optional o1 o2
                o3 o4
                &rest r
                &key k1 k2
                k3 k4)
  'hello)

;;; Test: 28
;;
;; lisp-lambda-list-keyword-parameter-alignment: t
;; lisp-lambda-list-keyword-alignment: t

(destructuring-bind (foo &optional x
                                   y
                         &key bar
                              quux)
    foo
  body)

;;; Test: 29
;;
;; lisp-lambda-list-keyword-parameter-alignment: t
;; lisp-lambda-list-keyword-alignment: t

(named-lambda foo
    (x &optional y
                 z
       &rest more)
  body)

;;; Test: 30

(foo fii
     (or x
         y) t
     bar)

;;; Test: 31

(foo
 (bar))

;;; Test: 32
;;
;; comment-indent-function: (lambda () nil)
;; comment-column: nil

(unknown (;; KLUDGE: comment-indent hackery to get
          ;; the comment right. Otherwise we get a
          ;; space before the first ;.
          bar quux
          zot)
         (#|fii|#
          zot)
         (
          quux))

;;; Test: 33

(complex-indent.1 ((x z
                    f
                    ((fox foo
                          foo))
                    :note (ding bar quux
                                zot)
                    :wait (this! is
                                 a funcall))
                    ;; Not 100% sure this should not be a step left.
                    (abbb)
                    (abb))
  (bodyform)
  (another))

;;; Test: 34

(complex-indent.2 (bar quux
                       zot)
    (a b
     c d)
  (form1)
  (form2))

;;; Test: 35

(complex-indent.3 (:wait fii
                         (this is
                               a funcall))
  (bodyform)
  (another))

;;; Test: 36

(defmacro foo (body)
  `(let (,@(stuff)
         ,(more-stuff)
         ,(even-more)
         (foo foo))
     ,@bofy))

;;; Test: 37

(defun foo ()
  `(list foo bar
         ,@(quux fo
                 foo)))

;;; Test: 38

(defmacro foofoo (body)
  `(foo
    `(let (,',@,(stuff)
           ,(more-stuff)
           ,(even-more)
           (foo foo))
       ,@bofy)))

;;; Test: 39
;;
;; lisp-lambda-list-keyword-parameter-alignment: t
;; lisp-lambda-list-keyword-alignment: t

(defstruct (foo (:constructor make-foo (&optional bar
                                                  quux
                                        &key zot
                                             fii)))
  bar
  quux
  zot
  fii)

;;; Test: 40
;;
;; lisp-lambda-list-keyword-parameter-alignment: t
;; lisp-lambda-list-keyword-alignment: t

(defmethod foo :around (zot &key x
                                 y)
  (list zot))

;;; Test: 41
;;
;; lisp-lambda-list-keyword-parameter-alignment: t
;; lisp-lambda-list-keyword-alignment: t

(progn
  (defmethod foo :around (fii &key x
                                   y)
    (list fii)))

;;; Test: 42
;;
;; lisp-lambda-list-keyword-parameter-alignment: t
;; lisp-lambda-list-keyword-alignment: t

(progn
  (defgeneric foo (x y &optional a
                                 b)
    (:method :around (a b &optional x
                                    y)
      (list a b x y))))

;;; Test: 43
;;
;; lisp-lambda-list-keyword-parameter-alignment: t
;; lisp-lambda-list-keyword-alignment: t

(defgeneric foo (x &optional a b)
  (:method (x y &optional a
                          b)
    (list x y a b)))

;;; Test: 44

(let (definer
      foo
      bar
      quux)
  ...)

;;; Test: 45

(let (definition
      foo
      bar
      quux)
  ...)

;;; Test: 46

(let (foo bar
      quux)
  ...)

;;; Test: 47

(with-compilation-unit 
    (:foo t
     :quux nil)
  ...)

;;; Test: 48

(cond
  ((> x y) (foo)
   ;; This isn't ideal -- I at least would align with (FOO here.
   (bar) (quux)
   (zot))
  (qux (foo)
       (bar)
       (zot))
  (zot
   (foo)
   (foo2))
  (t (foo)
     (bar)))

;;; Test: 49

(cond ((> x y) (foo)
       ;; This isn't ideal -- I at least would align with (FOO here.
       (bar))
      (qux (foo)
           (bar))
      (zot
       (foo))
      (t (foo)
         (bar)))
