blob: aa5a738bdf2b99094874755b93aa9033df2bae60 [file] [log] [blame]
Bram Moolenaar6cd13452015-12-03 16:54:53 +01001" Tests for 'lispwords' settings being global-local
2
3set nocompatible viminfo+=nviminfo
4
5func Test_global_local_lispwords()
6 setglobal lispwords=foo,bar,baz
7 setlocal lispwords-=foo | setlocal lispwords+=quux
8 call assert_equal('foo,bar,baz', &g:lispwords)
9 call assert_equal('bar,baz,quux', &l:lispwords)
10 call assert_equal('bar,baz,quux', &lispwords)
11
12 setlocal lispwords<
13 call assert_equal('foo,bar,baz', &g:lispwords)
14 call assert_equal('foo,bar,baz', &l:lispwords)
15 call assert_equal('foo,bar,baz', &lispwords)
16endfunc
Bram Moolenaardb510072017-09-28 21:52:17 +020017
18func Test_lisp_indent()
19 enew!
20
21 call append(0, [
22 \ '(defun html-file (base)',
23 \ '(format nil "~(~A~).html" base))',
24 \ '',
25 \ '(defmacro page (name title &rest body)',
26 \ '(let ((ti (gensym)))',
27 \ '`(with-open-file (*standard-output*',
28 \ '(html-file ,name)',
29 \ ':direction :output',
30 \ ':if-exists :supersede)',
31 \ '(let ((,ti ,title))',
32 \ '(as title ,ti)',
33 \ '(with center ',
34 \ '(as h2 (string-upcase ,ti)))',
35 \ '(brs 3)',
36 \ ',@body))))',
37 \ '',
38 \ ';;; Utilities for generating links',
39 \ '',
40 \ '(defmacro with-link (dest &rest body)',
41 \ '`(progn',
42 \ '(format t "<a href=\"~A\">" (html-file ,dest))',
43 \ ',@body',
44 \ '(princ "</a>")))'
45 \ ])
Bram Moolenaar02b31112019-08-31 22:16:38 +020046 call assert_equal(7, lispindent(2))
47 call assert_equal(5, 6->lispindent())
48
Bram Moolenaardb510072017-09-28 21:52:17 +020049 set lisp
50 set lispwords&
51 let save_copt = &cpoptions
52 set cpoptions+=p
53 normal 1G=G
54
55 call assert_equal([
56 \ '(defun html-file (base)',
57 \ ' (format nil "~(~A~).html" base))',
58 \ '',
59 \ '(defmacro page (name title &rest body)',
60 \ ' (let ((ti (gensym)))',
61 \ ' `(with-open-file (*standard-output*',
62 \ ' (html-file ,name)',
63 \ ' :direction :output',
64 \ ' :if-exists :supersede)',
65 \ ' (let ((,ti ,title))',
66 \ ' (as title ,ti)',
67 \ ' (with center ',
68 \ ' (as h2 (string-upcase ,ti)))',
69 \ ' (brs 3)',
70 \ ' ,@body))))',
71 \ '',
72 \ ';;; Utilities for generating links',
73 \ '',
74 \ '(defmacro with-link (dest &rest body)',
75 \ ' `(progn',
76 \ ' (format t "<a href=\"~A\">" (html-file ,dest))',
77 \ ' ,@body',
78 \ ' (princ "</a>")))',
79 \ ''
80 \ ], getline(1, "$"))
81
82 enew!
83 let &cpoptions=save_copt
Bram Moolenaarce11de82017-10-26 22:00:00 +020084 set nolisp
Bram Moolenaardb510072017-09-28 21:52:17 +020085endfunc