home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 197_01 / emacsrc < prev    next >
Text File  |  1979-12-31  |  6KB  |  284 lines

  1. ;**************************************************************************
  2. ;
  3. ;        STARTUP COMMAND FILE FOR EMACS
  4. ;            (.emacsrc)
  5. ;
  6. ;        Copyright (C) 1988 J.Manzai
  7. ;        All rights Reserved
  8. ;
  9. ;
  10. ;    Date Created: March 19, 1988 @(#) .emacsrc Version 1.0
  11. ;
  12. ;    Modifications: 24-Mar-88 Disabled the bind/unbind key function.
  13. ;                 These Key are too similar to the search-
  14. ;                 forward key binding and were hit too
  15. ;                 Many times by accident. Rewrote the indent-
  16. ;                 ation Macros to handle tabs correctly.
  17. ;
  18. ;    WARNING:        This file is stored with the file name 
  19. ;                "EMACSRC". When you use this file under UNIX,
  20. ;                you must change the name to ".emacsrc".
  21. ;
  22. ;                This start-up file shoud be used in conjunction
  23. ;                with file "comp".
  24. ;***************************************************************************
  25.  
  26. ; Disable the message line while this setup is running...
  27.  
  28.     set $discmd FALSE
  29.  
  30. ; Setup some key bindings for the shifted function keys. The unshifted
  31. ; function keys are already initialized in the EMACS ebind.h file.
  32.  
  33.     bind-to-key execute-macro-11 M-!
  34.     bind-to-key execute-macro-12 M-@
  35.     bind-to-key execute-macro-13 M-#
  36.     bind-to-key execute-macro-14 M-$
  37.     bind-to-key execute-macro-15 M-%
  38.     bind-to-key execute-macro-16 M-^
  39.     bind-to-key execute-macro-17 M-&
  40.     bind-to-key execute-macro-18 M-*
  41.     bind-to-key execute-macro-19 M-_
  42.     bind-to-key execute-macro-20 M-+
  43.     
  44. ; Set Global modes of operation
  45.  
  46.     add-global-mode magic
  47.     add-global-mode exact
  48.  
  49. ; Define some useful macros
  50.  
  51.     ; Draw opening line of comment block
  52.     
  53.     1    store-macro
  54.         beginning-of-line
  55.         insert-string "/"
  56.         79 insert-string "*"
  57.         insert-string "~n"
  58.         !endm
  59.  
  60.     ; Draw closing line of comment block
  61.  
  62.     2    store-macro
  63.         beginning-of-line
  64.         79 insert-string "*"
  65.         insert-string "/~n"
  66.         !endm
  67.  
  68.     ; Draw function separation line
  69.     
  70.     3    store-macro
  71.         beginning-of-line
  72.         insert-string "/* "
  73.         74 insert-string "-"
  74.         insert-string " */~n"
  75.         !endm
  76.     
  77.     ; Center the string already typed on this line
  78.  
  79.     4     store-macro
  80.         write-message "[CENTERING]"
  81.         beginning-of-line
  82.         trim-line
  83.         previous-line
  84.         !if &gre $lwidth 74
  85.             write-message "[LINE TOO LONG]"
  86.             !return
  87.         !endif
  88.         !if &equal $lwidth 0
  89.             !return
  90.         !endif
  91.         set %i &div $lwidth 2
  92.         set %i &sub 37 %i
  93.         !while &less $curcol %i
  94.             insert-string " "
  95.         !endwhile
  96.         next-line
  97.         beginning-of-line
  98.         clear-message-line
  99.         !endm
  100.  
  101. ; Automatic indentation Control for C-source code..
  102.  
  103.     ; Handle opening "{" in c-mode editing...
  104.     
  105.     bind-to-key execute-macro-5 {
  106.     set %level 0
  107.  
  108.     5    store-macro
  109.         !if &less $curcol 4
  110.             insert-string "{~n"
  111.             insert-string " "    ; insert tab
  112.             set %level 1
  113.             !return
  114.         !else
  115.             set %level &add %level 1
  116.             insert-string "{~n"
  117.             beginning-of-line
  118.             set %tabs 0
  119.             !while &less %tabs %level
  120.                 insert-string " "    ; insert tab
  121.                 set %tabs &add %tabs 1
  122.             !endwhile
  123.         !endif
  124.         !endm
  125.  
  126.     ; Handle newline when using c-mode indentation...
  127.  
  128.     bind-to-key execute-macro-6    ^M
  129.  
  130.     6    store-macro
  131.         insert-string "~n"
  132.         beginning-of-line
  133.         set %tabs 0
  134.         !while &less %tabs %level
  135.             insert-string " "
  136.             set %tabs &add %tabs 1
  137.         !endwhile
  138.         !endif
  139.         !endm
  140.  
  141.     ; Handle closing "}" when using c-mode indentation
  142.  
  143.     bind-to-key execute-macro-7 }
  144.  
  145.     7    store-macro
  146.         set %level &sub %level 1
  147.         !if &equ %level 0
  148.             beginning-of-line
  149.             insert-string "}~n"
  150.             !return
  151.         !endif
  152.         !if &less %level 0
  153.             write-message "Too many closing braces!!"
  154.             set %save 0
  155.             set %level 0
  156.             !return
  157.         !endif
  158.         insert-string "}~n"
  159.         beginning-of-line
  160.         set %tabs 0
  161.         !while &less %tabs %level
  162.             insert-string " "    ; insert tab
  163.             set %tabs &add %tabs 1
  164.         !endwhile
  165.         !endm
  166.  
  167.     ; Disable the indentation macros...
  168.  
  169.     9     store-macro
  170.         unbind-key {
  171.         bind-to-key newline ^M
  172.         unbind-key }
  173.         set %level 0
  174.         write-message "[AUTO INDENT DISABLE]"
  175.         !endm
  176.  
  177.     ; Start with auto-indent disabled
  178.  
  179.     execute-macro-9
  180.  
  181.     ; Enable the indentation macros...
  182.  
  183.     10    store-macro
  184.         bind-to-key execute-macro-5 {
  185.         bind-to-key execute-macro-6 ^M
  186.         bind-to-key execute-macro-7 }
  187.         write-message "[AUTO INDENT ENABLED]"
  188.         !endm
  189.  
  190.     ; Display the current binding list
  191.  
  192.     8    store-macro
  193.         describe-bindings
  194.         !endm
  195.  
  196.     ; Display help in a new window
  197.  
  198.     11    store-macro
  199.         help
  200.         !endm
  201.  
  202.     ; Close the current window...
  203.  
  204.     12    store-macro
  205.         delete-window
  206.         !endm
  207.  
  208.     ; Display key bindings in new window
  209.  
  210.     13    store-macro
  211.         describe-bindings
  212.         !endm
  213.  
  214.     ; Display current buffer status
  215.  
  216.     14     store-macro
  217.         list-buffers
  218.         previous-window
  219.         !endm
  220.  
  221.     ; Increase size of current window
  222.  
  223.     19    store-macro
  224.         grow-window
  225.         !endm
  226.  
  227.     ; Decrease size of current window
  228.  
  229.     20     store-macro
  230.         shrink-window
  231.         !endm
  232.  
  233.     ; Control the development environment
  234.  
  235.     bind-to-key execute-macro-25 M-\
  236.     set %ftime TRUE
  237.  
  238.     25    store-macro
  239.         !force delete-other-windows
  240.         !if &seq %ftime TRUE
  241.             set %name &left $cfname &sub &sindex $cfname "." 1
  242.             set %ftime FALSE
  243.         !endif
  244.         save-file
  245.         write-message "[STANDBY, WORKING....]"
  246.         !force pipe-command &cat "comp " %name
  247.         clear-message-line
  248.         delete-buffer &cat %name ".e"
  249.         !force find-file &cat %name ".e"
  250.         !if &seq $status TRUE
  251.             beginning-of-file
  252.             !force search-forward "[0-9][0-9]*"
  253.             set %eline $match
  254.             next-window
  255.             goto-line %eline
  256.         !else
  257.             next-window
  258.             delete-other-windows
  259.             delete-buffer &cat %name ".e"
  260.             write-message "No errors - press <retrun> to continue..."
  261.             >key
  262.         !endif
  263.         !endm
  264.  
  265.     bind-to-key execute-macro-26 M-|
  266.     
  267.     26    store-macro
  268.         pipe-command %name
  269.         next-window
  270.         !endm
  271.  
  272.     ; Disable the bind/unbind key functions...
  273.  
  274.         unbind-key M-K
  275.         unbind-key M-^K
  276.  
  277.     ; Enable the message line now that the setup is complete...
  278.  
  279.         set $discmd TRUE
  280.     
  281.  
  282.  
  283.         
  284.