refactor(cpoptions): remove 'p'

Deleting a cpo flag a day keeps the doctor away

We don't need two different ways to indent LISP code
This commit is contained in:
bfredl 2023-10-06 23:01:24 +02:00
parent ddc8dd187d
commit e8acbc1ade
7 changed files with 65 additions and 85 deletions

View File

@ -1720,9 +1720,6 @@ A jump table for the options with a short description can be found at |Q_op|.
when it didn't exist when editing it. This is a when it didn't exist when editing it. This is a
protection against a file unexpectedly created by protection against a file unexpectedly created by
someone else. Vi didn't complain about this. someone else. Vi didn't complain about this.
*cpo-p*
p Vi compatible Lisp indenting. When not present, a
slightly better algorithm is used.
*cpo-P* *cpo-P*
P When included, a ":write" command that appends to a P When included, a ":write" command that appends to a
file will set the file name for the current buffer, if file will set the file name for the current buffer, if

View File

@ -675,7 +675,7 @@ Options:
bioskey (MS-DOS) bioskey (MS-DOS)
conskey (MS-DOS) conskey (MS-DOS)
*'cp'* *'nocompatible'* *'nocp'* *'compatible'* (Nvim is always "nocompatible".) *'cp'* *'nocompatible'* *'nocp'* *'compatible'* (Nvim is always "nocompatible".)
'cpoptions' (gjkHw<*- and all POSIX flags were removed) 'cpoptions' (gjpkHw<*- and all POSIX flags were removed)
*'cryptmethod'* *'cm'* *'key'* (Vim encryption implementation) *'cryptmethod'* *'cm'* *'key'* (Vim encryption implementation)
cscopepathcomp cscopepathcomp
cscopeprg cscopeprg

View File

@ -1296,9 +1296,6 @@ vim.bo.ci = vim.bo.copyindent
--- when it didn't exist when editing it. This is a --- when it didn't exist when editing it. This is a
--- protection against a file unexpectedly created by --- protection against a file unexpectedly created by
--- someone else. Vi didn't complain about this. --- someone else. Vi didn't complain about this.
--- *cpo-p*
--- p Vi compatible Lisp indenting. When not present, a
--- slightly better algorithm is used.
--- *cpo-P* --- *cpo-P*
--- P When included, a ":write" command that appends to a --- P When included, a ":write" command that appends to a
--- file will set the file name for the current buffer, if --- file will set the file name for the current buffer, if

View File

@ -1167,9 +1167,6 @@ int get_lisp_indent(void)
pos_T paren; pos_T paren;
int amount; int amount;
// Set vi_lisp to use the vi-compatible method.
int vi_lisp = (vim_strchr(p_cpo, CPO_LISP) != NULL);
pos_T realpos = curwin->w_cursor; pos_T realpos = curwin->w_cursor;
curwin->w_cursor.col = 0; curwin->w_cursor.col = 0;
@ -1247,9 +1244,6 @@ int get_lisp_indent(void)
char *that = get_cursor_line_ptr(); char *that = get_cursor_line_ptr();
if (vi_lisp && (get_indent() == 0)) {
amount = 2;
} else {
char *line = that; char *line = that;
chartabsize_T cts; chartabsize_T cts;
init_chartabsize_arg(&cts, curwin, pos->lnum, 0, line, line); init_chartabsize_arg(&cts, curwin, pos->lnum, 0, line, line);
@ -1265,8 +1259,7 @@ int get_lisp_indent(void)
// non-standard-lisp ones are Scheme special forms): // non-standard-lisp ones are Scheme special forms):
// (let ((a 1)) instead (let ((a 1)) // (let ((a 1)) instead (let ((a 1))
// (...)) of (...)) // (...)) of (...))
if (!vi_lisp && ((*that == '(') || (*that == '[')) if (((*that == '(') || (*that == '[')) && lisp_match(that + 1)) {
&& lisp_match(that + 1)) {
amount += 2; amount += 2;
} else { } else {
if (*that != NUL) { if (*that != NUL) {
@ -1289,7 +1282,7 @@ int get_lisp_indent(void)
// Not a comment line. // Not a comment line.
// Test *that != '(' to accommodate first let/do // Test *that != '(' to accommodate first let/do
// argument if it is more than one line. // argument if it is more than one line.
if (!vi_lisp && (*that != '(') && (*that != '[')) { if ((*that != '(') && (*that != '[')) {
firsttry++; firsttry++;
} }
@ -1297,14 +1290,11 @@ int get_lisp_indent(void)
init_chartabsize_arg(&cts, curwin, init_chartabsize_arg(&cts, curwin,
(colnr_T)(that - line), amount, line, that); (colnr_T)(that - line), amount, line, that);
if (vi_lisp || ((*that != '"') && (*that != '\'') if (((*that != '"') && (*that != '\'') && (*that != '#')
&& (*that != '#')
&& (((uint8_t)(*that) < '0') || ((uint8_t)(*that) > '9')))) { && (((uint8_t)(*that) < '0') || ((uint8_t)(*that) > '9')))) {
int quotecount = 0; int quotecount = 0;
while (*cts.cts_ptr while (*cts.cts_ptr
&& (!ascii_iswhite(*cts.cts_ptr) || quotecount || parencount) && (!ascii_iswhite(*cts.cts_ptr) || quotecount || parencount)) {
&& (!((*cts.cts_ptr == '(' || *cts.cts_ptr == '[')
&& !quotecount && !parencount && vi_lisp))) {
if (*cts.cts_ptr == '"') { if (*cts.cts_ptr == '"') {
quotecount = !quotecount; quotecount = !quotecount;
} }
@ -1336,7 +1326,6 @@ int get_lisp_indent(void)
} }
} }
} }
}
} else { } else {
amount = 0; // No matching '(' or '[' found, use zero indent. amount = 0; // No matching '(' or '[' found, use zero indent.
} }

View File

@ -151,7 +151,6 @@
#define CPO_NUMCOL 'n' // 'number' column also used for text #define CPO_NUMCOL 'n' // 'number' column also used for text
#define CPO_LINEOFF 'o' #define CPO_LINEOFF 'o'
#define CPO_OVERNEW 'O' // silently overwrite new file #define CPO_OVERNEW 'O' // silently overwrite new file
#define CPO_LISP 'p' // 'lisp' indenting
#define CPO_FNAMEAPP 'P' // set file name for ":w >>file" #define CPO_FNAMEAPP 'P' // set file name for ":w >>file"
#define CPO_JOINCOL 'q' // with "3J" use column after first join #define CPO_JOINCOL 'q' // with "3J" use column after first join
#define CPO_REDO 'r' #define CPO_REDO 'r'

View File

@ -1709,9 +1709,6 @@ return {
when it didn't exist when editing it. This is a when it didn't exist when editing it. This is a
protection against a file unexpectedly created by protection against a file unexpectedly created by
someone else. Vi didn't complain about this. someone else. Vi didn't complain about this.
*cpo-p*
p Vi compatible Lisp indenting. When not present, a
slightly better algorithm is used.
*cpo-P* *cpo-P*
P When included, a ":write" command that appends to a P When included, a ":write" command that appends to a
file will set the file name for the current buffer, if file will set the file name for the current buffer, if

View File

@ -50,6 +50,7 @@ func Test_lisp_indent()
set lisp set lisp
set lispwords& set lispwords&
throw 'Skipped: cpo+=p not supported'
let save_copt = &cpoptions let save_copt = &cpoptions
set cpoptions+=p set cpoptions+=p
normal 1G=G normal 1G=G