2 * Copyright (c) 1992, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 1992, 1993, 1994, 1995, 1996
5 * Keith Bostic. All rights reserved.
7 * See the LICENSE file for redistribution information.
12 #include <sys/types.h>
13 #include <sys/queue.h>
16 #include <bitstring.h>
22 #include "../common/common.h"
29 * PUBLIC: int v_at(SCR *, VICMD *);
32 v_at(SCR *sp, VICMD *vp)
45 * Historically, [@*]<carriage-return> and [@*][@*] executed the most
46 * recently executed buffer in ex mode. In vi mode, only @@ repeated
47 * the last buffer. We change historic practice and make @* work from
48 * vi mode as well, it's simpler and more consistent.
50 * My intent is that *[buffer] will, in the future, pass the buffer to
51 * whatever interpreter is loaded.
53 name = F_ISSET(vp, VC_BUFFER) ? vp->buffer : '@';
54 if (name == '@' || name == '*') {
55 if (!F_ISSET(sp, SC_AT_SET)) {
56 ex_emsg(sp, NULL, EXM_NOPREVBUF);
63 CBNAME(sp, cbp, name);
65 ex_emsg(sp, KEY_NAME(sp, name), EXM_EMPTYBUF);
73 * The buffer is executed in vi mode, while in vi mode, so simply
74 * push it onto the terminal queue and continue.
77 * Historic practice is that if the buffer was cut in line mode,
78 * <newlines> were appended to each line as it was pushed onto
79 * the stack. If the buffer was cut in character mode, <newlines>
80 * were appended to all lines but the last one.
83 * Historic practice is that execution of an @ buffer could be
84 * undone by a single 'u' command, i.e. the changes were grouped
85 * together. We don't get this right; I'm waiting for the new DB
86 * logging code to be available.
88 TAILQ_FOREACH_REVERSE(tp, cbp->textq, _texth, q) {
89 if (((F_ISSET(cbp, CB_LMODE) ||
90 TAILQ_NEXT(tp, q) != NULL) &&
91 v_event_push(sp, NULL, L("\n"), 1, 0)) ||
92 v_event_push(sp, NULL, tp->lb, tp->len, 0))
98 * If any count was supplied, it applies to the first command in the
101 if (F_ISSET(vp, VC_C1SET)) {
102 len = snprintf(nbuf, sizeof(nbuf), "%lu", vp->count);
103 CHAR2INT(sp, nbuf, len, wp, wlen);
104 MEMCPY(wbuf, wp, wlen);
105 if (v_event_push(sp, NULL, wp, wlen, 0))