Mercurial > vim
comparison src/spellfile.c @ 17682:3dbff5d37520 v8.1.1838
patch 8.1.1838: there is :spellwrong and :spellgood but not :spellrare
commit https://github.com/vim/vim/commit/08cc374dabd2a02785129fa1c0100f7745c244ad
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Aug 11 22:51:14 2019 +0200
patch 8.1.1838: there is :spellwrong and :spellgood but not :spellrare
Problem: There is :spellwrong and :spellgood but not :spellrare.
Solution: Add :spellrare. (Martin Tournoij, closes https://github.com/vim/vim/issues/4291)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 11 Aug 2019 23:00:07 +0200 |
parents | ce04ebdf26b8 |
children | 4fbfecbb968c |
comparison
equal
deleted
inserted
replaced
17681:fbdef42903ae | 17682:3dbff5d37520 |
---|---|
6123 } | 6123 } |
6124 } | 6124 } |
6125 | 6125 |
6126 /* | 6126 /* |
6127 * ":[count]spellgood {word}" | 6127 * ":[count]spellgood {word}" |
6128 * ":[count]spellwrong {word}" | 6128 * ":[count]spellwrong {word}" |
6129 * ":[count]spellundo {word}" | 6129 * ":[count]spellundo {word}" |
6130 * ":[count]spellrare {word}" | |
6130 */ | 6131 */ |
6131 void | 6132 void |
6132 ex_spell(exarg_T *eap) | 6133 ex_spell(exarg_T *eap) |
6133 { | 6134 { |
6134 spell_add_word(eap->arg, (int)STRLEN(eap->arg), eap->cmdidx == CMD_spellwrong, | 6135 spell_add_word(eap->arg, (int)STRLEN(eap->arg), |
6136 eap->cmdidx == CMD_spellwrong ? SPELL_ADD_BAD : | |
6137 eap->cmdidx == CMD_spellrare ? SPELL_ADD_RARE : SPELL_ADD_GOOD, | |
6135 eap->forceit ? 0 : (int)eap->line2, | 6138 eap->forceit ? 0 : (int)eap->line2, |
6136 eap->cmdidx == CMD_spellundo); | 6139 eap->cmdidx == CMD_spellundo); |
6137 } | 6140 } |
6138 | 6141 |
6139 /* | 6142 /* |
6140 * Add "word[len]" to 'spellfile' as a good or bad word. | 6143 * Add "word[len]" to 'spellfile' as a good, rare or bad word. |
6141 */ | 6144 */ |
6142 void | 6145 void |
6143 spell_add_word( | 6146 spell_add_word( |
6144 char_u *word, | 6147 char_u *word, |
6145 int len, | 6148 int len, |
6146 int bad, | 6149 int what, // SPELL_ADD_ values |
6147 int idx, /* "zG" and "zW": zero, otherwise index in | 6150 int idx, // "zG" and "zW": zero, otherwise index in |
6148 'spellfile' */ | 6151 // 'spellfile' |
6149 int undo) /* TRUE for "zug", "zuG", "zuw" and "zuW" */ | 6152 int undo) // TRUE for "zug", "zuG", "zuw" and "zuW" |
6150 { | 6153 { |
6151 FILE *fd = NULL; | 6154 FILE *fd = NULL; |
6152 buf_T *buf = NULL; | 6155 buf_T *buf = NULL; |
6153 int new_spf = FALSE; | 6156 int new_spf = FALSE; |
6154 char_u *fname; | 6157 char_u *fname; |
6211 } | 6214 } |
6212 | 6215 |
6213 fname = fnamebuf; | 6216 fname = fnamebuf; |
6214 } | 6217 } |
6215 | 6218 |
6216 if (bad || undo) | 6219 if (what == SPELL_ADD_BAD || undo) |
6217 { | 6220 { |
6218 /* When the word appears as good word we need to remove that one, | 6221 /* When the word appears as good word we need to remove that one, |
6219 * since its flags sort before the one with WF_BANNED. */ | 6222 * since its flags sort before the one with WF_BANNED. */ |
6220 fd = mch_fopen((char *)fname, "r"); | 6223 fd = mch_fopen((char *)fname, "r"); |
6221 if (fd != NULL) | 6224 if (fd != NULL) |
6278 | 6281 |
6279 if (fd == NULL) | 6282 if (fd == NULL) |
6280 semsg(_(e_notopen), fname); | 6283 semsg(_(e_notopen), fname); |
6281 else | 6284 else |
6282 { | 6285 { |
6283 if (bad) | 6286 if (what == SPELL_ADD_BAD) |
6284 fprintf(fd, "%.*s/!\n", len, word); | 6287 fprintf(fd, "%.*s/!\n", len, word); |
6288 else if (what == SPELL_ADD_RARE) | |
6289 fprintf(fd, "%.*s/?\n", len, word); | |
6285 else | 6290 else |
6286 fprintf(fd, "%.*s\n", len, word); | 6291 fprintf(fd, "%.*s\n", len, word); |
6287 fclose(fd); | 6292 fclose(fd); |
6288 | 6293 |
6289 home_replace(NULL, fname, NameBuff, MAXPATHL, TRUE); | 6294 home_replace(NULL, fname, NameBuff, MAXPATHL, TRUE); |