diff options
| author | Philipp Stephani | 2017-06-28 23:47:57 +0200 |
|---|---|---|
| committer | Philipp Stephani | 2017-07-02 17:48:23 +0200 |
| commit | 34d4720f833bb382b28d9faecf82d34db1eb4494 (patch) | |
| tree | f149e3b03da94c7db458610007e82b33ac735018 /test | |
| parent | d90b98a2a52abf67b84aa12df282b0defec8505b (diff) | |
| download | emacs-34d4720f833bb382b28d9faecf82d34db1eb4494.tar.gz emacs-34d4720f833bb382b28d9faecf82d34db1eb4494.zip | |
Electric quotes: Improve support for Markdown mode (Bug#24709)
Introduce a new user option 'electric-quote-context-sensitive'. If
non-nil, have ' insert an opening quote if sensible.
Also introduce a new variable 'electric-quote-code-faces'. Major
modes such as 'markdown-mode' can add faces to this list to treat text
as inline code and disable electric quoting.
* lisp/electric.el (electric-quote-context-sensitive): New user
option.
(electric-quote-code-faces): New variable.
(electric-quote-post-self-insert-function): Treat ' as ` if
desired and applicable; disable electric quoting for given faces.
* test/lisp/electric-tests.el (electric-quote-opening-single)
(electric-quote-closing-single, electric-quote-opening-double)
(electric-quote-closing-double)
(electric-quote-context-sensitive-backtick)
(electric-quote-context-sensitive-bob-single)
(electric-quote-context-sensitive-bob-double)
(electric-quote-context-sensitive-bol-single)
(electric-quote-context-sensitive-bol-double)
(electric-quote-context-sensitive-after-space-single)
(electric-quote-context-sensitive-after-space-double)
(electric-quote-context-sensitive-after-letter-single)
(electric-quote-context-sensitive-after-letter-double)
(electric-quote-context-sensitive-after-paren-single)
(electric-quote-context-sensitive-after-paren-double)
(electric-quote-markdown-in-text)
(electric-quote-markdown-in-code): New unit tests.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/electric-tests.el | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/test/lisp/electric-tests.el b/test/lisp/electric-tests.el index 78a37650619..6f63d30e755 100644 --- a/test/lisp/electric-tests.el +++ b/test/lisp/electric-tests.el | |||
| @@ -593,5 +593,121 @@ baz\"\"" | |||
| 593 | :bindings '((electric-quote-string . t)) | 593 | :bindings '((electric-quote-string . t)) |
| 594 | :test-in-comments nil :test-in-strings nil) | 594 | :test-in-comments nil :test-in-strings nil) |
| 595 | 595 | ||
| 596 | (define-electric-pair-test electric-quote-opening-single | ||
| 597 | "" "`" :expected-string "‘" :expected-point 2 | ||
| 598 | :modes '(text-mode) | ||
| 599 | :fixture-fn #'electric-quote-local-mode | ||
| 600 | :test-in-comments nil :test-in-strings nil) | ||
| 601 | |||
| 602 | (define-electric-pair-test electric-quote-closing-single | ||
| 603 | "" "'" :expected-string "’" :expected-point 2 | ||
| 604 | :modes '(text-mode) | ||
| 605 | :fixture-fn #'electric-quote-local-mode | ||
| 606 | :test-in-comments nil :test-in-strings nil) | ||
| 607 | |||
| 608 | (define-electric-pair-test electric-quote-opening-double | ||
| 609 | "‘" "-`" :expected-string "“" :expected-point 2 | ||
| 610 | :modes '(text-mode) | ||
| 611 | :fixture-fn #'electric-quote-local-mode | ||
| 612 | :test-in-comments nil :test-in-strings nil) | ||
| 613 | |||
| 614 | (define-electric-pair-test electric-quote-closing-double | ||
| 615 | "’" "-'" :expected-string "”" :expected-point 2 | ||
| 616 | :modes '(text-mode) | ||
| 617 | :fixture-fn #'electric-quote-local-mode | ||
| 618 | :test-in-comments nil :test-in-strings nil) | ||
| 619 | |||
| 620 | (define-electric-pair-test electric-quote-context-sensitive-backtick | ||
| 621 | "" "`" :expected-string "`" :expected-point 2 | ||
| 622 | :modes '(text-mode) | ||
| 623 | :fixture-fn #'electric-quote-local-mode | ||
| 624 | :bindings '((electric-quote-context-sensitive . t)) | ||
| 625 | :test-in-comments nil :test-in-strings nil) | ||
| 626 | |||
| 627 | (define-electric-pair-test electric-quote-context-sensitive-bob-single | ||
| 628 | "" "'" :expected-string "‘" :expected-point 2 | ||
| 629 | :modes '(text-mode) | ||
| 630 | :fixture-fn #'electric-quote-local-mode | ||
| 631 | :bindings '((electric-quote-context-sensitive . t)) | ||
| 632 | :test-in-comments nil :test-in-strings nil) | ||
| 633 | |||
| 634 | (define-electric-pair-test electric-quote-context-sensitive-bob-double | ||
| 635 | "‘" "-'" :expected-string "“" :expected-point 2 | ||
| 636 | :modes '(text-mode) | ||
| 637 | :fixture-fn #'electric-quote-local-mode | ||
| 638 | :bindings '((electric-quote-context-sensitive . t)) | ||
| 639 | :test-in-comments nil :test-in-strings nil) | ||
| 640 | |||
| 641 | (define-electric-pair-test electric-quote-context-sensitive-bol-single | ||
| 642 | "a\n" "--'" :expected-string "a\n‘" :expected-point 4 | ||
| 643 | :modes '(text-mode) | ||
| 644 | :fixture-fn #'electric-quote-local-mode | ||
| 645 | :bindings '((electric-quote-context-sensitive . t)) | ||
| 646 | :test-in-comments nil :test-in-strings nil) | ||
| 647 | |||
| 648 | (define-electric-pair-test electric-quote-context-sensitive-bol-double | ||
| 649 | "a\n‘" "---'" :expected-string "a\n“" :expected-point 4 | ||
| 650 | :modes '(text-mode) | ||
| 651 | :fixture-fn #'electric-quote-local-mode | ||
| 652 | :bindings '((electric-quote-context-sensitive . t)) | ||
| 653 | :test-in-comments nil :test-in-strings nil) | ||
| 654 | |||
| 655 | (define-electric-pair-test electric-quote-context-sensitive-after-space-single | ||
| 656 | " " "-'" :expected-string " ‘" :expected-point 3 | ||
| 657 | :modes '(text-mode) | ||
| 658 | :fixture-fn #'electric-quote-local-mode | ||
| 659 | :bindings '((electric-quote-context-sensitive . t)) | ||
| 660 | :test-in-comments nil :test-in-strings nil) | ||
| 661 | |||
| 662 | (define-electric-pair-test electric-quote-context-sensitive-after-space-double | ||
| 663 | " ‘" "--'" :expected-string " “" :expected-point 3 | ||
| 664 | :modes '(text-mode) | ||
| 665 | :fixture-fn #'electric-quote-local-mode | ||
| 666 | :bindings '((electric-quote-context-sensitive . t)) | ||
| 667 | :test-in-comments nil :test-in-strings nil) | ||
| 668 | |||
| 669 | (define-electric-pair-test electric-quote-context-sensitive-after-letter-single | ||
| 670 | "a" "-'" :expected-string "a’" :expected-point 3 | ||
| 671 | :modes '(text-mode) | ||
| 672 | :fixture-fn #'electric-quote-local-mode | ||
| 673 | :bindings '((electric-quote-context-sensitive . t)) | ||
| 674 | :test-in-comments nil :test-in-strings nil) | ||
| 675 | |||
| 676 | (define-electric-pair-test electric-quote-context-sensitive-after-letter-double | ||
| 677 | "a’" "--'" :expected-string "a”" :expected-point 3 | ||
| 678 | :modes '(text-mode) | ||
| 679 | :fixture-fn #'electric-quote-local-mode | ||
| 680 | :bindings '((electric-quote-context-sensitive . t)) | ||
| 681 | :test-in-comments nil :test-in-strings nil) | ||
| 682 | |||
| 683 | (define-electric-pair-test electric-quote-context-sensitive-after-paren-single | ||
| 684 | "(" "-'" :expected-string "(‘" :expected-point 3 | ||
| 685 | :modes '(text-mode) | ||
| 686 | :fixture-fn #'electric-quote-local-mode | ||
| 687 | :bindings '((electric-quote-context-sensitive . t)) | ||
| 688 | :test-in-comments nil :test-in-strings nil) | ||
| 689 | |||
| 690 | (define-electric-pair-test electric-quote-context-sensitive-after-paren-double | ||
| 691 | "(‘" "--'" :expected-string "(“" :expected-point 3 | ||
| 692 | :modes '(text-mode) | ||
| 693 | :fixture-fn #'electric-quote-local-mode | ||
| 694 | :bindings '((electric-quote-context-sensitive . t)) | ||
| 695 | :test-in-comments nil :test-in-strings nil) | ||
| 696 | |||
| 697 | (define-electric-pair-test electric-quote-markdown-in-text | ||
| 698 | "" "'" :expected-string "’" :expected-point 2 | ||
| 699 | :modes '(text-mode) | ||
| 700 | :fixture-fn #'electric-quote-local-mode | ||
| 701 | :bindings '((electric-quote-code-faces font-lock-constant-face)) | ||
| 702 | :test-in-comments nil :test-in-strings nil) | ||
| 703 | |||
| 704 | (define-electric-pair-test electric-quote-markdown-in-code | ||
| 705 | #("`a`" 1 2 (face font-lock-constant-face)) "-'" | ||
| 706 | :expected-string "`'a`" :expected-point 3 | ||
| 707 | :modes '(text-mode) | ||
| 708 | :fixture-fn #'electric-quote-local-mode | ||
| 709 | :bindings '((electric-quote-code-faces font-lock-constant-face)) | ||
| 710 | :test-in-comments nil :test-in-strings nil) | ||
| 711 | |||
| 596 | (provide 'electric-tests) | 712 | (provide 'electric-tests) |
| 597 | ;;; electric-tests.el ends here | 713 | ;;; electric-tests.el ends here |