diff --git a/microemacs/3rdparty/tfs/winmsvc.mak b/microemacs/3rdparty/tfs/winmsvc.mak index e26575660..92696c3fc 100644 --- a/microemacs/3rdparty/tfs/winmsvc.mak +++ b/microemacs/3rdparty/tfs/winmsvc.mak @@ -75,6 +75,7 @@ LDLSTT = !ENDIF OUTDIRR = .$(BUILDID)-release OUTDIRD = .$(BUILDID)-debug +INSTDIR = ..\..\bin\$(BUILDID) TRDPARTY = .. CCDEFS = /DWIN32 /D_WIN32 /D_WIN32_WINNT=0x0600 /D_$(BIT_SIZE)BIT /W3 /Zi /EHs-c- /D_HAS_EXCEPTIONS=0 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /I$(TRDPARTY)\zlib @@ -96,14 +97,12 @@ OUTDIR = $(OUTDIRD) CCFLAGS = $(CCFLAGSD) LDFLAGS = $(LDFLAGSD) ARFLAGS = $(ARFLAGSD) -INSTDIR = INSTPRG = - echo No install - debug !ELSE OUTDIR = $(OUTDIRR) CCFLAGS = $(CCFLAGSR) LDFLAGS = $(LDFLAGSR) ARFLAGS = $(ARFLAGSR) -INSTDIR = ..\..\bin\$(BUILDID) INSTPRG = copy !ENDIF diff --git a/microemacs/doc/m3mac064.3 b/microemacs/doc/m3mac064.3 index 14cff61b4..4b7cb8982 100755 --- a/microemacs/doc/m3mac064.3 +++ b/microemacs/doc/m3mac064.3 @@ -57,10 +57,16 @@ a file extension or magic string association with the hook file. i.e. .CE .Me $ehf-scheme .RE -On loading a file which matches the +The first time a file is loaded that that is bound to \fBfhook-XXX\fR via an .Ht add-file-hook 2 -definition then the \fChkXXX.emf\fR file is executed and the template is -applied to the file. +definition, the \fChkXXX.emf\fR macro file is executed and then the \fBfhook-XXX\fR command is executed +with the file's buffer current so that the template is applied to it. Only the execution of \fBfhook-XXX\fR is done on +subsequent loading of files of this type. +.PP +When the \fBfhook-XXX\fR command is executed it's +.Hl #l9 Variables 4 +register variable is set to the matched magic string if the binding was via a file content hook, or an empty string. +This can be useful as the magic string often contains configuration values such as the tab and indent width. .PP A basic template framework to be used with the \fBbuff-init\fR commands may be defined as follows for a language template called \fIXXX\fR:- diff --git a/microemacs/macros/buffinit.emf b/microemacs/macros/buffinit.emf index 7ee768d6a..e43c5aa34 100755 --- a/microemacs/macros/buffinit.emf +++ b/microemacs/macros/buffinit.emf @@ -100,7 +100,7 @@ define-macro-file collapse collapse-current collapse-all beginning-of-function e !emacro 0 define-macro buffer-init - set-variable #l9 $result + set-variable #l9 #p9 set-variable $buffer-fhook &cat "fhook-" &set #l8 @1 buffer-command-setup set-variable #l0 &ind &spr ".%s.setup" $buffer-fhook @@ -171,8 +171,8 @@ define-macro-file collapse collapse-current collapse-all beginning-of-function e buffer-bind-create "bo" "esc q" "" comment-restyle !endif !endif - !if &or &exi &ind &spr ".%s.fold" $buffer-fhook &sin "fold-open:" $result - !force 0 fold-setup $result + !if &or &exi &ind &spr ".%s.fold" $buffer-fhook &sin "fold-open:" #l9 + !force 0 fold-setup #l9 !iif ¬ $status !jump 2 !elif &sin "f" #l0 buffer-bind-create "b" "f2" "" collapse-current diff --git a/microemacs/macros/hkjst.emf b/microemacs/macros/hkjst.emf index 8c553f831..1e234394f 100755 --- a/microemacs/macros/hkjst.emf +++ b/microemacs/macros/hkjst.emf @@ -10,17 +10,14 @@ ; Notes: broken out of hkdoc.emf and docmacro.emf ; define-macro fhook-jst - set-variable #l1 $result @# buffer-init "jst" ; Over-ride any special document modes ; Search for additional modes in a: ; -!- jst; fill-column: ; fill-mode: -!- ; - !if ¬ &seq #l1 "" - !if &xseq #l1 ".*fill-column:[ \t]*\\([0-9]+\\)[ \t]*;.*" - set-variable $buffer-fill-col @s1 - !endif - !if &xseq #l1 ".*fill-mode:[ \t]*\\([a-zA-Z]+\\)[ \t]*;.*" + !if ¬ &seq #l9 "" + !iif &xseq #l9 ".*fill-column:[ \t]*\\([0-9]+\\)[ \t]*;.*" set-variable $buffer-fill-col @s1 + !if &xseq #l9 ".*fill-mode:[ \t]*\\([a-zA-Z]+\\)[ \t]*;.*" set-variable #l0 @s1 !if &iseq #l0 "left" set-variable $buffer-fill-mode "L" diff --git a/microemacs/macros/hkpls.emf b/microemacs/macros/hkpls.emf index e3bcb2c4c..72f179565 100755 --- a/microemacs/macros/hkpls.emf +++ b/microemacs/macros/hkpls.emf @@ -22,7 +22,6 @@ ; ^proceedure[ \t\n]+[a-zA-Z0-9_]+[ \t]*([^)]*)[ \t\n]*; define-macro fhook-pls - set-variable #l1 $result set-variable $buffer-mask "luh1" @# buffer-init "pls" buffer-init-hooks @@ -30,7 +29,7 @@ define-macro fhook-pls ; ; -!- pls; tabwidth:; -!- ; - !if ¬ &seq #l1 "" + !if ¬ &seq #l9 "" !iif &xseq #l9 ".*tabsize[ \t]*:[ \t]*\\([0-9]+\\)[ \t]*[-;].*" set-variable $buffer-indent-width @s1 !iif &xseq #l9 ".*tabwidth[ \t]*:[ \t]*\\([0-9]+\\)[ \t]*[-;].*" set-variable $buffer-tab-width @s1 !endif @@ -569,10 +568,10 @@ set-variable .fhook-pls.fold-mopen "1" ;EXTRA; hilight .hilight.pls 1 "wait" .scheme.keyword !if &band .hilight.flags 0x08 ; hilight constants, e.g. numbers - hilight .hilight.pls 1 "[[:digit:]]+" .scheme.constant + hilight .hilight.pls 1 "[[:digit:]]+" .scheme.constant hilight .hilight.pls 1 "-[[:digit:]]+" .scheme.constant hilight .hilight.pls 1 "[[:digit:]]+\\.[[:digit:]]+" .scheme.constant - hilight .hilight.c 1 "-[[:digit:]]+\\.[[:digit:]]+" .scheme.constant + hilight .hilight.pls 1 "-[[:digit:]]+\\.[[:digit:]]+" .scheme.constant !endif !endif diff --git a/microemacs/src/buffer.c b/microemacs/src/buffer.c index 9e1b6f644..4edba7633 100755 --- a/microemacs/src/buffer.c +++ b/microemacs/src/buffer.c @@ -168,34 +168,33 @@ assignHooks(meBuffer *bp, meUByte *hooknm) { meUByte fn[meBUF_SIZE_MAX], buff[meBUF_SIZE_MAX] ; /* Temporary buffer */ - buff[0] = 'h' ; - buff[1] = 'k' ; - meStrcpy(buff+2,hooknm+6) ; + buff[0] = 'h'; + buff[1] = 'k'; + meStrcpy(buff+2,hooknm+6); if(!fileLookup(buff,extMacroCnt,extMacroLst,meFL_CHECKDOT|meFL_USESRCHPATH,fn)) { if(hooknm == defaultHookName) - triedDefault++ ; + triedDefault++; else if(hooknm == binaryHookName) - triedBinary++ ; + triedBinary++; else if(hooknm == rbinHookName) - triedRbin++ ; + triedRbin++; else mlwrite(MWABORT|MWWAIT,(meUByte *)"Failed to find file [%s]",buff); } else { - execFile(fn,0,1) ; - bp->fhook = decode_fncname(hooknm,1) ; + execFile(fn,0,1); + bp->fhook = decode_fncname(hooknm,1); } } - if((bp->fhook = decode_fncname(hooknm,1)) >= 0) - resultStr[0] = '\0' ; + bp->fhook = decode_fncname(hooknm,1); *hooknm = 'b' ; - bp->bhook = decode_fncname(hooknm,1) ; + bp->bhook = decode_fncname(hooknm,1); *hooknm = 'd' ; - bp->dhook = decode_fncname(hooknm,1) ; + bp->dhook = decode_fncname(hooknm,1); *hooknm = 'e' ; - bp->ehook = decode_fncname(hooknm,1) ; + bp->ehook = decode_fncname(hooknm,1); *hooknm = 'f'; return; } @@ -221,7 +220,8 @@ assignHooks(meBuffer *bp, meUByte *hooknm) void setBufferContext(meBuffer *bp) { - int ii ; + meLine *lp, *tlp; + int ii, ml=0; #if MEOPT_COLOR /* First setup the global scheme - this can be missed by buffers loaded with -c */ @@ -233,9 +233,8 @@ setBufferContext(meBuffer *bp) !meModeTest(bp->mode,MDRBIN) && ((bp->fileFlag & meBFFLAG_DIR) == 0) && ((ii = fileHookCount) > 0)) { - meUByte *pp, cc ; - meLine *lp, *tlp ; - int nn ; + meUByte *pp, cc; + int nn; /* search for the first non-blank line */ for(lp=meLineGetNext(bp->baseLine) ; lp != bp->baseLine ; lp = meLineGetNext(lp)) @@ -250,84 +249,74 @@ setBufferContext(meBuffer *bp) (meRegexComp(&meRegexStrCmp,fileHookExt[ii],(nn < 0) ? meREGEX_ICASE:0) == meREGEX_OKAY)) { if(nn < 0) - nn = -nn ; - tlp = lp ; + nn = -nn; + tlp = lp; do { if(meRegexMatch(&meRegexStrCmp,meLineGetText(tlp), meLineGetLength(tlp),0,meLineGetLength(tlp),0)) { - assignHooks(bp,fileHookFunc[ii]) ; - if(bp->fhook >= 0) - { - ii = meRegexStrCmp.group[0].end - meRegexStrCmp.group[0].start ; - if(ii >= meBUF_SIZE_MAX) - ii = meBUF_SIZE_MAX - 1 ; - meStrncpy(resultStr,meLineGetText(tlp)+ - meRegexStrCmp.group[0].start,ii) ; - resultStr[ii] = '\0' ; - ii = 0 ; - break ; - } + assignHooks(bp,fileHookFunc[ii]); + ml = meRegexStrCmp.group[0].end - meRegexStrCmp.group[0].start; + ii = 0; + break; } - } while((--nn > 0) && ((tlp=meLineGetNext(tlp)) != bp->baseLine)) ; + } while((--nn > 0) && ((tlp=meLineGetNext(tlp)) != bp->baseLine)); } } - break ; + break; } } } } if(bp->fhook < 0) { - meUByte *hooknm ; + meUByte *hooknm; /* Do file hooks */ if(meModeTest(bp->mode,MDBINARY)) - hooknm = binaryHookName ; + hooknm = binaryHookName; else if(meModeTest(bp->mode,MDRBIN)) - hooknm = rbinHookName ; + hooknm = rbinHookName; else { - meUByte *sp, *bn ; - int ll, bnll ; + meUByte *sp, *bn; + int ll, bnll; /* Find the length of the string to pass into check_extension. * Check if its name has a and/or a backup ~, if so reduce * the length so '' & '~'s not inc. */ - sp = bp->name ; - ll = meStrlen(sp) ; - if((sp[ll-1] == '>') && (bp->fileName != NULL) && - ((bn = getFileBaseName(bp->fileName)) != NULL) && - ((bnll = meStrlen(bn)) > 0) && (ll > bnll) && - (sp[bnll] == '<') && !meStrncmp(sp,bn,bnll)) - ll = bnll ; + sp = bp->name; + ll = meStrlen(sp); + if((sp[ll-1] == '>') && (bp->fileName != NULL) && ((bn = getFileBaseName(bp->fileName)) != NULL) && + ((bnll = meStrlen(bn)) > 0) && (ll > bnll) && (sp[bnll] == '<') && !meStrncmp(sp,bn,bnll)) + ll = bnll; if(sp[ll-1] == '~') - ll-- ; + ll--; if(ll) { - meUByte cc = sp[ll-1] ; + meUByte cc = sp[ll-1]; if(cc == '~') { - ll-- ; + ll--; if((ll > 2) && (sp[ll-1] == '~') && (sp[ll-2] == '.')) - ll -= 2 ; + ll -= 2; } else if(isDigit(cc)) { - int ii=ll-2 ; + int ii=ll-2; while(ii > 0) { - cc = sp[ii--] ; + cc = sp[ii--]; if(!isDigit(cc)) { if((cc == '~') && (sp[ii] == '.')) - ll = ii ; - break ; + ll = ii; + break; } } } } - ii = fileHookCount ; + ii = fileHookCount; while(--ii >= 0) if((fileHookArg[ii] == 0) && checkExtent(sp,ll,fileHookExt[ii], @@ -338,16 +327,26 @@ setBufferContext(meBuffer *bp) #endif )) { - hooknm = fileHookFunc[ii] ; - break ; + hooknm = fileHookFunc[ii]; + break; } if(ii < 0) - hooknm = defaultHookName ; + hooknm = defaultHookName; } - assignHooks(bp,hooknm) ; + assignHooks(bp,hooknm); } if(bp->fhook >= 0) - execBufferFunc(bp,bp->fhook,meEBF_ARG_GIVEN,(bp->intFlag & BIFFILE)) ; + { + /* copy the magic string identifier or "" to fhook's #l9 */ + if(ml) + { + if(ml >= meBUF_SIZE_MAX) + ml = meBUF_SIZE_MAX - 1; + meStrncpy(meRegCurr->next->reg[9],meLineGetText(tlp)+meRegexStrCmp.group[0].start,ml); + } + meRegCurr->next->reg[9][ml] = '\0'; + execBufferFunc(bp,bp->fhook,meEBF_ARG_GIVEN,(bp->intFlag & BIFFILE)); + } } #endif diff --git a/microemacs/src/exec.c b/microemacs/src/exec.c index 337797fb0..e617efc43 100755 --- a/microemacs/src/exec.c +++ b/microemacs/src/exec.c @@ -1517,21 +1517,21 @@ donbuf(meLine *hlp, meVariable **varList, meUByte *commandName, int f, int n) meUByte oldcle; int oldexec, status; - if((rp=meRegCurr->next) == NULL) + /* Always make sure there is another child so functions calling execBufferFunc can use it */ + if((rp=meRegCurr->next)->next == NULL) { - if(meRegCurr->depth >= meMACRO_DEPTH_MAX) + if(rp->depth > meMACRO_DEPTH_MAX) { /* macro recursion gone too deep, bail out. * attempt to force the break out by pretending C-g was pressed */ TTbreakFlag = 1 ; return mlwrite(MWABORT|MWWAIT,(meUByte *)"[Macro recursion gone too deep]") ; } - if((rp = meMalloc(sizeof(meRegister))) == NULL) + if((rp->next = meMalloc(sizeof(meRegister))) == NULL) return meABORT; - meRegCurr->next = rp; - rp->depth = meRegCurr->depth + 1; - rp->prev = meRegCurr; - rp->next = NULL; + rp->next->depth = rp->depth + 1; + rp->next->prev = rp; + rp->next->next = NULL; } /* save the arguments */ oldcle = clexec; diff --git a/microemacs/src/winmsvc.mak b/microemacs/src/winmsvc.mak index dd0cb4c04..c60b208ec 100644 --- a/microemacs/src/winmsvc.mak +++ b/microemacs/src/winmsvc.mak @@ -109,6 +109,7 @@ LDLSTT = !ENDIF OUTDIRR = .$(BUILDID)-release OUTDIRD = .$(BUILDID)-debug +INSTDIR = ..\bin\$(BUILDID) TRDPARTY = ..\3rdparty CCDEFS = /D_WIN32 /D_ARCHITEC=$(ARCHITEC) /D_TOOLKIT=$(TOOLKIT) /D_TOOLKIT_VER=$(TOOLKIT_VER) /D_PLATFORM_VER=$(PLATFORM_VER) /D_$(BIT_SIZE)BIT /D_WIN$(BIT_SIZE) /D_WIN32_WINNT=0x0600 /DWINVER=0x0600 /W3 /Zi /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /I$(TRDPARTY)\tfs /I$(TRDPARTY)\zlib /DmeVER_CN=$(meVER_CN) /DmeVER_YR=$(meVER_YR) /DmeVER_MN=$(meVER_MN) /DmeVER_DY=$(meVER_DY) @@ -131,14 +132,12 @@ BOUTDIR = $(OUTDIRD) CCFLAGS = $(CCFLAGSD) LDFLAGS = $(LDFLAGSD) ARFLAGS = $(ARFLAGSD) -INSTDIR = INSTPRG = - echo No install - debug !ELSE BOUTDIR = $(OUTDIRR) CCFLAGS = $(CCFLAGSR) LDFLAGS = $(LDFLAGSR) ARFLAGS = $(ARFLAGSR) -INSTDIR = ..\bin\$(BUILDID) INSTPRG = copy !ENDIF diff --git a/microemacs/test/pls/jon.pls b/microemacs/test/pls/jon.pls index 1b6b53776..58d2f4328 100755 --- a/microemacs/test/pls/jon.pls +++ b/microemacs/test/pls/jon.pls @@ -1,4 +1,4 @@ -/* -*- pls -*- ************************************************************** +/* -*- pls; tabwidth:4; tabsize:5; -*- ************************************** * * Copyright 2002 Jon Green. * All Rights Reserved @@ -12,7 +12,7 @@ * Author : $Author: bill $ * Created By : * Created : Fri Oct 4 00:40:59 2002 - * Last Modified : <021004.0041> + * Last Modified : <240829.1301> * * Description * @@ -38,6 +38,7 @@ ****************************************************************************/ if then + DELETE FROM accounts WHERE account_id = acct.account_id; elsif then end if; begin