annotate src/testdir/test_lispindent.vim @ 30805:4edfa418f8ba v9.0.0737

patch 9.0.0737: Lisp word only recognized when a space follows Commit: https://github.com/vim/vim/commit/d26c5805bcbd630dab0478c2d22503a6e32a83c1 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Oct 13 12:30:08 2022 +0100 patch 9.0.0737: Lisp word only recognized when a space follows Problem: Lisp word only recognized when a space follows. Solution: Also match a word at the end of a line. Rename the test. Use a compiled function to avoid backslashes.
author Bram Moolenaar <Bram@vim.org>
date Thu, 13 Oct 2022 13:45:06 +0200
parents
children 942f1b3bc694
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30805
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 " Tests for 'lispwords' settings being global-local.
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2 " And other lisp indent stuff.
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4 set nocompatible viminfo+=nviminfo
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 func Test_global_local_lispwords()
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 setglobal lispwords=foo,bar,baz
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 setlocal lispwords-=foo | setlocal lispwords+=quux
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 call assert_equal('foo,bar,baz', &g:lispwords)
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 call assert_equal('bar,baz,quux', &l:lispwords)
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 call assert_equal('bar,baz,quux', &lispwords)
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13 setlocal lispwords<
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 call assert_equal('foo,bar,baz', &g:lispwords)
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15 call assert_equal('foo,bar,baz', &l:lispwords)
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 call assert_equal('foo,bar,baz', &lispwords)
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 endfunc
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 def Test_lisp_indent()
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 enew!
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 append(0, [
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 '(defun html-file (base)',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 '(format nil "~(~A~).html" base))',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 '',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 '(defmacro page (name title &rest body)',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 '(let ((ti (gensym)))',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 '`(with-open-file (*standard-output*',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 '(html-file ,name)',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 ':direction :output',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 ':if-exists :supersede)',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 '(let ((,ti ,title))',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 '(as title ,ti)',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 '(with center ',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 '(as h2 (string-upcase ,ti)))',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 '(brs 3)',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 ',@body))))',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 '',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 ';;; Utilities for generating links',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 '',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 '(defmacro with-link (dest &rest body)',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 '`(progn',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 '(format t "<a href=\"~A\">" (html-file ,dest))',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 ',@body',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 '(princ "</a>")))'
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 ])
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 assert_equal(7, lispindent(2))
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 assert_equal(5, 6->lispindent())
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 assert_fails('lispindent(-1)', 'E966: Invalid line number: -1')
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 set lisp
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 set lispwords&
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 var save_copt = &cpoptions
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 set cpoptions+=p
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 normal 1G=G
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 assert_equal([
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 '(defun html-file (base)',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59 ' (format nil "~(~A~).html" base))',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 '',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 '(defmacro page (name title &rest body)',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 ' (let ((ti (gensym)))',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 ' `(with-open-file (*standard-output*',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64 ' (html-file ,name)',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 ' :direction :output',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66 ' :if-exists :supersede)',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 ' (let ((,ti ,title))',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 ' (as title ,ti)',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69 ' (with center ',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 ' (as h2 (string-upcase ,ti)))',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71 ' (brs 3)',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72 ' ,@body))))',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 '',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 ';;; Utilities for generating links',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 '',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 '(defmacro with-link (dest &rest body)',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77 ' `(progn',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 ' (format t "<a href=\"~A\">" (html-file ,dest))',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 ' ,@body',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 ' (princ "</a>")))',
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 ''
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82 ], getline(1, "$"))
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 enew!
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 &cpoptions = save_copt
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86 set nolisp
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87 enddef
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 func Test_lispindent_negative()
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90 " in legacy script there is no error
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 call assert_equal(-1, lispindent(-1))
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 endfunc
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 func Test_lisp_indent_works()
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95 " This was reading beyond the end of the line
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 new
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 exe "norm a\tü(\<CR>="
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98 set lisp
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99 norm ==
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100 bwipe!
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 endfunc
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102
4edfa418f8ba patch 9.0.0737: Lisp word only recognized when a space follows
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
103 " vim: shiftwidth=2 sts=2 expandtab