blob: 4144fb05211fb5593385a034b9821afd1749d8a5 [file] [log] [blame]
Bram Moolenaar8eba2bd2022-06-22 19:59:28 +01001" Tests for 'lispwords' settings being global-local.
2" And other lisp indent stuff.
Bram Moolenaar6cd13452015-12-03 16:54:53 +01003
4set nocompatible viminfo+=nviminfo
5
6func Test_global_local_lispwords()
7 setglobal lispwords=foo,bar,baz
8 setlocal lispwords-=foo | setlocal lispwords+=quux
9 call assert_equal('foo,bar,baz', &g:lispwords)
10 call assert_equal('bar,baz,quux', &l:lispwords)
11 call assert_equal('bar,baz,quux', &lispwords)
12
13 setlocal lispwords<
14 call assert_equal('foo,bar,baz', &g:lispwords)
15 call assert_equal('foo,bar,baz', &l:lispwords)
16 call assert_equal('foo,bar,baz', &lispwords)
17endfunc
Bram Moolenaardb510072017-09-28 21:52:17 +020018
19func Test_lisp_indent()
20 enew!
21
22 call append(0, [
23 \ '(defun html-file (base)',
24 \ '(format nil "~(~A~).html" base))',
25 \ '',
26 \ '(defmacro page (name title &rest body)',
27 \ '(let ((ti (gensym)))',
28 \ '`(with-open-file (*standard-output*',
29 \ '(html-file ,name)',
30 \ ':direction :output',
31 \ ':if-exists :supersede)',
32 \ '(let ((,ti ,title))',
33 \ '(as title ,ti)',
34 \ '(with center ',
35 \ '(as h2 (string-upcase ,ti)))',
36 \ '(brs 3)',
37 \ ',@body))))',
38 \ '',
39 \ ';;; Utilities for generating links',
40 \ '',
41 \ '(defmacro with-link (dest &rest body)',
42 \ '`(progn',
43 \ '(format t "<a href=\"~A\">" (html-file ,dest))',
44 \ ',@body',
45 \ '(princ "</a>")))'
46 \ ])
Bram Moolenaar02b31112019-08-31 22:16:38 +020047 call assert_equal(7, lispindent(2))
48 call assert_equal(5, 6->lispindent())
Bram Moolenaarbd7206e2020-03-06 20:36:04 +010049 call assert_equal(-1, lispindent(-1))
Bram Moolenaar02b31112019-08-31 22:16:38 +020050
Bram Moolenaardb510072017-09-28 21:52:17 +020051 set lisp
52 set lispwords&
53 let save_copt = &cpoptions
54 set cpoptions+=p
55 normal 1G=G
56
57 call assert_equal([
58 \ '(defun html-file (base)',
59 \ ' (format nil "~(~A~).html" base))',
60 \ '',
61 \ '(defmacro page (name title &rest body)',
62 \ ' (let ((ti (gensym)))',
63 \ ' `(with-open-file (*standard-output*',
64 \ ' (html-file ,name)',
65 \ ' :direction :output',
66 \ ' :if-exists :supersede)',
67 \ ' (let ((,ti ,title))',
68 \ ' (as title ,ti)',
69 \ ' (with center ',
70 \ ' (as h2 (string-upcase ,ti)))',
71 \ ' (brs 3)',
72 \ ' ,@body))))',
73 \ '',
74 \ ';;; Utilities for generating links',
75 \ '',
76 \ '(defmacro with-link (dest &rest body)',
77 \ ' `(progn',
78 \ ' (format t "<a href=\"~A\">" (html-file ,dest))',
79 \ ' ,@body',
80 \ ' (princ "</a>")))',
81 \ ''
82 \ ], getline(1, "$"))
83
84 enew!
85 let &cpoptions=save_copt
Bram Moolenaarce11de82017-10-26 22:00:00 +020086 set nolisp
Bram Moolenaardb510072017-09-28 21:52:17 +020087endfunc
Bram Moolenaarbd7206e2020-03-06 20:36:04 +010088
Bram Moolenaar8eba2bd2022-06-22 19:59:28 +010089func Test_lisp_indent_works()
90 " This was reading beyond the end of the line
91 new
92 exe "norm a\tΓΌ(\<CR>="
93 set lisp
94 norm ==
95 bwipe!
96endfunc
97
Bram Moolenaarbd7206e2020-03-06 20:36:04 +010098" vim: shiftwidth=2 sts=2 expandtab