Mercurial > hg > xemacs-beta
comparison lisp/packages/completion.el @ 70:131b0175ea99 r20-0b30
Import from CVS: tag r20-0b30
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:02:59 +0200 |
parents | ac2d302a0011 |
children | 821dec489c24 |
comparison
equal
deleted
inserted
replaced
69:804d1389bcd6 | 70:131b0175ea99 |
---|---|
461 ;; If the found string is in some unusual case, just insert it | 461 ;; If the found string is in some unusual case, just insert it |
462 ;; as is | 462 ;; as is |
463 string-to-coerce) | 463 string-to-coerce) |
464 ))) | 464 ))) |
465 | 465 |
466 ;; Tests - | 466 ;;; Tests - |
467 ;; (cmpl-merge-string-cases "AbCdEf456" "abc") --> AbCdEf456 | 467 ;;; (cmpl-merge-string-cases "AbCdEf456" "abc") --> AbCdEf456 |
468 ;; (cmpl-merge-string-cases "abcdef456" "ABC") --> ABCDEF456 | 468 ;;; (cmpl-merge-string-cases "abcdef456" "ABC") --> ABCDEF456 |
469 ;; (cmpl-merge-string-cases "ABCDEF456" "Abc") --> Abcdef456 | 469 ;;; (cmpl-merge-string-cases "ABCDEF456" "Abc") --> Abcdef456 |
470 ;; (cmpl-merge-string-cases "ABCDEF456" "abc") --> abcdef456 | 470 ;;; (cmpl-merge-string-cases "ABCDEF456" "abc") --> abcdef456 |
471 | 471 |
472 | 472 |
473 (defun cmpl-hours-since-origin () | 473 (defun cmpl-hours-since-origin () |
474 (let ((time (current-time))) | 474 (let ((time (current-time))) |
475 (floor (+ (* 65536.0 (nth 0 time)) (nth 1 time)) 3600))) | 475 (truncate |
476 (+ (* (/ (car time) 3600.0) (lsh 1 16)) | |
477 (/ (nth 2 time) 3600.0))))) | |
476 | 478 |
477 ;;--------------------------------------------------------------------------- | 479 ;;;--------------------------------------------------------------------------- |
478 ;; "Symbol" parsing functions | 480 ;;; "Symbol" parsing functions |
479 ;;--------------------------------------------------------------------------- | 481 ;;;--------------------------------------------------------------------------- |
480 ;; The functions symbol-before-point, symbol-under-point, etc. quickly return | 482 ;;; The functions symbol-before-point, symbol-under-point, etc. quickly return |
481 ;; an appropriate symbol string. The strategy is to temporarily change | 483 ;;; an appropriate symbol string. The strategy is to temporarily change |
482 ;; the syntax table to enable fast symbol searching. There are three classes | 484 ;;; the syntax table to enable fast symbol searching. There are three classes |
483 ;; of syntax in these "symbol" syntax tables :: | 485 ;;; of syntax in these "symbol" syntax tables :: |
484 ;; | 486 ;;; |
485 ;; syntax (?_) - "symbol" chars (e.g. alphanumerics) | 487 ;;; syntax (?_) - "symbol" chars (e.g. alphanumerics) |
486 ;; syntax (?w) - symbol chars to ignore at end of words (e.g. period). | 488 ;;; syntax (?w) - symbol chars to ignore at end of words (e.g. period). |
487 ;; syntax (? ) - everything else | 489 ;;; syntax (? ) - everything else |
488 ;; | 490 ;;; |
489 ;; Thus by judicious use of scan-sexps and forward-word, we can get | 491 ;;; Thus by judicious use of scan-sexps and forward-word, we can get |
490 ;; the word we want relatively fast and without consing. | 492 ;;; the word we want relatively fast and without consing. |
491 ;; | 493 ;;; |
492 ;; Why do we need a separate category for "symbol chars to ignore at ends" ? | 494 ;;; Why do we need a separate category for "symbol chars to ignore at ends" ? |
493 ;; For example, in LISP we want starting :'s trimmed | 495 ;;; For example, in LISP we want starting :'s trimmed |
494 ;; so keyword argument specifiers also define the keyword completion. And, | 496 ;;; so keyword argument specifiers also define the keyword completion. And, |
495 ;; for example, in C we want `.' appearing in a structure ref. to | 497 ;;; for example, in C we want `.' appearing in a structure ref. to |
496 ;; be kept intact in order to store the whole structure ref.; however, if | 498 ;;; be kept intact in order to store the whole structure ref.; however, if |
497 ;; it appears at the end of a symbol it should be discarded because it is | 499 ;;; it appears at the end of a symbol it should be discarded because it is |
498 ;; probably used as a period. | 500 ;;; probably used as a period. |
499 | 501 |
500 ;; Here is the default completion syntax :: | 502 ;;; Here is the default completion syntax :: |
501 ;; Symbol chars :: A-Z a-z 0-9 @ / \ * + ~ $ < > % | 503 ;;; Symbol chars :: A-Z a-z 0-9 @ / \ * + ~ $ < > % |
502 ;; Symbol chars to ignore at ends :: _ : . - | 504 ;;; Symbol chars to ignore at ends :: _ : . - |
503 ;; Separator chars. :: <tab> <space> ! ^ & ( ) = ` | { } [ ] ; " ' # | 505 ;;; Separator chars. :: <tab> <space> ! ^ & ( ) = ` | { } [ ] ; " ' # |
504 ;; , ? <Everything else> | 506 ;;; , ? <Everything else> |
505 | 507 |
506 ;; Mode specific differences and notes :: | 508 ;;; Mode specific differences and notes :: |
507 ;; LISP diffs -> | 509 ;;; LISP diffs -> |
508 ;; Symbol chars :: ! & ? = ^ | 510 ;;; Symbol chars :: ! & ? = ^ |
509 ;; | 511 ;;; |
510 ;; C diffs -> | 512 ;;; C diffs -> |
511 ;; Separator chars :: + * / : % | 513 ;;; Separator chars :: + * / : % |
512 ;; A note on the hyphen (`-'). Perhaps the hyphen should also be a separator | 514 ;;; A note on the hyphen (`-'). Perhaps the hyphen should also be a separator |
513 ;; char., however, we wanted to have completion symbols include pointer | 515 ;;; char., however, we wanted to have completion symbols include pointer |
514 ;; references. For example, "foo->bar" is a symbol as far as completion is | 516 ;;; references. For example, "foo->bar" is a symbol as far as completion is |
515 ;; concerned. | 517 ;;; concerned. |
516 ;; | 518 ;;; |
517 ;; FORTRAN diffs -> | 519 ;;; FORTRAN diffs -> |
518 ;; Separator chars :: + - * / : | 520 ;;; Separator chars :: + - * / : |
519 ;; | 521 ;;; |
520 ;; Pathname diffs -> | 522 ;;; Pathname diffs -> |
521 ;; Symbol chars :: . | 523 ;;; Symbol chars :: . |
522 ;; Of course there is no pathname "mode" and in fact we have not implemented | 524 ;;; Of course there is no pathname "mode" and in fact we have not implemented |
523 ;; this table. However, if there was such a mode, this is what it would look | 525 ;;; this table. However, if there was such a mode, this is what it would look |
524 ;; like. | 526 ;;; like. |
525 | 527 |
526 ;;----------------------------------------------- | 528 ;;;----------------------------------------------- |
527 ;; Table definitions | 529 ;;; Table definitions |
528 ;;----------------------------------------------- | 530 ;;;----------------------------------------------- |
529 | 531 |
530 (defun cmpl-make-standard-completion-syntax-table () | 532 (defun cmpl-make-standard-completion-syntax-table () |
531 ;; XEmacs change: Left the original code alone. -sb | 533 (let ((table (make-syntax-table)) ;; default syntax is whitespace |
532 (let ((table (make-vector 256 0)) ;; default syntax is whitespace | |
533 i) | 534 i) |
534 ;; alpha chars | 535 ;; alpha chars |
535 (setq i 0) | 536 (setq i 0) |
536 (while (< i 26) | 537 (while (< i 26) |
537 (modify-syntax-entry (+ ?a i) "_" table) | 538 (modify-syntax-entry (+ ?a i) "_" table) |
2035 ) | 2036 ) |
2036 (search-failed) | 2037 (search-failed) |
2037 )))) | 2038 )))) |
2038 | 2039 |
2039 | 2040 |
2040 ;;----------------------------------------------- | 2041 ;;;----------------------------------------------- |
2041 ;; C file completion parsing | 2042 ;;; C file completion parsing |
2042 ;;----------------------------------------------- | 2043 ;;;----------------------------------------------- |
2043 ;; C : | 2044 ;;; C : |
2044 ;; Looks for #define or [<storage class>] [<type>] <name>{,<name>} | 2045 ;;; Looks for #define or [<storage class>] [<type>] <name>{,<name>} |
2045 ;; or structure, array or pointer defs. | 2046 ;;; or structure, array or pointer defs. |
2046 ;; It gets most of the definition names. | 2047 ;;; It gets most of the definition names. |
2047 ;; | 2048 ;;; |
2048 ;; As you might suspect by now, we use some symbol table hackery | 2049 ;;; As you might suspect by now, we use some symbol table hackery |
2049 ;; | 2050 ;;; |
2050 ;; Symbol separator chars (have whitespace syntax) --> , ; * = ( | 2051 ;;; Symbol separator chars (have whitespace syntax) --> , ; * = ( |
2051 ;; Opening char --> [ { | 2052 ;;; Opening char --> [ { |
2052 ;; Closing char --> ] } | 2053 ;;; Closing char --> ] } |
2053 ;; opening and closing must be skipped over | 2054 ;;; opening and closing must be skipped over |
2054 ;; Whitespace chars (have symbol syntax) | 2055 ;;; Whitespace chars (have symbol syntax) |
2055 ;; Everything else has word syntax | 2056 ;;; Everything else has word syntax |
2056 | 2057 |
2057 (defun cmpl-make-c-def-completion-syntax-table () | 2058 (defun cmpl-make-c-def-completion-syntax-table () |
2058 ;; XEmacs change | 2059 (let ((table (make-syntax-table)) |
2059 (let ((table (make-vector 256 0)) | |
2060 (whitespace-chars '(? ?\n ?\t ?\f ?\v ?\r)) | 2060 (whitespace-chars '(? ?\n ?\t ?\f ?\v ?\r)) |
2061 ;; unfortunately the ?( causes the parens to appear unbalanced | 2061 ;; unfortunately the ?( causes the parens to appear unbalanced |
2062 (separator-chars '(?, ?* ?= ?\( ?\; | 2062 (separator-chars '(?, ?* ?= ?\( ?\; |
2063 )) | 2063 )) |
2064 i) | 2064 i) |