home *** CD-ROM | disk | FTP | other *** search
/ Best Objectech Shareware Selections / UNTITLED.iso / boss / word / text / 019 / misc.sl < prev    next >
Text File  |  1993-01-19  |  2KB  |  71 lines

  1. ;;
  2. ;;  Miscellaneous functions
  3. ;;
  4.  
  5.  
  6.  
  7. ;; Since this version of JED uses Linked-List approach and does not
  8. ;; support regular expressions, it is hard to search for strings at the 
  9. ;; beginning or end of a line.  Here are some functions which do this:
  10.  
  11. (           ;; bol_fsearch  returns 0 if not found
  12.   [s] =s    ;; sample usage:  push_spot "string" bol_fsearch
  13.             ;;                {pop_spot} !if
  14.   {1 down}
  15.   { bol s looking_at {1 return} if }
  16.   while
  17.   0
  18. ) bol_fsearch
  19.  
  20. ;;
  21. ;;  atrim:  trims all whitespace around point
  22. ;;
  23. ( trim
  24.   eolp {
  25.         bolp { 1 left pop 
  26.                what_column trim what_column -
  27.            {1 right pop } !if
  28.          }
  29.      !if
  30.        }
  31.   !if
  32. ) atrim
  33.  
  34.  
  35.  
  36. ;;
  37. ;;  A common problem:  I like 4 column tabs but my printer insists on 8
  38. ;;               column tabs.  How do I keep 8 column tabs but make
  39. ;;               the tab key simulate 4 column tabs?
  40. ;;  Solution:
  41.  
  42. 8 =TAB               ;; tabs set at 8 characters
  43. [MYTAB] 4 =MYTAB     ;; a new global variable
  44.  
  45. ( [c goal] what_column =c
  46.   c 1 -
  47.   MYTAB / 1 +
  48.   MYTAB * 1 + =goal
  49.   goal c - whitespace
  50.   ;;
  51.   ;; Now fixup any multiple spaces. Not needed but reduces file size.
  52.   ;;
  53.   skip_white what_column 
  54.   atrim
  55.   what_column - whitespace
  56.   goal goto_column
  57. ) my_tab_cmd      "my_tab_cmd"  "^I" setkey  ;; function bound to tab key
  58.  
  59. (
  60.    [ch]  "}" =ch
  61.  
  62.    ch insert
  63.    indent_line
  64.    1 left pop del
  65.    update
  66.    ch int =LAST_CHAR self_ins
  67.    "\n\n" insert indent_line
  68. ) my_ket_cmd "my_ket_cmd" "}" setkey
  69.  
  70.    
  71.