remove left dependencies to main: bindable functions.

This commit is contained in:
Renaud 2013-06-05 11:48:40 +08:00
parent 48db208aac
commit c96138add5
9 changed files with 211 additions and 198 deletions

View File

@ -1,8 +1,8 @@
# makefile for emacs, updated Tue, Jun 04, 2013 11:39:09 AM
# makefile for emacs, updated Wed, Jun 05, 2013 11:36:19 AM
SRC=ansi.c basic.c bind.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c globals.c ibmpc.c input.c isearch.c line.c lock.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c
OBJ=ansi.o basic.o bind.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o globals.o ibmpc.o input.o isearch.o line.o lock.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o
HDR=basic.h bind.h buffer.h crypt.h display.h ebind.h edef.h efunc.h estruct.h eval.h exec.h execute.h file.h fileio.h input.h isearch.h line.h lock.h main.h names.h pklock.h random.h region.h search.h spawn.h termio.h utf8.h version.h window.h word.h wrapper.h
SRC=ansi.c basic.c bind.c bindable.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c globals.c ibmpc.c input.c isearch.c line.c lock.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c
OBJ=ansi.o basic.o bind.o bindable.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o globals.o ibmpc.o input.o isearch.o line.o lock.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o
HDR=basic.h bind.h bindable.h buffer.h crypt.h display.h ebind.h edef.h efunc.h estruct.h eval.h exec.h execute.h file.h fileio.h input.h isearch.h line.h lock.h main.h names.h pklock.h random.h region.h search.h spawn.h termio.h utf8.h version.h window.h word.h wrapper.h
# DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them
@ -126,15 +126,16 @@ depend: ${SRC}
ansi.o: ansi.c estruct.h line.h utf8.h edef.h
basic.o: basic.c basic.h display.h estruct.h line.h utf8.h edef.h input.h \
random.h word.h
bind.o: bind.c bind.h edef.h estruct.h line.h utf8.h buffer.h display.h \
ebind.h exec.h file.h fileio.h input.h main.h names.h window.h
bind.o: bind.c bind.h edef.h estruct.h line.h utf8.h bindable.h buffer.h \
display.h ebind.h exec.h file.h fileio.h input.h names.h window.h
bindable.o: bindable.c bindable.h
buffer.o: buffer.c buffer.h estruct.h line.h utf8.h display.h edef.h \
file.h input.h window.h
crypt.o: crypt.c crypt.h display.h estruct.h line.h utf8.h edef.h input.h
display.o: display.c display.h estruct.h line.h utf8.h edef.h termio.h \
version.h wrapper.h window.h
ebind.o: ebind.c ebind.h basic.h bind.h edef.h estruct.h line.h utf8.h \
buffer.h crypt.h eval.h exec.h file.h isearch.h main.h random.h \
bindable.h buffer.h crypt.h eval.h exec.h file.h isearch.h random.h \
region.h search.h spawn.h window.h word.h
eval.o: eval.c eval.h estruct.h line.h utf8.h basic.h bind.h edef.h \
buffer.h display.h exec.h fileio.h input.h random.h search.h termio.h \
@ -149,17 +150,17 @@ fileio.o: fileio.c fileio.h crypt.h display.h estruct.h line.h utf8.h \
edef.h
globals.o: globals.c estruct.h line.h utf8.h edef.h
ibmpc.o: ibmpc.c estruct.h line.h utf8.h edef.h
input.o: input.c input.h edef.h estruct.h line.h utf8.h bind.h display.h \
exec.h main.h names.h wrapper.h
input.o: input.c input.h edef.h estruct.h line.h utf8.h bind.h bindable.h \
display.h exec.h names.h wrapper.h
isearch.o: isearch.c isearch.h basic.h display.h estruct.h line.h utf8.h \
edef.h input.h search.h
line.o: line.c line.h utf8.h basic.h display.h estruct.h edef.h random.h
lock.o: lock.c lock.h estruct.h line.h utf8.h display.h edef.h input.h
main.o: main.c main.h crypt.h display.h estruct.h line.h utf8.h edef.h \
input.h termio.h version.h basic.h bind.h buffer.h eval.h execute.h \
file.h lock.h random.h search.h
input.h termio.h version.h basic.h bind.h bindable.h buffer.h eval.h \
execute.h file.h lock.h random.h search.h
names.o: names.c names.h basic.h bind.h edef.h estruct.h line.h utf8.h \
buffer.h display.h eval.h exec.h crypt.h file.h isearch.h main.h \
bindable.h buffer.h display.h eval.h exec.h crypt.h file.h isearch.h \
region.h random.h search.h spawn.h window.h word.h
pklock.o: pklock.c pklock.h estruct.h line.h utf8.h edef.h
posix.o: posix.c termio.h

