Patch 9.0.0737
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.
Files: src/indent.c, src/testdir/test_lispwords.vim,
src/testdir/test_lispindent.vim, src/testdir/test_cpoptions.vim,
src/testdir/test_alot.vim, src/testdir/Make_all.mak
*** ../vim-9.0.0736/src/indent.c 2022-10-01 20:17:13.820291832 +0100
--- src/indent.c 2022-10-13 12:14:22.381693812 +0100
***************
*** 1952,1958 ****
{
(void)copy_option_part(&word, buf, LSIZE, ",");
len = (int)STRLEN(buf);
! if (STRNCMP(buf, p, len) == 0 && p[len] == ' ')
return TRUE;
}
return FALSE;
--- 1952,1958 ----
{
(void)copy_option_part(&word, buf, LSIZE, ",");
len = (int)STRLEN(buf);
! if (STRNCMP(buf, p, len) == 0 && IS_WHITE_OR_NUL(p[len]))
return TRUE;
}
return FALSE;
*** ../vim-9.0.0736/src/testdir/test_lispwords.vim 2022-06-22 19:37:56.000000000 +0100
--- src/testdir/test_lispwords.vim 1970-01-01 00:00:00.000000000 +0000
***************
*** 1,98 ****
- " Tests for 'lispwords' settings being global-local.
- " And other lisp indent stuff.
-
- set nocompatible viminfo+=nviminfo
-
- func Test_global_local_lispwords()
- setglobal lispwords=foo,bar,baz
- setlocal lispwords-=foo | setlocal lispwords+=quux
- call assert_equal('foo,bar,baz', &g:lispwords)
- call assert_equal('bar,baz,quux', &l:lispwords)
- call assert_equal('bar,baz,quux', &lispwords)
-
- setlocal lispwords<
- call assert_equal('foo,bar,baz', &g:lispwords)
- call assert_equal('foo,bar,baz', &l:lispwords)
- call assert_equal('foo,bar,baz', &lispwords)
- endfunc
-
- func Test_lisp_indent()
- enew!
-
- call append(0, [
- \ '(defun html-file (base)',
- \ '(format nil "~(~A~).html" base))',
- \ '',
- \ '(defmacro page (name title &rest body)',
- \ '(let ((ti (gensym)))',
- \ '`(with-open-file (*standard-output*',
- \ '(html-file ,name)',
- \ ':direction :output',
- \ ':if-exists :supersede)',
- \ '(let ((,ti ,title))',
- \ '(as title ,ti)',
- \ '(with center ',
- \ '(as h2 (string-upcase ,ti)))',
- \ '(brs 3)',
- \ ',@body))))',
- \ '',
- \ ';;; Utilities for generating links',
- \ '',
- \ '(defmacro with-link (dest &rest body)',
- \ '`(progn',
- \ '(format t "<a href=\"~A\">" (html-file ,dest))',
- \ ',@body',
- \ '(princ "</a>")))'
- \ ])
- call assert_equal(7, lispindent(2))
- call assert_equal(5, 6->lispindent())
- call assert_equal(-1, lispindent(-1))
-
- set lisp
- set lispwords&
- let save_copt = &cpoptions
- set cpoptions+=p
- normal 1G=G
-
- call assert_equal([
- \ '(defun html-file (base)',
- \ ' (format nil "~(~A~).html" base))',
- \ '',
- \ '(defmacro page (name title &rest body)',
- \ ' (let ((ti (gensym)))',
- \ ' `(with-open-file (*standard-output*',
- \ ' (html-file ,name)',
- \ ' :direction :output',
- \ ' :if-exists :supersede)',
- \ ' (let ((,ti ,title))',
- \ ' (as title ,ti)',
- \ ' (with center ',
- \ ' (as h2 (string-upcase ,ti)))',
- \ ' (brs 3)',
- \ ' ,@body))))',
- \ '',
- \ ';;; Utilities for generating links',
- \ '',
- \ '(defmacro with-link (dest &rest body)',
- \ ' `(progn',
- \ ' (format t "<a href=\"~A\">" (html-file ,dest))',
- \ ' ,@body',
- \ ' (princ "</a>")))',
- \ ''
- \ ], getline(1, "$"))
-
- enew!
- let &cpoptions=save_copt
- set nolisp
- endfunc
-
- func Test_lisp_indent_works()
- " This was reading beyond the end of the line
- new
- exe "norm a\tü(\<CR>="
- set lisp
- norm ==
- bwipe!
- endfunc
-
- " vim: shiftwidth=2 sts=2 expandtab
--- 0 ----
*** ../vim-9.0.0736/src/testdir/test_lispindent.vim 2022-10-13 12:29:26.293463598 +0100
--- src/testdir/test_lispindent.vim 2022-10-13 12:21:15.901010895 +0100
***************
*** 0 ****
--- 1,103 ----
+ " Tests for 'lispwords' settings being global-local.
+ " And other lisp indent stuff.
+
+ set nocompatible viminfo+=nviminfo
+
+ func Test_global_local_lispwords()
+ setglobal lispwords=foo,bar,baz
+ setlocal lispwords-=foo | setlocal lispwords+=quux
+ call assert_equal('foo,bar,baz', &g:lispwords)
+ call assert_equal('bar,baz,quux', &l:lispwords)
+ call assert_equal('bar,baz,quux', &lispwords)
+
+ setlocal lispwords<
+ call assert_equal('foo,bar,baz', &g:lispwords)
+ call assert_equal('foo,bar,baz', &l:lispwords)
+ call assert_equal('foo,bar,baz', &lispwords)
+ endfunc
+
+ def Test_lisp_indent()
+ enew!
+
+ append(0, [
+ '(defun html-file (base)',
+ '(format nil "~(~A~).html" base))',
+ '',
+ '(defmacro page (name title &rest body)',
+ '(let ((ti (gensym)))',
+ '`(with-open-file (*standard-output*',
+ '(html-file ,name)',
+ ':direction :output',
+ ':if-exists :supersede)',
+ '(let ((,ti ,title))',
+ '(as title ,ti)',
+ '(with center ',
+ '(as h2 (string-upcase ,ti)))',
+ '(brs 3)',
+ ',@body))))',
+ '',
+ ';;; Utilities for generating links',
+ '',
+ '(defmacro with-link (dest &rest body)',
+ '`(progn',
+ '(format t "<a href=\"~A\">" (html-file ,dest))',
+ ',@body',
+ '(princ "</a>")))'
+ ])
+ assert_equal(7, lispindent(2))
+ assert_equal(5, 6->lispindent())
+ assert_fails('lispindent(-1)', 'E966: Invalid line number: -1')
+
+ set lisp
+ set lispwords&
+ var save_copt = &cpoptions
+ set cpoptions+=p
+ normal 1G=G
+
+ assert_equal([
+ '(defun html-file (base)',
+ ' (format nil "~(~A~).html" base))',
+ '',
+ '(defmacro page (name title &rest body)',
+ ' (let ((ti (gensym)))',
+ ' `(with-open-file (*standard-output*',
+ ' (html-file ,name)',
+ ' :direction :output',
+ ' :if-exists :supersede)',
+ ' (let ((,ti ,title))',
+ ' (as title ,ti)',
+ ' (with center ',
+ ' (as h2 (string-upcase ,ti)))',
+ ' (brs 3)',
+ ' ,@body))))',
+ '',
+ ';;; Utilities for generating links',
+ '',
+ '(defmacro with-link (dest &rest body)',
+ ' `(progn',
+ ' (format t "<a href=\"~A\">" (html-file ,dest))',
+ ' ,@body',
+ ' (princ "</a>")))',
+ ''
+ ], getline(1, "$"))
+
+ enew!
+ &cpoptions = save_copt
+ set nolisp
+ enddef
+
+ func Test_lispindent_negative()
+ " in legacy script there is no error
+ call assert_equal(-1, lispindent(-1))
+ endfunc
+
+ func Test_lisp_indent_works()
+ " This was reading beyond the end of the line
+ new
+ exe "norm a\tü(\<CR>="
+ set lisp
+ norm ==
+ bwipe!
+ endfunc
+
+ " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-9.0.0736/src/testdir/test_cpoptions.vim 2022-09-08 16:39:16.912140162 +0100
--- src/testdir/test_cpoptions.vim 2022-10-13 12:24:16.272554927 +0100
***************
*** 422,428 ****
let &cpo = save_cpo
endfunc
! " Test for the 'p' flag in 'cpo' is in the test_lispwords.vim file.
" Test for the 'P' flag in 'cpo' (appending to a file sets the current file
" name)
--- 422,428 ----
let &cpo = save_cpo
endfunc
! " Test for the 'p' flag in 'cpo' is in the test_lispindent.vim file.
" Test for the 'P' flag in 'cpo' (appending to a file sets the current file
" name)
*** ../vim-9.0.0736/src/testdir/test_alot.vim 2022-07-23 06:24:56.405106035 +0100
--- src/testdir/test_alot.vim 2022-10-13 12:22:29.244833704 +0100
***************
*** 16,22 ****
source test_ga.vim
source test_glob2regpat.vim
source test_global.vim
- source test_lispwords.vim
source test_move.vim
source test_put.vim
source test_reltime.vim
--- 16,21 ----
*** ../vim-9.0.0736/src/testdir/Make_all.mak 2022-10-04 16:23:39.006042192 +0100
--- src/testdir/Make_all.mak 2022-10-13 12:23:35.904662635 +0100
***************
*** 182,188 ****
test_largefile \
test_let \
test_lineending \
! test_lispwords \
test_listchars \
test_listdict \
test_listener \
--- 182,188 ----
test_largefile \
test_let \
test_lineending \
! test_lispindent \
test_listchars \
test_listdict \
test_listener \
***************
*** 427,432 ****
--- 427,433 ----
test_langmap.res \
test_let.res \
test_lineending.res \
+ test_lispindent.res \
test_listchars.res \
test_listdict.res \
test_listener.res \
*** ../vim-9.0.0736/src/version.c 2022-10-13 11:59:18.845930012 +0100
--- src/version.c 2022-10-13 12:15:38.613620292 +0100
***************
*** 701,702 ****
--- 701,704 ----
{ /* Add new patch number below this line */
+ /**/
+ 737,
/**/
--
We learn from our mistakes. Politicians don't make mistakes.
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///