Annotation of researchv9/cmd/emacs/macros/lisp, revision 1.1

1.1     ! root        1: )             Electric C ) - Show matching parens - [if lnowid >= 4]
        !             2: 
        !             3: C. Douglas Blewett (MH3-C-319) Version 4.3
        !             4: 
        !             5: This file contains assorted macros to make life more livable while
        !             6: working with LISP and C.  The routines attached to ) and } are a
        !             7: little smarter than "balance" about showing matches that are off the
        !             8: screen.  M-% goes to the matching paren or brace.  If the cursor is
        !             9: on a "(" the routine will find the corresponding ")" (or "{" and "}").
        !            10: Of course, if the cursor is on a ")" or a "}" the routine will find the
        !            11: matching "(" or "{".  C mode MUST be turned OFF for this stuff to work.
        !            12: 
        !            13: At Jeff Langer's suggestion "}" also adjusts the indentation to that
        !            14: found on the line containing the matching "{".
        !            15: 
        !            16: The routine attached to ^M (carriage return) indents correctly
        !            17: (maintains the level of indentation including spaces and tabs) and
        !            18: removes unused white space (usually caused by the indenting routine
        !            19: itself) on blank lines.
        !            20: 
        !            21: WARNING: this routine uses "comcol" and "lnowid" as global variables for
        !            22: storing the current level of indentation and turning these features on
        !            23: and off (High Voltage).
        !            24: 
        !            25:  Interface routines
        !            26:       M-%  - Moves to corresponding () or {} pair (like vi % command)
        !            27:       )    - Shows matching "(" (only if it is currently displayed)
        !            28:       {    - Inserts {, a ^M and indents one tab
        !            29:       }    - Shows matching "{" (only if it is currently displayed)
        !            30:       ^M   - Maintains the exact level of indentation and removes
        !            31:               unused whitespace from interveneing empty lines
        !            32:       ;    - Inserts a ; and does a ^M
        !            33:       M-^^ - Toggles these features (High Voltage) on and off
        !            34: 
        !            35:        )
        !            36:        <lnowid
        !            37:        �
<lnowid
        !            38:        

        !            39:        |�
        !            40:                �5~4
        !            41:                        ��
        !            42:                        �On_screen
        !            43:                        
        !            44:                �
        !            45:        �
        !            46: 
        !            47: �     Electric C Level - [lnowid >= 4 ^M and ), >= 5 }, >= 6 { and ;]
        !            48:        <c
        !            49:        
                            Turn of C mode
        !            50:        <comcol
        !            51:        0
                           Set indent to zero
        !            52:        <lnowid
        !            53:        �
<lnowid
        !            54:        |�
        !            55:                �~4
        !            56:                        4

        !            57:                        0<High Voltage Electric C On Low - 4
        !            58:                �
        !            59:                �~5
        !            60:                        5

        !            61:                        0<High Voltage Electric C On Medium - 5
        !            62:                �
        !            63:                �~6
        !            64:                        6

        !            65:                        0<High Voltage Electric C On High - 6
        !            66:                �
        !            67:                � 
        !            68:                        3

        !            69:                        0<High Voltage Electric C off
        !            70:                �
        !            71:        �
        !            72: 
        !            73: ;             Electric C ; - New line and indent - [if lnowid >= 6]
        !            74:        ;
        !            75:        <lnowid
        !            76:        �
<lnowid
        !            77:        

        !            78:        |�
        !            79:                �5~6
        !            80:                        

        !            81:                �
        !            82:        �
        !            83: 
        !            84: {             Electric C { - New line and indent - [if lnowid >= 6]
        !            85:        {
        !            86:        <lnowid
        !            87:        �
<lnowid
        !            88:        

        !            89:        |�
        !            90:                �5~6
        !            91:                        �Indent_get
        !            92:                        &    -
        !            93:                �
        !            94:        �
        !            95: 
        !            96: }             Electric C } - Match Previous, etc. - [if lnowid >= 5]
        !            97:        }
        !            98:        <lnowid
        !            99:        �
