Simple image host.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

multiple-cursors-steps.el 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. (When "^I mark next like this$"
  2. (lambda () (call-interactively 'mc/mark-next-like-this)))
  3. (When "^I mark previous like this$"
  4. (lambda () (call-interactively 'mc/mark-previous-like-this)))
  5. (When "^I mark all like this$"
  6. (lambda () (call-interactively 'mc/mark-all-like-this)))
  7. (When "^I mark all like this dwim$"
  8. (lambda () (call-interactively 'mc/mark-all-like-this-dwim)))
  9. (When "^I mark all in region$"
  10. (lambda () (call-interactively 'mc/mark-all-in-region)))
  11. (When "^I insert numbers$"
  12. (lambda () (call-interactively 'mc/insert-numbers)))
  13. (When "^I reverse regions$"
  14. (lambda () (call-interactively 'mc/reverse-regions)))
  15. (When "^I sort regions$"
  16. (lambda () (call-interactively 'mc/sort-regions)))
  17. (When "^I edit lines$"
  18. (lambda () (call-interactively 'mc/edit-lines)))
  19. (When "^I set rectangular region anchor$"
  20. (lambda () (call-interactively 'set-rectangular-region-anchor)))
  21. (And "^delete-selection-mode is active$"
  22. (lambda ()
  23. (delete-selection-mode 1)))
  24. (Given "^I turn off transient-mark-mode$"
  25. (lambda ()
  26. (transient-mark-mode -1)))
  27. (Then "^I should have \\([0-9]+\\) cursors$"
  28. (lambda (num)
  29. (let ((actual (mc/num-cursors)))
  30. (assert (eq (string-to-number num) actual) nil
  31. "Expected to have %s cursors, but was %d." num actual))))
  32. (Then "^I should have one cursor$"
  33. (lambda ()
  34. (assert (not multiple-cursors-mode) nil
  35. "Expected to have one cursor, but multiple-cursors-mode is still active.")
  36. (assert (eq 1 (mc/num-cursors)) nil
  37. "Expected to have one cursor, but there are still fake cursor overlays.")))
  38. (Then "^rectangular-region-mode should be off$"
  39. (lambda ()
  40. (assert (not rectangular-region-mode) nil
  41. "Expected rectangular-region-mode mode to be off, but wasn't.")))
  42. (Then "^rectangular-region-mode should be on$"
  43. (lambda ()
  44. (assert rectangular-region-mode nil
  45. "Expected rectangular-region-mode mode to be on, but wasn't.")))
  46. (When "^I press \"\\(.+\\)\"$"
  47. (lambda (keybinding)
  48. (let ((macro (edmacro-parse-keys keybinding)))
  49. (if espuds-chain-active
  50. (setq espuds-action-chain (vconcat espuds-action-chain macro))
  51. (if (and (equal keybinding "C-g")
  52. (eq (key-binding (kbd "C-g")) 'keyboard-quit))
  53. (espuds-quit)
  54. (execute-kbd-macro macro))))))
  55. (Given "^I have cursors at \"\\(.+\\)\" in \"\\(.+\\)\"$"
  56. (lambda (needle haystack)
  57. (insert haystack)
  58. (goto-char (point-min))
  59. (search-forward needle)
  60. (set-mark (point))
  61. (goto-char (match-beginning 0))
  62. (mc/mark-all-like-this)
  63. (mc/keyboard-quit)))
  64. (When "^I copy \"\\(.+\\)\" in another program$"
  65. (lambda (text)
  66. (lexical-let ((text text))
  67. (setq interprogram-paste-function
  68. #'(lambda () (let ((r text)) (setq text nil) r))))))
  69. (Given "^I have bound C-! to a lambda that inserts \"\\(.+\\)\"$"
  70. (lambda (ins)
  71. (lexical-let ((ins ins))
  72. (global-set-key (kbd "C-!") #'(lambda () (interactive) (insert ins))))))
  73. (Given "^I have bound C-! to a new command that inserts \"\\(.+\\)\"$"
  74. (lambda (ins)
  75. (lexical-let ((ins ins))
  76. (defun mc-test-temp-command () (interactive) (insert ins))
  77. (global-set-key (kbd "C-!") 'mc-test-temp-command))))
  78. (Given "^I have bound C-! to another new command that inserts \"\\(.+\\)\"$"
  79. (lambda (ins)
  80. (lexical-let ((ins ins))
  81. (defun mc-test-temp-command-2 () (interactive) (insert ins))
  82. (global-set-key (kbd "C-!") 'mc-test-temp-command-2))))
  83. (Given "^I have bound C-! to a keyboard macro that insert \"_\"$"
  84. (lambda ()
  85. (fset 'mc-test-temp-kmacro "\C-q_")
  86. (global-set-key (kbd "C-!") 'mc-test-temp-kmacro)))
  87. (When "^I go to character \"\\(.+\\)\"$"
  88. (lambda (char)
  89. (goto-char (point-min))
  90. (let ((search (re-search-forward (format "%s" char) nil t))
  91. (message "Can not go to character '%s' since it does not exist in the current buffer: %s"))
  92. (assert search nil message char (espuds-buffer-contents)))))
  93. (When "^I go to the \\(front\\|end\\) of the word \"\\(.+\\)\"$"
  94. (lambda (pos word)
  95. (goto-char (point-min))
  96. (let ((search (re-search-forward (format "%s" word) nil t))
  97. (message "Can not go to character '%s' since it does not exist in the current buffer: %s"))
  98. (assert search nil message word (espuds-buffer-contents))
  99. (if (string-equal "front" pos) (backward-word)))))
  100. (When "^I select the last \"\\(.+\\)\"$"
  101. (lambda (text)
  102. (goto-char (point-max))
  103. (let ((search (re-search-backward text nil t)))
  104. (assert search nil "The text '%s' was not found in the current buffer." text))
  105. (set-mark (point))
  106. (re-search-forward text)))
  107. (When "^I mark all \\(.+\\)$"
  108. (lambda (rest)
  109. (let ((func (intern (mapconcat 'identity
  110. (cons "mc/mark-all"
  111. (split-string rest))
  112. "-"))))
  113. (call-interactively func))))