2
bind.c
View File

@ -12,6 +12,7 @@
#include <stdio.h>
#include "bindable.h"
#include "buffer.h"
#include "display.h"
#include "ebind.h"
@ -20,7 +21,6 @@
#include "fileio.h"
#include "input.h"
#include "line.h"
#include "main.h"
#include "names.h"
#include "window.h"

174
bindable.c Normal file
View File

@ -0,0 +1,174 @@
/* bindable.h -- implements bindable.c */
#include "bindable.h"
#include "buffer.h"
#include "display.h"
#include "edef.h"
#include "file.h"
#include "input.h"
#if VMS
#include <ssdef.h>
#define GOOD (SS$_NORMAL)
#endif
#ifndef GOOD
#define GOOD 0
#endif
/*
* Fancy quit command, as implemented by Norm. If the any buffer has
* changed do a write on that buffer and exit emacs, otherwise simply exit.
*/
int quickexit(int f, int n)
{
struct buffer *bp; /* scanning pointer to buffers */
struct buffer *oldcb; /* original current buffer */
int status;
oldcb = curbp; /* save in case we fail */
bp = bheadp;
while (bp != NULL) {
if ((bp->b_flag & BFCHG) != 0 /* Changed. */
&& (bp->b_flag & BFTRUNC) == 0 /* Not truncated P.K. */
&& (bp->b_flag & BFINVS) == 0) { /* Real. */
curbp = bp; /* make that buffer cur */
mlwrite("(Saving %s)", bp->b_fname);
#if PKCODE
#else
mlwrite("\n");
#endif
if ((status = filesave(f, n)) != TRUE) {
curbp = oldcb; /* restore curbp */
return status;
}
}
bp = bp->b_bufp; /* on to the next buffer */
}
quit(f, n); /* conditionally quit */
return TRUE;
}
/*
* Quit command. If an argument, always quit. Otherwise confirm if a buffer
* has been changed and not written out. Normally bound to "C-X C-C".
*/
int quit(int f, int n)
{
int s;
if (f != FALSE /* Argument forces it. */
|| anycb() == FALSE /* All buffers clean. */
/* User says it's OK. */
|| (s =
mlyesno("Modified buffers exist. Leave anyway")) == TRUE) {
#if (FILOCK && BSD) || SVR4
if (lockrel() != TRUE) {
TTputc('\n');
TTputc('\r');
TTclose();
TTkclose();
exit(1);
}
#endif
vttidy();
if (f)
exit(n);
else
exit(GOOD);
}
mlwrite("");
return s;
}
/*
* Begin a keyboard macro.
* Error if not at the top level in keyboard processing. Set up variables and
* return.
*/
int ctlxlp(int f, int n)
{
if (kbdmode != STOP) {
mlwrite("%%Macro already active");
return FALSE;
}
mlwrite("(Start macro)");
kbdptr = &kbdm[0];
kbdend = kbdptr;
kbdmode = RECORD;
return TRUE;
}
/*
* End keyboard macro. Check for the same limit conditions as the above
* routine. Set up the variables and return to the caller.
*/
int ctlxrp(int f, int n)
{
if (kbdmode == STOP) {
mlwrite("%%Macro not active");
return FALSE;
}
if (kbdmode == RECORD) {
mlwrite("(End macro)");
kbdmode = STOP;
}
return TRUE;
}
/*
* Execute a macro.
* The command argument is the number of times to loop. Quit as soon as a
* command gets an error. Return TRUE if all ok, else FALSE.
*/
int ctlxe(int f, int n)
{
if (kbdmode != STOP) {
mlwrite("%%Macro already active");
return FALSE;
}
if (n <= 0)
return TRUE;
kbdrep = n; /* remember how many times to execute */
kbdmode = PLAY; /* start us in play mode */
kbdptr = &kbdm[0]; /* at the beginning */
return TRUE;
}
/*
* Abort.
* Beep the beeper. Kill off any keyboard macro, etc., that is in progress.
* Sometimes called as a routine, to do general aborting of stuff.
*/
int ctrlg(int f, int n)
{
TTbeep();
kbdmode = STOP;
mlwrite("(Aborted)");
return ABORT;
}
/* user function that does NOTHING */
int nullproc(int f, int n)
{
return TRUE;
}
/* dummy function for binding to meta prefix */
int metafn(int f, int n)
{
return TRUE;
}
/* dummy function for binding to control-x prefix */
int cex(int f, int n)
{
return TRUE;
}
/* dummy function for binding to universal-argument */
int unarg(int f, int n)
{
return TRUE;
}