<lnowid
        !           100:        

        !           101:        |�
        !           102:                �5~5
        !           103:                        <-
        !           104:                        ��
        !           105:                        �On_screen
        !           106:                        �Indent_get
        !           107:                        5��Indent_get
        !           108:                        --<}<-
        !           109:                        �3-}�
        !           110:                �
        !           111:        �
        !           112: 
        !           113: �On_screen
        !           114:        |�                    Test if it is on the screen
        !           115:                �~3=-1
        !           116:                �
        !           117:                � 
        !           118:                        #8�80--
        !           119:                        80
        !           120:                �      Quick Twitch - it is faster than a 1 sec. delay
        !           121:        �
        !           122: 
        !           123: �Indent_get
        !           124:        &�1                         Copy the indentation
        !           125:        <
        !           126:        ^�4~0
        !           127:                !�
        !           128:                        � 
        !           129:                                +
        !           130:                        �
        !           131:                        �       
        !           132:                                +
        !           133:                        �
        !           134:                        ��
        !           135:                                �0
        !           136:                        �
        !           137:                �
        !           138:        �
        !           139: 
        !           140: �             Find_Matching parens and braces
        !           141:        !�                  What are we matching
        !           142:                �(
        !           143:                        �1
        !           144:                        5�1
        !           145:                        6�4
        !           146:                        <[()]
        !           147:                �
        !           148:                �)
        !           149:                        �-1
        !           150:                        5�-1
        !           151:                        6�-4
        !           152:                        <[()]
        !           153:                �
        !           154:                �{
        !           155:                        �1
        !           156:                        5�1
        !           157:                        6�4
        !           158:                        <[{}]
        !           159:                �
        !           160:                �}
        !           161:                        �-1
        !           162:                        5�-1
        !           163:                        6�-4
        !           164:                        <[{}]
        !           165:                �
        !           166:                ��
        !           167:                        �0
        !           168:                        
        !           169:                �
        !           170:        �
        !           171:        ^�4~0          Loop until match is found
        !           172:                |�
        !           173:                        �5          Move off the  current item
        !           174:                                0>   Get a copy of the search string
        !           175:                                6�   Search in the correct direction
        !           176:                                !�  What we found
        !           177:                                        �(
        !           178:                                                �11~1
        !           179:                                        �
        !           180:                                        �)
        !           181:                                                �11~-1
        !           182:                                        �
        !           183:                                        �{
        !           184:                                                �11~1
        !           185:                                        �
        !           186:                                        �}
        !           187:                                                �11~-1
        !           188:                                        �
        !           189:                                        ��
        !           190:                                                �0
        !           191:                                        �
        !           192:                                �
        !           193:                        �
        !           194:                        �              Beginning or end of file
        !           195:                                �0
        !           196:                        �
        !           197:                �
        !           198:                |�            Kludge to handle loop bug
        !           199:                        �1~0
        !           200:                                |�
        !           201:                                        �~50
        !           202:                                                5�0
        !           203:                                                -
        !           204:                                        �
        !           205:                                �
        !           206:                        �
        !           207:                �
        !           208:        �
        !           209: 
        !           210: 
             Electric C - Maintain the indent - [if lnowid >= 4]
        !           211:        
        !           212:        <lnowid
        !           213:        �
<lnowid
        !           214:        

        !           215:        |�
        !           216:                �5~4
        !           217:        |�
        !           218:                �
        !           219:                        �1  ^U is the flag for space or tabs loop
        !           220:                        6�0 6 is the flag for line containing chars
        !           221:                �
        !           222:                � 
        !           223:                        �0
        !           224:                        6�1
        !           225:                �
        !           226:        �
        !           227:        5�0                 5 is the flag for space or tabs found
        !           228:        ^�4~0  Loop while trailing spaces and tabs
        !           229:                !�11~64
        !           230:                        �`             Space
        !           231:                                5�1
        !           232:                        �
        !           233:                        �I     Tab
        !           234:                                5�1
        !           235:                        �
        !           236:                        �J             Line feed
        !           237:                                �0
        !           238:                                |�Clear line if it has spaces or tabs
        !           239:                                        �~51
        !           240:                                                
        !           241:                                        �
        !           242:                                �
        !           243:                        �
        !           244:                        ��     Real line - leave it alone
        !           245:                                �0
        !           246:                                6�1
        !           247:                        �
        !           248:                �
        !           249:        �
        !           250:        �Indent_get
        !           251:        &-                         Install the copied chars.
        !           252:        0
        !           253:        |�
        !           254:                �~61             True text line
        !           255:                �
        !           256:                �1~3=0           Intervening blank lines
        !           257:                        <comcol
        !           258:                        �1

        !           259:                        <     
        !           260:                        14~8-
        !           261:                        < 
        !           262:                        15~8-
        !           263:                �
        !           264:        �
        !           265:        <comcol
        !           266:        3=
                                Set comcol
        !           267:        �
        !           268:        � 
        !           269:                &
        !           270:        �
        !           271: �
        !           272: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.