home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / text / edit / macro / tex-scripts / nexterror.ged < prev    next >
Text File  |  1994-03-24  |  2KB  |  98 lines

  1. /* Skip to next TeX error --- take filename and line-number of the current
  2. window look for logfile. Then look for last word on the first halfline and then
  3. get that word and search for it. So the cursor should get to the error at once.
  4.  
  5. Done by:
  6.  
  7. R.Laederach
  8. Kappelisackerstr. 46
  9. 3063 Ittigen
  10. Switzerland
  11. Phone:+41/(0)31/912 19 08
  12.  
  13. This stuff ist PostcardWare, so send me a postcard or something useful (read
  14. the doc!).
  15. */
  16.  
  17. /* $VER: 0.9, ©1993 Dietmar Eilert. Empty GoldED macro */
  18.  
  19. OPTIONS RESULTS                             /* enable return codes     */
  20.  
  21. if (LEFT(ADDRESS(), 6) ~= "GOLDED") then    /* not started by GoldEd ? */
  22.     address 'GOLDED.1'
  23.  
  24. 'LOCK CURRENT'                              /* lock GUI, gain access   */
  25. OPTIONS FAILAT 6                            /* ignore warnings         */
  26. SIGNAL ON SYNTAX                            /* ensure clean exit       */
  27.  
  28.  
  29. 'QUERY DOC'
  30. fullname = RESULT
  31.  
  32. basename = (left(fullname, LENGTH(fullname)-4))
  33. extension = translate(right(fullname, 4) , xrange('a','z'), xrange('A','Z'))
  34.  
  35.  
  36. IF extension ~= ".tex" THEN DO
  37.     'REQUEST BODY="I need a .tex file"'
  38.     UNLOCK
  39.     EXIT 5
  40. END
  41.  
  42. logname = basename||".log"
  43.  
  44. 'QUERY LINE'
  45. currentline = RESULT + 1
  46.  
  47. 'REQUEST HIDE = TRUE'
  48.  
  49. 'WINDOW QUIET HEIGHT=80 FORCE USE="'||logname||'"'
  50. 'OPEN AGAIN' /* Reloading file slows operation down, but ensures
  51. that the right error will be gotten */
  52. 'REQUEST HIDE = FALSE'
  53.  
  54. 'GOTO UNFOLD=TRUE TOP'
  55.  
  56. number = 0
  57. found = 1
  58. DO WHILE(found & number <= currentline)
  59.     'FIND NEXT QUIET STRING="l."'
  60.     found = (RC = 0)
  61.     if (found) THEN DO
  62.         OPTIONS RESULTS
  63.         'QUERY BUFFER'
  64.         parse var RESULT "l." number errorstring
  65.         IF "" ~= errorstring THEN DO
  66.             wordnumber = WORDS(errorstring)
  67.             errorword = WORD(errorstring,wordnumber)
  68.             /* say errorstring
  69.             say errorword
  70.             say wordnumber >I used that for debugging */
  71.             END
  72.     END
  73.  
  74. END
  75.  
  76. 'WINDOW USE="'||fullname||'"' /* FORCE is not required because text is already
  77. loaded. If user killed text in-between, then he's a sicko */
  78. IF 0~= number & number > currentline THEN DO
  79.     'GOTO COLUMN=1 UNFOLD=TRUE LINE=' number
  80.     'FIX VAR=ERRORWORD'
  81.     'FIND QUIET NEXT STRING="'||errorword||'"'
  82.     UNLOCK
  83.     END
  84. else DO
  85.     'REQUEST BODY="No more errors."'
  86. UNLOCK
  87. END
  88.  
  89. 'UNLOCK' /* VERY important: unlock GUI */
  90. EXIT
  91.  
  92. SYNTAX:
  93.  
  94. SAY "Sorry, error line" SIGL ":" ERRORTEXT(RC) ":-("
  95. 'UNLOCK'
  96. EXIT
  97.  
  98.