summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2004-12-24 14:35:23 +0000
committerBram Moolenaar <Bram@vim.org>2004-12-24 14:35:23 +0000
commitb5bf5b8fae9ff5e2f7704686efae2814be1e18f7 (patch)
treefcaa6e0f52dfd691d0c4796d34e402d46ce7c293 /src
parent1cd871b5341bf43ee99e136844e3131014880f92 (diff)
updated for version 7.0024v7.0024
Diffstat (limited to 'src')
-rw-r--r--src/Makefile138
-rw-r--r--src/buffer.c3
-rw-r--r--src/charset.c5
-rw-r--r--src/ex_cmds.c22
-rw-r--r--src/ex_cmds.h4
-rw-r--r--src/ex_cmds2.c2
-rw-r--r--src/ex_docmd.c7
-rw-r--r--src/fileio.c189
-rw-r--r--src/gui_gtk.c10
-rwxr-xr-xsrc/installman.sh108
-rw-r--r--src/installml.sh162
-rw-r--r--src/main.c6
-rw-r--r--src/normal.c6
-rw-r--r--src/option.c44
-rw-r--r--src/option.h3
-rw-r--r--src/proto/ex_cmds.pro2
-rw-r--r--src/proto/fileio.pro3
-rw-r--r--src/screen.c11
-rw-r--r--src/structs.h4
-rw-r--r--src/tag.c2
-rw-r--r--src/testdir/Make_amiga.mak3
-rw-r--r--src/testdir/Make_dos.mak2
-rw-r--r--src/testdir/Make_os2.mak2
-rw-r--r--src/testdir/Make_vms.mms4
-rw-r--r--src/testdir/Makefile3
-rw-r--r--src/testdir/test54.in17
-rw-r--r--src/testdir/test54.ok1
-rw-r--r--src/version.h4
28 files changed, 616 insertions, 151 deletions
diff --git a/src/Makefile b/src/Makefile
index 72f0cb8b09..4a676c240e 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -122,7 +122,7 @@
# make installruntime only installs the Vim help and
# runtime files
# make installlinks only installs the Vim binary links
-# make installhelplinks only installs the Vim manpage links
+# make installmanlinks only installs the Vim manpage links
# make installmacros only installs the Vim macros
# make installtutor only installs the Vim tutor
# make installtools only installs xxd
@@ -848,8 +848,8 @@ TOOLS = xxd/xxd$(EXEEXT)
# directories. This directory must exist.
#DESTDIR = ~/pkg/vim
-### Location of man pages
-MANSUBDIR = $(MANDIR)/man1
+### Directory of the man pages
+MAN1DIR = /man1
### Vim version (adjusted by a script)
VIMMAJOR = 7
@@ -1067,7 +1067,7 @@ KDE_LIBS1 =
KDE_LIBS2 =
KDE_INSTALL = install_normal
KDE_TARGETS = installglinks installkdeicons
-KDE_MAN_TARGETS = installghelplinks
+KDE_MAN_TARGETS = yes
KDE_TESTTARGET = gui
### GTK GUI
@@ -1083,7 +1083,7 @@ GTK_LIBS1 =
GTK_LIBS2 = $(GTK_LIBNAME)
GTK_INSTALL = install_normal
GTK_TARGETS = installglinks
-GTK_MAN_TARGETS = installghelplinks
+GTK_MAN_TARGETS = yes
GTK_TESTTARGET = gui
### Motif GUI
@@ -1097,7 +1097,7 @@ MOTIF_LIBS1 =
MOTIF_LIBS2 = $(MOTIF_LIBNAME) -lXt
MOTIF_INSTALL = install_normal
MOTIF_TARGETS = installglinks
-MOTIF_MAN_TARGETS = installghelplinks
+MOTIF_MAN_TARGETS = yes
MOTIF_TESTTARGET = gui
### Athena GUI
@@ -1126,7 +1126,7 @@ ATHENA_LIBS1 = $(XAW_LIB)
ATHENA_LIBS2 = -lXt
ATHENA_INSTALL = install_normal
ATHENA_TARGETS = installglinks
-ATHENA_MAN_TARGETS = installghelplinks
+ATHENA_MAN_TARGETS = yes
ATHENA_TESTTARGET = gui
### neXtaw GUI
@@ -1143,7 +1143,7 @@ NEXTAW_LIBS1 = $(NEXTAW_LIB)
NEXTAW_LIBS2 = -lXt
NEXTAW_INSTALL = install_normal
NEXTAW_TARGETS = installglinks
-NEXTAW_MAN_TARGETS = installghelplinks
+NEXTAW_MAN_TARGETS = yes
NEXTAW_TESTTARGET = gui
### (J) Sun OpenWindows 3.2 (SunOS 4.1.x) or earlier that produce these ld
@@ -1167,7 +1167,7 @@ BEOSGUI_LIBS1 = -lbe -lroot
BEOSGUI_LIBS2 =
BEOSGUI_INSTALL = install_normal
BEOSGUI_TARGETS = installglinks
-BEOSGUI_MAN_TARGETS = installghelplinks
+BEOSGUI_MAN_TARGETS = yes
BEOSGUI_TESTTARGET = gui
# PHOTON GUI
@@ -1180,7 +1180,7 @@ PHOTONGUI_LIBS1 = -lph -lphexlib
PHOTONGUI_LIBS2 =
PHOTONGUI_INSTALL = install_normal
PHOTONGUI_TARGETS = installglinks
-PHOTONGUI_MAN_TARGETS = installghelplinks
+PHOTONGUI_MAN_TARGETS = yes
PHOTONGUI_TESTTARGET = gui
# CARBON GUI
@@ -1277,7 +1277,9 @@ DEST_TOOLS = $(DESTDIR)$(TOOLSSUBLOC)
DEST_TUTOR = $(DESTDIR)$(TUTORSUBLOC)
DEST_SCRIPT = $(DESTDIR)$(SCRIPTLOC)
DEST_PRINT = $(DESTDIR)$(PRINTSUBLOC)
-DEST_MAN = $(DESTDIR)$(MANSUBDIR)
+DEST_MAN_TOP = $(DESTDIR)$(MANDIR)
+DEST_MAN = $(DEST_MAN_TOP)$(MAN1DIR)
+DEST_MAN_IT = $(DEST_MAN_TOP)/it$(MAN1DIR)
# BASIC_SRC: files that are always used
# GUI_SRC: extra GUI files for current configuration
@@ -1661,7 +1663,7 @@ install: $(GUI_INSTALL)
install_normal: installvim installtools install-languages install-icons
-installvim: installvimbin installruntime installlinks installhelplinks installmacros installtutor
+installvim: installvimbin installruntime installlinks installmanlinks installmacros installtutor
installvimbin: $(VIMTARGET) $(DESTDIR)$(exec_prefix) $(DEST_BIN)
-if test -f $(DEST_BIN)/$(VIMTARGET); then \
@@ -1674,37 +1676,16 @@ installvimbin: $(VIMTARGET) $(DESTDIR)$(exec_prefix) $(DEST_BIN)
# may create a link to the new executable from /usr/bin/vi
-$(LINKIT)
-# install the help files; first adjust the contents for the location
-installruntime: $(HELPSOURCE)/vim.1 $(DEST_MAN) $(DEST_VIM) $(DEST_RT) \
+# Long list of arguments for the shell script that installs the manual pages
+# for one language.
+INSTALLMANARGS = $(VIMLOC) $(SCRIPTLOC) $(VIMRCLOC) $(HELPSOURCE) $(MANMOD) \
+ $(VIMNAME) $(VIMDIFFNAME) $(EVIMNAME)
+
+# install the help files; first adjust the contents for the final location
+installruntime: $(HELPSOURCE)/vim.1 $(DEST_VIM) $(DEST_RT) \
$(DEST_HELP) $(DEST_PRINT) $(DEST_COL) $(DEST_SYN) $(DEST_IND) \
$(DEST_FTP) $(DEST_PLUG) $(DEST_TUTOR) $(DEST_COMP)
- @echo generating $(DEST_MAN)/$(VIMNAME).1
- @sed -e s+/usr/local/lib/vim+$(VIMLOC)+ \
- -e s+$(VIMLOC)/doc+$(HELPSUBLOC)+ \
- -e s+$(VIMLOC)/syntax+$(SYNSUBLOC)+ \
- -e s+$(VIMLOC)/tutor+$(TUTORSUBLOC)+ \
- -e s+$(VIMLOC)/vimrc+$(VIMRCLOC)/vimrc+ \
- -e s+$(VIMLOC)/gvimrc+$(VIMRCLOC)/gvimrc+ \
- -e s+$(VIMLOC)/menu.vim+$(SCRIPTLOC)/menu.vim+ \
- -e s+$(VIMLOC)/bugreport.vim+$(SCRIPTLOC)/bugreport.vim+ \
- -e s+$(VIMLOC)/filetype.vim+$(SCRIPTLOC)/filetype.vim+ \
- -e s+$(VIMLOC)/ftoff.vim+$(SCRIPTLOC)/ftoff.vim+ \
- -e s+$(VIMLOC)/scripts.vim+$(SCRIPTLOC)/scripts.vim+ \
- -e s+$(VIMLOC)/optwin.vim+$(SCRIPTLOC)/optwin.vim+ \
- -e 's+$(VIMLOC)/\*.ps+$(SCRIPTLOC)/\*.ps+' \
- $(HELPSOURCE)/vim.1 > $(DEST_MAN)/$(VIMNAME).1
- chmod $(MANMOD) $(DEST_MAN)/$(VIMNAME).1
- @echo generating $(DEST_MAN)/$(VIMNAME)tutor.1
- @sed -e s+/usr/local/lib/vim+$(VIMLOC)+ \
- -e s+$(VIMLOC)/tutor+$(TUTORSUBLOC)+ \
- $(HELPSOURCE)/vimtutor.1 > $(DEST_MAN)/$(VIMNAME)tutor.1
- chmod $(MANMOD) $(DEST_MAN)/$(VIMNAME)tutor.1
- $(INSTALL_DATA) $(HELPSOURCE)/vimdiff.1 $(DEST_MAN)/$(VIMDIFFNAME).1
- chmod $(MANMOD) $(DEST_MAN)/$(VIMDIFFNAME).1
- @echo generating $(DEST_MAN)/$(EVIMNAME).1
- @sed -e s+/usr/local/lib/vim+$(SCRIPTLOC)+ \
- $(HELPSOURCE)/evim.1 > $(DEST_MAN)/$(EVIMNAME).1
- chmod $(MANMOD) $(DEST_MAN)/$(EVIMNAME).1
+ -$(SHELL) ./installman.sh install $(DEST_MAN) "" $(INSTALLMANARGS)
@echo generating help tags
# Generate the help tags with ":helptags" to handle all languages.
-@cd $(HELPSOURCE); $(MAKE) VIMEXE=$(DEST_BIN)/$(VIMTARGET) vimtags
@@ -1794,7 +1775,7 @@ installtutor: $(TUTORSOURCE) $(DEST_VIM) $(DEST_RT) $(DEST_TUTOR)
chmod $(HELPMOD) $(DEST_TUTOR)/*
# install helper program xxd
-installtools: $(TOOLS) $(DESTDIR)$(exec_prefix) $(DEST_BIN) $(DEST_MAN) \
+installtools: $(TOOLS) $(DESTDIR)$(exec_prefix) $(DEST_BIN) \
$(TOOLSSOURCE) $(DEST_VIM) $(DEST_RT) $(DEST_TOOLS)
if test -f $(DEST_BIN)/xxd$(EXEEXT); then \
mv -f $(DEST_BIN)/xxd$(EXEEXT) $(DEST_BIN)/xxd.rm; \
@@ -1803,8 +1784,8 @@ installtools: $(TOOLS) $(DESTDIR)$(exec_prefix) $(DEST_BIN) $(DEST_MAN) \
$(INSTALL_PROG) xxd/xxd$(EXEEXT) $(DEST_BIN)
$(STRIP) $(DEST_BIN)/xxd$(EXEEXT)
chmod $(BINMOD) $(DEST_BIN)/xxd$(EXEEXT)
- $(INSTALL_DATA) $(HELPSOURCE)/xxd.1 $(DEST_MAN)
- chmod $(MANMOD) $(DEST_MAN)/xxd.1
+ -$(SHELL) ./installman.sh xxd $(DEST_MAN) "" $(INSTALLMANARGS)
+ -$(SHELL) ./installman.sh xxd $(DEST_MAN_IT) "-it" $(INSTALLMANARGS)
# install the runtime tools
$(INSTALL_DATA_R) $(TOOLSSOURCE)/* $(DEST_TOOLS)
# When using CVS some CVS directories might have been copied.
@@ -1822,6 +1803,9 @@ installtools: $(TOOLS) $(DESTDIR)$(exec_prefix) $(DEST_BIN) $(DEST_MAN) \
# install the language specific files, if they were unpacked
install-languages: languages $(DEST_LANG) $(DEST_KMAP)
+ -$(SHELL) ./installman.sh install $(DEST_MAN_IT) "-it" $(INSTALLMANARGS)
+ -$(SHELL) ./installml.sh install "$(GUI_MAN_TARGETS)" \
+ $(DEST_MAN_IT) $(INSTALLMLARGS)
if test -n "$(MAKEMO)" -a -f $(PODIR)/Makefile; then \
cd $(PODIR); $(MAKE) prefix=$(DESTDIR)$(prefix) LOCALEDIR=$(DEST_LANG) \
INSTALL_DATA=$(INSTALL_DATA) FILEMOD=$(FILEMOD) install; \
@@ -1877,7 +1861,8 @@ $(HELPSOURCE)/vim.1 $(MACROSOURCE) $(TOOLSSOURCE):
@echo You need to unpack the runtime archive before running "make install".
test -f error
-$(DESTDIR)$(exec_prefix) $(DEST_BIN) $(DEST_MAN) $(DEST_VIM) $(DEST_RT) $(DEST_HELP) \
+$(DESTDIR)$(exec_prefix) $(DEST_BIN) \
+ $(DEST_VIM) $(DEST_RT) $(DEST_HELP) \
$(DEST_PRINT) $(DEST_COL) $(DEST_SYN) $(DEST_IND) $(DEST_FTP) \
$(DEST_LANG) $(DEST_KMAP) $(DEST_COMP) \
$(DEST_MACRO) $(DEST_TOOLS) $(DEST_TUTOR) $(DEST_PLUG):
@@ -1942,69 +1927,36 @@ $(DEST_BIN)/$(EVIEWTARGET):
# create links for the manual pages with various names to vim. This is only
# done when the links (or manpages with the same name) don't exist yet.
-installhelplinks: $(GUI_MAN_TARGETS) \
- $(DEST_MAN)/$(EXNAME).1 \
- $(DEST_MAN)/$(VIEWNAME).1 \
- $(DEST_MAN)/$(RVIMNAME).1 \
- $(DEST_MAN)/$(RVIEWNAME).1
-
-installghelplinks: $(DEST_MAN)/$(GVIMNAME).1 \
- $(DEST_MAN)/$(GVIEWNAME).1 \
- $(DEST_MAN)/$(RGVIMNAME).1 \
- $(DEST_MAN)/$(RGVIEWNAME).1 \
- $(DEST_MAN)/$(GVIMDIFFNAME).1 \
- $(DEST_MAN)/$(EVIEWNAME).1
-
-$(DEST_MAN)/$(EXNAME).1:
- cd $(DEST_MAN); ln -s $(VIMNAME).1 $(EXNAME).1
-
-$(DEST_MAN)/$(VIEWNAME).1:
- cd $(DEST_MAN); ln -s $(VIMNAME).1 $(VIEWNAME).1
-
-$(DEST_MAN)/$(GVIMNAME).1:
- cd $(DEST_MAN); ln -s $(VIMNAME).1 $(GVIMNAME).1
-
-$(DEST_MAN)/$(GVIEWNAME).1:
- cd $(DEST_MAN); ln -s $(VIMNAME).1 $(GVIEWNAME).1
-
-$(DEST_MAN)/$(RVIMNAME).1:
- cd $(DEST_MAN); ln -s $(VIMNAME).1 $(RVIMNAME).1
-
-$(DEST_MAN)/$(RVIEWNAME).1:
- cd $(DEST_MAN); ln -s $(VIMNAME).1 $(RVIEWNAME).1
-
-$(DEST_MAN)/$(RGVIMNAME).1:
- cd $(DEST_MAN); ln -s $(VIMNAME).1 $(RGVIMNAME).1
-
-$(DEST_MAN)/$(RGVIEWNAME).1:
- cd $(DEST_MAN); ln -s $(VIMNAME).1 $(RGVIEWNAME).1
-$(DEST_MAN)/$(GVIMDIFFNAME).1:
- cd $(DEST_MAN); ln -s $(VIMDIFFNAME).1 $(GVIMDIFFNAME).1
+INSTALLMLARGS = $(VIMNAME) $(VIMDIFFNAME) $(EVIMNAME) \
+ $(EXNAME) $(VIEWNAME) $(RVIMNAME) $(RVIEWNAME) \
+ $(GVIMNAME) $(GVIEWNAME) $(RGVIMNAME) $(RGVIEWNAME) \
+ $(GVIMDIFFNAME) $(EVIEWNAME)
-$(DEST_MAN)/$(EVIEWNAME).1:
- cd $(DEST_MAN); ln -s $(EVIMNAME).1 $(EVIEWNAME).1
+installmanlinks:
+ -$(SHELL) ./installml.sh install "$(GUI_MAN_TARGETS)" \
+ $(DEST_MAN) $(INSTALLMLARGS)
uninstall: uninstall_runtime
-rm -f $(DEST_BIN)/$(VIMTARGET)
- -rm -f $(DEST_MAN)/$(VIMNAME).1 $(DEST_MAN)/$(VIMNAME)tutor.1
-rm -f $(DEST_BIN)/vimtutor
- -rm -f $(DEST_BIN)/xxd$(EXEEXT) $(DEST_MAN)/xxd.1
-rm -f $(DEST_BIN)/$(EXTARGET) $(DEST_BIN)/$(VIEWTARGET)
-rm -f $(DEST_BIN)/$(GVIMTARGET) $(DEST_BIN)/$(GVIEWTARGET)
-rm -f $(DEST_BIN)/$(RVIMTARGET) $(DEST_BIN)/$(RVIEWTARGET)
-rm -f $(DEST_BIN)/$(RGVIMTARGET) $(DEST_BIN)/$(RGVIEWTARGET)
-rm -f $(DEST_BIN)/$(VIMDIFFTARGET) $(DEST_BIN)/$(GVIMDIFFTARGET)
-rm -f $(DEST_BIN)/$(EVIMTARGET) $(DEST_BIN)/$(EVIEWTARGET)
- -rm -f $(DEST_MAN)/$(EXNAME).1 $(DEST_MAN)/$(VIEWNAME).1
- -rm -f $(DEST_MAN)/$(GVIMNAME).1 $(DEST_MAN)/$(GVIEWNAME).1
- -rm -f $(DEST_MAN)/$(RVIMNAME).1 $(DEST_MAN)/$(RVIEWNAME).1
- -rm -f $(DEST_MAN)/$(RGVIMNAME).1 $(DEST_MAN)/$(RGVIEWNAME).1
- -rm -f $(DEST_MAN)/$(VIMDIFFNAME).1 $(DEST_MAN)/$(GVIMDIFFNAME).1
- -rm -f $(DEST_MAN)/$(EVIMNAME).1 $(DEST_MAN)/$(EVIEWNAME).1
+ -rm -f $(DEST_BIN)/xxd$(EXEEXT)
# Note: the "rmdir" will fail if any files were added after "make install"
uninstall_runtime:
+ -$(SHELL) ./installman.sh uninstall $(DEST_MAN) "" $(INSTALLMANARGS)
+ -$(SHELL) ./installman.sh uninstall $(DEST_MAN_IT) "-it" $(INSTALLMANARGS)
+ -$(SHELL) ./installml.sh uninstall "$(GUI_MAN_TARGETS)" \
+ $(DEST_MAN) $(INSTALLMLARGS)
+ -$(SHELL) ./installml.sh uninstall "$(GUI_MAN_TARGETS)" \
+ $(DEST_MAN_IT) $(INSTALLMLARGS)
+ -rm -f $(DEST_MAN)/xxd.1 $(DEST_MAN_IT)/xxd.1
-rm -f $(DEST_HELP)/*.txt $(DEST_HELP)/tags $(DEST_HELP)/*.pl
-rm -f $(DEST_HELP)/*.??x $(DEST_HELP)/tags-??
-rm -f $(SYS_MENU_FILE) $(SYS_SYNMENU_FILE) $(SYS_DELMENU_FILE)
diff --git a/src/buffer.c b/src/buffer.c
index 19dcb593d1..4003b9c986 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -588,6 +588,9 @@ free_buffer(buf)
#ifdef FEAT_RUBY
ruby_buffer_free(buf);
#endif
+#ifdef FEAT_AUTOCMD
+ aubuflocal_remove(buf);
+#endif
vim_free(buf);
}
diff --git a/src/charset.c b/src/charset.c
index 336eec6244..4560a96d1e 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -816,11 +816,8 @@ win_linetabsize(wp, p, len)
colnr_T col = 0;
char_u *s;
- for (s = p; *s != NUL && (len == MAXCOL || s < p + len); )
- {
+ for (s = p; *s != NUL && (len == MAXCOL || s < p + len); mb_ptr_adv(s))
col += win_lbr_chartabsize(wp, s, col, NULL);
- mb_ptr_adv(s);
- }
return (int)col;
}
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index c78c643610..7a176e066f 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -5216,6 +5216,28 @@ fix_help_buffer()
}
}
+/*
+ * ":exusage"
+ */
+/*ARGSUSED*/
+ void
+ex_exusage(eap)
+ exarg_T *eap;
+{
+ do_cmdline_cmd((char_u *)"help ex-cmd-index");
+}
+
+/*
+ * ":viusage"
+ */
+/*ARGSUSED*/
+ void
+ex_viusage(eap)
+ exarg_T *eap;
+{
+ do_cmdline_cmd((char_u *)"help normal-index");
+}
+
#if defined(FEAT_EX_EXTRA) || defined(PROTO)
static void helptags_one __ARGS((char_u *dir, char_u *ext, char_u *lang));
diff --git a/src/ex_cmds.h b/src/ex_cmds.h
index 5d0f0819b0..f59d0182e4 100644
--- a/src/ex_cmds.h
+++ b/src/ex_cmds.h
@@ -352,6 +352,8 @@ EX(CMD_execute, "execute", ex_execute,
EXTRA|NOTRLCOM|SBOXOK|CMDWIN),
EX(CMD_exit, "exit", ex_exit,
RANGE|WHOLEFOLD|BANG|FILE1|ARGOPT|DFLALL|TRLBAR|CMDWIN),
+EX(CMD_exusage, "exusage", ex_exusage,
+ TRLBAR),
EX(CMD_file, "file", ex_file,
RANGE|NOTADR|ZEROR|BANG|FILE1|TRLBAR),
EX(CMD_files, "files", buflist_list,
@@ -836,6 +838,8 @@ EX(CMD_visual, "visual", ex_edit,
BANG|FILE1|EDITCMD|ARGOPT|TRLBAR),
EX(CMD_view, "view", ex_edit,
BANG|FILE1|EDITCMD|ARGOPT|TRLBAR),
+EX(CMD_viusage, "viusage", ex_viusage,
+ TRLBAR),
EX(CMD_vmap, "vmap", ex_map,
EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN),
EX(CMD_vmapclear, "vmapclear", ex_mapclear,
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index 6c919ff99b..715bf99eb4 100644
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -2152,7 +2152,7 @@ static FILE *fopen_noinh_readbin __ARGS((char *filename));
fopen_noinh_readbin(filename)
char *filename;
{
- int fd_tmp = open(filename, O_RDONLY | O_BINARY | O_NOINHERIT);
+ int fd_tmp = mch_open(filename, O_RDONLY | O_BINARY | O_NOINHERIT, 0);
if (fd_tmp == -1)
return NULL;
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index a668c999d1..82f90ddf7e 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -3174,7 +3174,7 @@ set_one_cmd_context(xp, buff)
xp->xp_pattern = skipwhite(arg);
for (p = xp->xp_pattern; *p; )
{
- if (*p == '\\' && p[1])
+ if (*p == '\\' && p[1] != NUL)
++p;
#ifdef SPACE_IN_FILENAME
else if (vim_iswhite(*p) && (!(argt & NOSPC) || usefilter))
@@ -3440,7 +3440,10 @@ set_one_cmd_context(xp, buff)
case CMD_tjump:
case CMD_stjump:
case CMD_ptjump:
- xp->xp_context = EXPAND_TAGS;
+ if (*p_wop != NUL)
+ xp->xp_context = EXPAND_TAGS_LISTFILES;
+ else
+ xp->xp_context = EXPAND_TAGS;
xp->xp_pattern = arg;
break;
case CMD_augroup:
diff --git a/src/fileio.c b/src/fileio.c
index d33718d129..98d9cffba5 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -6590,6 +6590,7 @@ typedef struct AutoPat
char last; /* last pattern for apply_autocmds() */
AutoCmd *cmds; /* list of commands to do */
struct AutoPat *next; /* next AutoPat in AutoPat list */
+ int buflocal_nr; /* !=0 for buffer-local AutoPat */
} AutoPat;
static struct event_name
@@ -6686,8 +6687,13 @@ typedef struct AutoPatCmd
char_u *sfname; /* sfname to match with */
char_u *tail; /* tail of fname */
EVENT_T event; /* current event */
+ int arg_bufnr; /* initially equal to <abuf>, set to zero when
+ buf is deleted */
+ struct AutoPatCmd *next; /* chain of active apc-s for auto-invalidation*/
} AutoPatCmd;
+AutoPatCmd *active_apc_list = NULL; /* stack of active autocommands */
+
/*
* augroups stores a list of autocmd group names.
*/
@@ -6721,6 +6727,7 @@ static char_u *getnextac __ARGS((int c, void *cookie, int indent));
static int apply_autocmds_group __ARGS((EVENT_T event, char_u *fname, char_u *fname_io, int force, int group, buf_T *buf, exarg_T *eap));
static void auto_next_pat __ARGS((AutoPatCmd *apc, int stop_at_last));
+
static EVENT_T last_event;
static int last_group;
@@ -6795,6 +6802,7 @@ au_remove_pat(ap)
{
vim_free(ap->pat);
ap->pat = NULL;
+ ap->buflocal_nr = -1;
au_need_clean = TRUE;
}
@@ -6869,6 +6877,39 @@ au_cleanup()
}
/*
+ * Called when buffer is freed, to remove/invalidate related buffer-local
+ * autocmds.
+ */
+ void
+aubuflocal_remove(buf)
+ buf_T *buf;
+{
+ AutoPat *ap;
+ EVENT_T event;
+ AutoPatCmd *apc;
+
+ /* invalidate currently executing autocommands */
+ for (apc = active_apc_list; apc; apc = apc->next)
+ if (buf->b_fnum == apc->arg_bufnr)
+ apc->arg_bufnr = 0;
+
+ /* invalidate buflocals looping through events */
+ for (event = (EVENT_T)0; (int)event < (int)NUM_EVENTS;
+ event = (EVENT_T)((int)event + 1))
+ /* loop over all autocommand patterns */
+ for (ap = first_autopat[(int)event]; ap != NULL; ap = ap->next)
+ if (ap->buflocal_nr == buf->b_fnum)
+ {
+ au_remove_pat(ap);
+ if (p_verbose >= 6)
+ smsg((char_u *)
+ _("auto-removing autocommand: %s <buffer=%d>"),
+ event_nr2name(event), buf->b_fnum);
+ }
+ au_cleanup();
+}
+
+/*
* Add an autocmd group name.
* Return it's ID. Returns AUGROUP_ERROR (< 0) for error.
*/
@@ -7292,6 +7333,9 @@ do_autocmd_event(event, pat, nested, cmd, forceit, group)
int findgroup;
int allgroups;
int patlen;
+ int is_buflocal;
+ int buflocal_nr;
+ char_u buflocal_pat[25]; /* for "<buffer=X>" */
if (group == AUGROUP_ALL)
findgroup = current_augroup;
@@ -7339,6 +7383,39 @@ do_autocmd_event(event, pat, nested, cmd, forceit, group)
patlen = (int)(endpat - pat);
/*
+ * detect special <buflocal[=X]> buffer-local patterns
+ */
+ is_buflocal = FALSE;
+ buflocal_nr = 0;
+
+ if (patlen >= 7 && STRNCMP(pat, "<buffer", 7) == 0
+ && pat[patlen - 1] == '>')
+ {
+ /* Error will be printed only for addition. printing and removing
+ * will proceed silently. */
+ is_buflocal = TRUE;
+ if (patlen == 8)
+ buflocal_nr = curbuf->b_fnum;
+ else if (patlen > 9 && pat[7] == '=')
+ {
+ /* <buffer=abuf> */
+ if (patlen == 13 && STRNICMP(pat, "<buffer=abuf>", 13))
+ buflocal_nr = autocmd_bufnr;
+ /* <buffer=123> */
+ else if (skipdigits(pat + 8) == pat + patlen - 1)
+ buflocal_nr = atoi((char *)pat + 8);
+ }
+ }
+
+ if (is_buflocal)
+ {
+ /* normalize pat into standard "<buffer>#N" form */
+ sprintf((char *)buflocal_pat, "<buffer=%d>", buflocal_nr);
+ pat = buflocal_pat; /* can modify pat and patlen */
+ patlen = STRLEN(buflocal_pat); /* but not endpat */
+ }
+
+ /*
* Find AutoPat entries with this pattern.
*/
prev_ap = &first_autopat[(int)event];
@@ -7351,7 +7428,9 @@ do_autocmd_event(event, pat, nested, cmd, forceit, group)
* not specified and it's the current group, or a group was
* not specified and we are listing
* - the length of the pattern matches
- * - the pattern matches
+ * - the pattern matches.
+ * For <buffer[=X]>, this condition works because we normalize
+ * all buffer-local patterns.
*/
if ((allgroups || ap->group == findgroup)
&& ap->patlen == patlen
@@ -7374,7 +7453,7 @@ do_autocmd_event(event, pat, nested, cmd, forceit, group)
}
/*
- * Show autocmd's for this autopat
+ * Show autocmd's for this autopat, or buflocals <buffer=X>
*/
else if (*cmd == NUL)
show_autocmd(ap, event);
@@ -7401,6 +7480,15 @@ do_autocmd_event(event, pat, nested, cmd, forceit, group)
*/
if (ap == NULL)
{
+ /* refuse to add buffer-local ap if buffer number is invalid */
+ if (is_buflocal && (buflocal_nr == 0
+ || buflist_findnr(buflocal_nr) == NULL))
+ {
+ EMSGN(_("E680: <buffer=%d>: invalid buffer number "),
+ buflocal_nr);
+ return FAIL;
+ }
+
ap = (AutoPat *)alloc((unsigned)sizeof(AutoPat));
if (ap == NULL)
return FAIL;
@@ -7411,13 +7499,23 @@ do_autocmd_event(event, pat, nested, cmd, forceit, group)
vim_free(ap);
return FAIL;
}
- ap->reg_pat = file_pat_to_reg_pat(pat, endpat,
- &ap->allow_dirs, TRUE);
- if (ap->reg_pat == NULL)
+
+ if (is_buflocal)
{
- vim_free(ap->pat);
- vim_free(ap);
- return FAIL;
+ ap->buflocal_nr = buflocal_nr;
+ ap->reg_pat = NULL;
+ }
+ else
+ {
+ ap->buflocal_nr = 0;
+ ap->reg_pat = file_pat_to_reg_pat(pat, endpat,
+ &ap->allow_dirs, TRUE);
+ if (ap->reg_pat == NULL)
+ {
+ vim_free(ap->pat);
+ vim_free(ap);
+ return FAIL;
+ }
}
ap->cmds = NULL;
*prev_ap = ap;
@@ -7786,14 +7884,14 @@ apply_autocmds_group(event, fname, fname_io, force, group, buf, eap)
* autocommands are blocked.
*/
if (first_autopat[(int)event] == NULL || autocmd_block > 0)
- return retval;
+ goto BYPASS_AU;
/*
* When autocommands are busy, new autocommands are only executed when
* explicitly enabled with the "nested" flag.
*/
if (autocmd_busy && !(force || autocmd_nested))
- return retval;
+ goto BYPASS_AU;
#ifdef FEAT_EVAL
/*
@@ -7801,20 +7899,20 @@ apply_autocmds_group(event, fname, fname_io, force, group, buf, eap)
* occurred or an exception was thrown but not caught.
*/
if (aborting())
- return retval;
+ goto BYPASS_AU;
#endif
/*
* FileChangedShell never nests, because it can create an endless loop.
*/
if (filechangeshell_busy && event == EVENT_FILECHANGEDSHELL)
- return retval;
+ goto BYPASS_AU;
/*
* Ignore events in 'eventignore'.
*/
if (event_ignored(event))
- return retval;
+ goto BYPASS_AU;
/*
* Allow nesting of autocommands, but restrict the depth, because it's
@@ -7823,7 +7921,7 @@ apply_autocmds_group(event, fname, fname_io, force, group, buf, eap)
if (nesting == 10)
{
EMSG(_("E218: autocommand nesting too deep"));
- return retval;
+ goto BYPASS_AU;
}
/*
@@ -7834,7 +7932,7 @@ apply_autocmds_group(event, fname, fname_io, force, group, buf, eap)
&& (event == EVENT_WINENTER || event == EVENT_BUFENTER))
|| (autocmd_no_leave
&& (event == EVENT_WINLEAVE || event == EVENT_BUFLEAVE)))
- return retval;
+ goto BYPASS_AU;
/*
* Save the autocmd_* variables and info about the current buffer.
@@ -7904,7 +8002,7 @@ apply_autocmds_group(event, fname, fname_io, force, group, buf, eap)
sfname = vim_strsave(fname);
/* Don't try expanding FileType, Syntax or WindowID. */
if (event == EVENT_FILETYPE || event == EVENT_SYNTAX
- || event == EVENT_REMOTEREPLY)
+ || event == EVENT_REMOTEREPLY)
fname = vim_strsave(fname);
else
fname = FullName_save(fname, FALSE);
@@ -7912,7 +8010,8 @@ apply_autocmds_group(event, fname, fname_io, force, group, buf, eap)
if (fname == NULL) /* out of memory */
{
vim_free(sfname);
- return FALSE;
+ retval = FALSE;
+ goto BYPASS_AU;
}
#ifdef BACKSLASH_IN_FILENAME
@@ -7983,11 +8082,17 @@ apply_autocmds_group(event, fname, fname_io, force, group, buf, eap)
patcmd.sfname = sfname;
patcmd.tail = tail;
patcmd.event = event;
+ patcmd.arg_bufnr = autocmd_bufnr;
+ patcmd.next = NULL;
auto_next_pat(&patcmd, FALSE);
/* found one, start executing the autocommands */
if (patcmd.curpat != NULL)
{
+ /* add to active_apc_list */
+ patcmd.next = active_apc_list;
+ active_apc_list = &patcmd;
+
#ifdef FEAT_EVAL
/* set v:cmdarg (only when there is a matching pattern) */
save_cmdbang = get_vim_var_nr(VV_CMDBANG);
@@ -8015,6 +8120,9 @@ apply_autocmds_group(event, fname, fname_io, force, group, buf, eap)
set_vim_var_nr(VV_CMDBANG, save_cmdbang);
}
#endif
+ /* delete from active_apc_list */
+ if (active_apc_list == &patcmd) /* just in case */
+ active_apc_list = patcmd.next;
}
--RedrawingDisabled;
@@ -8065,6 +8173,13 @@ apply_autocmds_group(event, fname, fname_io, force, group, buf, eap)
}
au_cleanup(); /* may really delete removed patterns/commands now */
+
+BYPASS_AU:
+ /* When wiping out a buffer make sure all its buffer-local autocommands
+ * are deleted. */
+ if (event == EVENT_BUFWIPEOUT && buf != NULL)
+ aubuflocal_remove(buf);
+
return retval;
}
@@ -8089,12 +8204,16 @@ auto_next_pat(apc, stop_at_last)
apc->curpat = NULL;
/* only use a pattern when it has not been removed, has commands and
- * the group matches */
+ * the group matches. For buffer-local autocommands only check the
+ * buffer number. */
if (ap->pat != NULL && ap->cmds != NULL
&& (apc->group == AUGROUP_ALL || apc->group == ap->group))
{
- if (match_file_pat(ap->reg_pat, apc->fname, apc->sfname, apc->tail,
- ap->allow_dirs))
+ /* execution-condition */
+ if (ap->buflocal_nr == 0
+ ? (match_file_pat(ap->reg_pat, apc->fname, apc->sfname,
+ apc->tail, ap->allow_dirs))
+ : ap->buflocal_nr == apc->arg_bufnr)
{
name = event_nr2name(apc->event);
s = _("%s Auto commands for \"%s\"");
@@ -8191,11 +8310,14 @@ getnextac(c, cookie, indent)
/*
* Return TRUE if there is a matching autocommand for "fname".
+ * To account for buffer-local autocommands, function needs to know
+ * in which buffer the file will be opened.
*/
int
-has_autocmd(event, sfname)
+has_autocmd(event, sfname, buf)
EVENT_T event;
char_u *sfname;
+ buf_T *buf;
{
AutoPat *ap;
char_u *fname;
@@ -8219,8 +8341,11 @@ has_autocmd(event, sfname)
for (ap = first_autopat[(int)event]; ap != NULL; ap = ap->next)
if (ap->pat != NULL && ap->cmds != NULL
- && match_file_pat(ap->reg_pat, fname, sfname, tail,
- ap->allow_dirs))
+ && (ap->buflocal_nr == 0
+ ? match_file_pat(ap->reg_pat, fname, sfname, tail,
+ ap->allow_dirs)
+ : buf != NULL && ap->buflocal_nr == buf->b_fnum
+ ))
{
retval = TRUE;
break;
@@ -8327,7 +8452,9 @@ get_event_name(xp, idx)
/*
* Return TRUE if an autocommand is defined for "event" and "pattern".
- * "pattern" can be NULL to accept any pattern.
+ * "pattern" can be NULL to accept any pattern. Buffer-local patterns
+ * <buffer> or <buffer=N> are accepted.
+ * Used for exists("#Event#pat")
*/
int
au_exists(name, name_end, pattern)
@@ -8339,6 +8466,7 @@ au_exists(name, name_end, pattern)
char_u *p;
EVENT_T event;
AutoPat *ap;
+ buf_T *buflocal_buf = NULL;
/* find the index (enum) for the event name */
event_name = vim_strnsave(name, (int)(name_end - name));
@@ -8360,15 +8488,24 @@ au_exists(name, name_end, pattern)
if (pattern == NULL)
return TRUE;
+ /* if pattern is "<buffer>", special handling is needed which uses curbuf */
+ /* for pattern "<buffer=N>, fnamecmp() will work fine */
+ if (STRICMP(pattern, "<buffer>") == 0)
+ buflocal_buf = curbuf;
+
/* Check if there is an autocommand with the given pattern. */
for ( ; ap != NULL; ap = ap->next)
- /* only use a pattern when it has not been removed and has commands */
+ /* only use a pattern when it has not been removed and has commands. */
+ /* For buffer-local autocommands, fnamecmp() works fine. */
if (ap->pat != NULL && ap->cmds != NULL
- && fnamecmp(ap->pat, pattern) == 0)
+ && (buflocal_buf == NULL
+ ? fnamecmp(ap->pat, pattern) == 0
+ : ap->buflocal_nr == buflocal_buf->b_fnum))
return TRUE;
return FALSE;
}
+
#endif /* FEAT_AUTOCMD */
#if defined(FEAT_AUTOCMD) || defined(FEAT_WILDIGN) || defined(PROTO)
diff --git a/src/gui_gtk.c b/src/gui_gtk.c
index e5b4259bbb..4e4c1d97f1 100644
--- a/src/gui_gtk.c
+++ b/src/gui_gtk.c
@@ -2014,15 +2014,17 @@ split_button_string(char_u *button_string, int *n_buttons)
if (array != NULL)
{
array[count++] = (char *)button_string;
- for (p = button_string; *p != NUL; mb_ptr_adv(p))
+ for (p = button_string; *p != NUL; )
{
if (*p == DLG_BUTTON_SEP)
{
- *p = NUL;
- array[count++] = (char *)p + 1;
+ *p++ = NUL;
+ array[count++] = (char *)p;
}