- Timestamp:
- Sep 15, 2005 6:27:33 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VSlickMacros/kdev.e
r291 r323 42 42 * 43 43 * Ctrl+Shift+T: Update project tagfile. 44 * Ctrl+Shift+L: Load document variables. 44 45 * 45 46 * Ctrl+Shift+B: KLOGENTRYX(..) … … 71 72 72 73 //optional stuff 73 //def 'C-S-Q' = odin32_klog_file_ask74 //def 'C-S-N' = odin32_klog_file_no_ask75 //def 'C-S-1' = odin32_klogentry76 //def 'C-S-3' = odin32_klogexit74 //def 'C-S-Q' = klib_klog_file_ask 75 //def 'C-S-N' = klib_klog_file_no_ask 76 //def 'C-S-1' = klib_klogentry 77 //def 'C-S-3' = klib_klogexit 77 78 78 79 … … 2325 2326 //say 'k_style_emacs_var: 'sVar'='sVal; 2326 2327 2327 /* 2328 /* 2328 2329 * Unpack the mode style parameters. 2329 2330 */ 2330 2331 _str sStyle = name_info(_edit_window().p_index); 2331 2332 _str sStyleName = p_mode_name; 2332 typeless iIndentAmount, fExpansion, iMinAbbrivation, fIndentAfterOpenParen, iBeginEndStyle, fIndent1stLevel, iMainStyle, iSwitchStyle, 2333 typeless iIndentAmount, fExpansion, iMinAbbrivation, fIndentAfterOpenParen, iBeginEndStyle, fIndent1stLevel, iMainStyle, iSwitchStyle, 2333 2334 sRest, sRes0, sRes1; 2334 2335 if (sStyleName == 'Slick-C') … … 2341 2342 2342 2343 2343 /* 2344 * Process the variable. 2344 /* 2345 * Process the variable. 2345 2346 */ 2346 2347 switch (sVar) … … 2377 2378 break; 2378 2379 } 2380 /* relevant emacs code: 2381 (defconst c-style-alist 2382 '(("gnu" 2383 (c-basic-offset . 2) 2384 (c-comment-only-line-offset . (0 . 0)) 2385 (c-offsets-alist . ((statement-block-intro . +) 2386 (knr-argdecl-intro . 5) 2387 (substatement-open . +) 2388 (label . 0) 2389 (statement-case-open . +) 2390 (statement-cont . +) 2391 (arglist-intro . c-lineup-arglist-intro-after-paren) 2392 (arglist-close . c-lineup-arglist) 2393 (inline-open . 0) 2394 (brace-list-open . +) 2395 )) 2396 (c-special-indent-hook . c-gnu-impose-minimum) 2397 (c-block-comment-prefix . "") 2398 ) 2399 ("k&r" 2400 (c-basic-offset . 5) 2401 (c-comment-only-line-offset . 0) 2402 (c-offsets-alist . ((statement-block-intro . +) 2403 (knr-argdecl-intro . 0) 2404 (substatement-open . 0) 2405 (label . 0) 2406 (statement-cont . +) 2407 )) 2408 ) 2409 ("bsd" 2410 (c-basic-offset . 8) 2411 (c-comment-only-line-offset . 0) 2412 (c-offsets-alist . ((statement-block-intro . +) 2413 (knr-argdecl-intro . +) 2414 (substatement-open . 0) 2415 (label . 0) 2416 (statement-cont . +) 2417 (inline-open . 0) 2418 (inexpr-class . 0) 2419 )) 2420 ) 2421 ("stroustrup" 2422 (c-basic-offset . 4) 2423 (c-comment-only-line-offset . 0) 2424 (c-offsets-alist . ((statement-block-intro . +) 2425 (substatement-open . 0) 2426 (label . 0) 2427 (statement-cont . +) 2428 )) 2429 ) 2430 ("whitesmith" 2431 (c-basic-offset . 4) 2432 (c-comment-only-line-offset . 0) 2433 (c-offsets-alist . ((knr-argdecl-intro . +) 2434 (label . 0) 2435 (statement-cont . +) 2436 (substatement-open . +) 2437 (block-open . +) 2438 (statement-block-intro . c-lineup-whitesmith-in-block) 2439 (block-close . c-lineup-whitesmith-in-block) 2440 (inline-open . +) 2441 (defun-open . +) 2442 (defun-block-intro . c-lineup-whitesmith-in-block) 2443 (defun-close . c-lineup-whitesmith-in-block) 2444 (brace-list-open . +) 2445 (brace-list-intro . c-lineup-whitesmith-in-block) 2446 (brace-entry-open . c-indent-multi-line-block) 2447 (brace-list-close . c-lineup-whitesmith-in-block) 2448 (class-open . +) 2449 (inclass . c-lineup-whitesmith-in-block) 2450 (class-close . +) 2451 (inexpr-class . 0) 2452 (extern-lang-open . +) 2453 (inextern-lang . c-lineup-whitesmith-in-block) 2454 (extern-lang-close . +) 2455 (namespace-open . +) 2456 (innamespace . c-lineup-whitesmith-in-block) 2457 (namespace-close . +) 2458 )) 2459 ) 2460 ("ellemtel" 2461 (c-basic-offset . 3) 2462 (c-comment-only-line-offset . 0) 2463 (c-hanging-braces-alist . ((substatement-open before after))) 2464 (c-offsets-alist . ((topmost-intro . 0) 2465 (topmost-intro-cont . 0) 2466 (substatement . +) 2467 (substatement-open . 0) 2468 (case-label . +) 2469 (access-label . -) 2470 (inclass . ++) 2471 (inline-open . 0) 2472 )) 2473 ) 2474 ("linux" 2475 (c-basic-offset . 8) 2476 (c-comment-only-line-offset . 0) 2477 (c-hanging-braces-alist . ((brace-list-open) 2478 (brace-entry-open) 2479 (substatement-open after) 2480 (block-close . c-snug-do-while))) 2481 (c-cleanup-list . (brace-else-brace)) 2482 (c-offsets-alist . ((statement-block-intro . +) 2483 (knr-argdecl-intro . 0) 2484 (substatement-open . 0) 2485 (label . 0) 2486 (statement-cont . +) 2487 )) 2488 ) 2489 ("python" 2490 (indent-tabs-mode . t) 2491 (fill-column . 78) 2492 (c-basic-offset . 8) 2493 (c-offsets-alist . ((substatement-open . 0) 2494 (inextern-lang . 0) 2495 (arglist-intro . +) 2496 (knr-argdecl-intro . +) 2497 )) 2498 (c-hanging-braces-alist . ((brace-list-open) 2499 (brace-list-intro) 2500 (brace-list-close) 2501 (brace-entry-open) 2502 (substatement-open after) 2503 (block-close . c-snug-do-while) 2504 )) 2505 (c-block-comment-prefix . "") 2506 ) 2507 ("java" 2508 (c-basic-offset . 4) 2509 (c-comment-only-line-offset . (0 . 0)) 2510 ;; the following preserves Javadoc starter lines 2511 (c-offsets-alist . ((inline-open . 0) 2512 (topmost-intro-cont . +) 2513 (statement-block-intro . +) 2514 (knr-argdecl-intro . 5) 2515 (substatement-open . +) 2516 (label . +) 2517 (statement-case-open . +) 2518 (statement-cont . +) 2519 (arglist-intro . c-lineup-arglist-intro-after-paren) 2520 (arglist-close . c-lineup-arglist) 2521 (access-label . 0) 2522 (inher-cont . c-lineup-java-inher) 2523 (func-decl-cont . c-lineup-java-throws) 2524 )) 2525 ) 2526 ) 2527 */ 2379 2528 2380 2529 case 'c-file-style': … … 2477 2626 } 2478 2627 2628 case 'nuke-trailing-whitespace-p': 2629 { 2630 _str sName = 'def-koptions-'p_buf_id; 2631 int idx = insert_name(sName, MISC_TYPE, "kstyledoc"); 2632 if (!idx) 2633 idx = find_index(sName, MISC_TYPE); 2634 if (idx) 2635 { 2636 if (sVal == 't') 2637 set_name_info(idx, "saveoptions: +S"); 2638 else 2639 set_name_info(idx, "saveoptions: -S"); 2640 say 'sVal=' sVal; 2641 } 2642 break; 2643 } 2644 2479 2645 default: 2480 2646 message('emacs variable "'sVar'" (value "'sVal'") is unknown to us.'); … … 2482 2648 } 2483 2649 2484 /* 2485 * Update the style? 2650 /* 2651 * Update the style? 2486 2652 */ 2487 2653 _str sNewStyle = ""; … … 2497 2663 //say ' sStyle='sStyle' p_mode_name='p_mode_name; 2498 2664 //say 'sNewStyle='sNewStyle' sName='sName; 2499 if (pos('kstyledoc-', sName) <= 0) 2665 if (pos('kstyledoc-', sName) <= 0) 2500 2666 { 2501 2667 sName = 'def-kstyledoc-'p_buf_id; … … 2509 2675 } 2510 2676 //say sName'='idx; 2511 } 2677 } 2512 2678 else 2513 2679 set_name_info(_edit_window().p_index, sNewStyle); … … 2520 2686 /** 2521 2687 * Parses a string with emacs variables. 2522 * 2523 * The variables are separated by new line. Junk at 2688 * 2689 * The variables are separated by new line. Junk at 2524 2690 * the start and end of the line is ignored. 2525 2691 */ … … 2536 2702 else 2537 2703 iEnd--; 2538 iNext++; 2704 iNext++; 2539 2705 2540 2706 sLine = strip(substr(sVars, 1, iEnd), 'B', " \t\n\r"); … … 2551 2717 //say '4={'pos('S4')','pos('4')',"'substr(sLine,pos('S4'),pos('4'))'"' 2552 2718 if (rc > 0) 2553 k_style_emacs_var(substr(sLine,pos('S1'),pos('1')), 2719 k_style_emacs_var(substr(sLine,pos('S1'),pos('1')), 2554 2720 substr(sLine,pos('S2'),pos('2'))); 2555 2721 } … … 2566 2732 typeless saved_pos; 2567 2733 _save_pos2(saved_pos); 2568 2734 2569 2735 int rc; 2570 2736 … … 2594 2760 2595 2761 _restore_pos2(saved_pos); 2762 } 2763 2764 2765 /** 2766 * Callback function for the event of a new buffer. 2767 * 2768 * This is used to make sure there are no left over per buffer options 2769 * hanging around. 2770 */ 2771 void _buffer_add_kdev(int buf_id) 2772 { 2773 _str sName = 'def-koptions-'buf_id; 2774 int idx = insert_name(sName, MISC_TYPE, "kstyledoc"); 2775 if (!idx) 2776 idx = find_index(sName, MISC_TYPE); 2777 if (idx) 2778 set_name_info(idx, ""); 2779 //message("_buffer_add_kdev: " idx); 2780 } 2781 2782 2783 /** 2784 * Callback function for the event of quitting a buffer. 2785 * 2786 * This is used to make sure there are no left over per buffer options 2787 * hanging around. 2788 */ 2789 void _cbquit2_kdev(int buf_id) 2790 { 2791 _str sName = 'def-koptions-'buf_id; 2792 int idx = find_index(sName, MISC_TYPE); 2793 if (idx) 2794 delete_name(idx); 2795 //message("_cbquit2_kdev: " idx " " sName); 2796 2797 sName = 'def-kstyledoc-'buf_id; 2798 idx = find_index(sName, MISC_TYPE); 2799 if (idx) 2800 delete_name(idx); 2801 } 2802 2803 2804 /** 2805 * Called to get save options for the current buffer. 2806 * 2807 * This requires a modified loadsave.e! 2808 */ 2809 _str _buffer_save_kdev(int buf_id) 2810 { 2811 _str sRet = "" 2812 _str sName = 'def-koptions-'buf_id; 2813 int idx = find_index(sName, MISC_TYPE); 2814 if (idx) 2815 { 2816 _str sOptions = strip(name_info(idx)); 2817 if (sOptions != "") 2818 parse sOptions with . "saveoptions:" sRet . 2819 message("_buffer_save_kdev: " idx " " sName " " sOptions); 2820 } 2821 return sRet; 2596 2822 } 2597 2823
Note:
See TracChangeset
for help on using the changeset viewer.