11
bindable.h Normal file
View File

@ -0,0 +1,11 @@
/* functions that can be bound to keys or procedure names */
int quickexit( int f, int n) ;
int quit( int f, int n) ;
int ctlxlp( int f, int n) ;
int ctlxrp( int f, int n) ;
int ctlxe( int f, int n) ;
int ctrlg( int f, int n) ;
int nullproc( int f, int n) ;
int metafn( int f, int n) ;
int cex( int f, int n) ;
int unarg( int f, int n) ;

View File

@ -10,6 +10,7 @@
#include "basic.h"
#include "bind.h"
#include "bindable.h"
#include "buffer.h"
#include "crypt.h"
#include "eval.h"
@ -17,7 +18,6 @@
#include "file.h"
#include "isearch.h"
#include "line.h"
#include "main.h"
#include "random.h"
#include "region.h"
#include "search.h"

View File

@ -14,9 +14,9 @@
#include <unistd.h>
#include "bind.h"
#include "bindable.h"
#include "display.h"
#include "exec.h"
#include "main.h"
#include "names.h"
#include "wrapper.h"

179
main.c
View File

@ -73,6 +73,7 @@
#include "basic.h"
#include "bind.h"
#include "bindable.h"
#include "buffer.h"
#include "eval.h"
#include "execute.h"
@ -90,21 +91,18 @@ extern unsigned _stklen = 32766;
#endif
#endif
#if VMS
#include <ssdef.h>
#define GOOD (SS$_NORMAL)
#endif
#ifndef GOOD
#define GOOD 0
#endif
#if UNIX
#include <signal.h>
static void emergencyexit(int);
#ifdef SIGWINCH
extern void sizesignal(int);
#endif
static void emergencyexit(int signr)
{
quickexit(FALSE, 0);
quit(TRUE, 0);
}
#endif
static void edinit( char *bname) ;
@ -490,169 +488,6 @@ static void edinit(char *bname)
wp->w_flag = WFMODE | WFHARD; /* Full. */
}
/*
* Fancy quit command, as implemented by Norm. If the any buffer has
* changed do a write on that buffer and exit emacs, otherwise simply exit.
*/
int quickexit(int f, int n)
{
struct buffer *bp; /* scanning pointer to buffers */
struct buffer *oldcb; /* original current buffer */
int status;
oldcb = curbp; /* save in case we fail */
bp = bheadp;
while (bp != NULL) {
if ((bp->b_flag & BFCHG) != 0 /* Changed. */
&& (bp->b_flag & BFTRUNC) == 0 /* Not truncated P.K. */
&& (bp->b_flag & BFINVS) == 0) { /* Real. */
curbp = bp; /* make that buffer cur */
mlwrite("(Saving %s)", bp->b_fname);
#if PKCODE
#else
mlwrite("\n");
#endif
if ((status = filesave(f, n)) != TRUE) {
curbp = oldcb; /* restore curbp */
return status;
}
}
bp = bp->b_bufp; /* on to the next buffer */
}
quit(f, n); /* conditionally quit */
return TRUE;
}
static void emergencyexit(int signr)
{
quickexit(FALSE, 0);
quit(TRUE, 0);
}
/*
* Quit command. If an argument, always quit. Otherwise confirm if a buffer
* has been changed and not written out. Normally bound to "C-X C-C".
*/
int quit(int f, int n)
{
int s;
if (f != FALSE /* Argument forces it. */
|| anycb() == FALSE /* All buffers clean. */
/* User says it's OK. */
|| (s =
mlyesno("Modified buffers exist. Leave anyway")) == TRUE) {
#if (FILOCK && BSD) || SVR4
if (lockrel() != TRUE) {
TTputc('\n');
TTputc('\r');
TTclose();
TTkclose();
exit(1);
}
#endif
vttidy();
if (f)
exit(n);
else
exit(GOOD);
}
mlwrite("");
return s;
}
/*
* Begin a keyboard macro.
* Error if not at the top level in keyboard processing. Set up variables and
* return.
*/
int ctlxlp(int f, int n)
{
if (kbdmode != STOP) {
mlwrite("%%Macro already active");
return FALSE;
}
mlwrite("(Start macro)");
kbdptr = &kbdm[0];
kbdend = kbdptr;
kbdmode = RECORD;
return TRUE;
}
/*
* End keyboard macro. Check for the same limit conditions as the above
* routine. Set up the variables and return to the caller.
*/
int ctlxrp(int f, int n)
{
if (kbdmode == STOP) {
mlwrite("%%Macro not active");
return FALSE;
}
if (kbdmode == RECORD) {
mlwrite("(End macro)");
kbdmode = STOP;
}
return TRUE;
}
/*
* Execute a macro.
* The command argument is the number of times to loop. Quit as soon as a
* command gets an error. Return TRUE if all ok, else FALSE.
*/
int ctlxe(int f, int n)
{
if (kbdmode != STOP) {
mlwrite("%%Macro already active");
return FALSE;
}
if (n <= 0)
return TRUE;
kbdrep = n; /* remember how many times to execute */
kbdmode = PLAY; /* start us in play mode */
kbdptr = &kbdm[0]; /* at the beginning */
return TRUE;
}
/*
* Abort.
* Beep the beeper. Kill off any keyboard macro, etc., that is in progress.
* Sometimes called as a routine, to do general aborting of stuff.
*/
int ctrlg(int f, int n)
{
TTbeep();
kbdmode = STOP;
mlwrite("(Aborted)");
return ABORT;
}
/* user function that does NOTHING */
int nullproc(int f, int n)
{
return TRUE;
}
/* dummy function for binding to meta prefix */
int metafn(int f, int n)
{
return TRUE;
}
/* dummy function for binding to control-x prefix */
int cex(int f, int n)
{
return TRUE;
}
/* dummy function for binding to universal-argument */
int unarg(int f, int n)
{
return TRUE;
}
/***** Compiler specific Library functions ****/
#if RAMSIZE

12
main.h
View File

@ -1,16 +1,8 @@
#ifndef _MAIN_H_
#define _MAIN_H_
int quickexit( int f, int n) ;
int quit( int f, int n) ;
int ctlxlp( int f, int n) ;
int ctlxrp( int f, int n) ;
int ctlxe( int f, int n) ;
int ctrlg( int f, int n) ;
int nullproc( int f, int n) ;
int metafn( int f, int n) ;
int cex( int f, int n) ;
int unarg( int f, int n) ;
#if CLEAN
int cexit( int status) ;
#endif
#endif

View File

@ -10,6 +10,7 @@
#include "basic.h"
#include "bind.h"
#include "bindable.h"
#include "buffer.h"
#include "display.h"
#include "eval.h"
@ -18,7 +19,6 @@
#include "file.h"
#include "isearch.h"
#include "line.h"
#include "main.h"
#include "region.h"
#include "random.h"
#include "search.h"