dotemacs

My Emacs configuration
git clone git://git.entf.net/dotemacs
Log | Files | Refs | LICENSE

expand-region-steps.el (2819B)


      1 ;; Copyright (C) 2012-2023  Free Software Foundation, Inc  -*- lexical-binding: t; -*-
      2 
      3 (Given "^mark is inactive by default$"
      4        (lambda ()
      5          (setq set-mark-default-inactive t)))
      6 
      7 (Given "^cursor behaviour is set to smart$"
      8        (lambda ()
      9          (setq expand-region-smart-cursor t)))
     10 
     11 (When "^I expand the region$"
     12       (lambda ()
     13         (cl-flet ((message (&rest args) nil))
     14           (er/expand-region 1))))
     15 
     16 (When "^I quit$"
     17       (lambda ()
     18         (cl-flet ((signal (&rest args) nil))
     19           (keyboard-quit))))
     20 
     21 (When "^I expand the region \\([0-9]+\\) times$"
     22       (lambda (arg)
     23         (cl-flet ((message (&rest args) nil))
     24           (er/expand-region (string-to-number arg)))))
     25 
     26 (And "^I contract the region$"
     27      (lambda ()
     28        (er/contract-region 1)))
     29 
     30 (When "^I place the cursor after \"\\(.+\\)\"$"
     31       (lambda (arg)
     32         (goto-char (point-min))
     33         (let ((search (search-forward arg nil t))
     34               (message "Can not place cursor after '%s', because there is no such point: '%s'"))
     35           (cl-assert search nil message arg (espuds-buffer-contents)))))
     36 
     37 (When "^I place the cursor before \"\\(.+\\)\"$"
     38       (lambda (arg)
     39         (goto-char (point-max))
     40         (let ((search (search-backward arg nil t))
     41               (message "Can not place cursor before '%s', because there is no such point: '%s'"))
     42           (cl-assert search nil message arg (espuds-buffer-contents)))))
     43 
     44 (When "^I pop the mark$"
     45       (lambda ()
     46         (set-mark-command 4)))
     47 
     48 (When "^I deactivate the mark$"
     49       (lambda ()
     50         (deactivate-mark)))
     51 
     52 (When "^I activate the mark$"
     53       (lambda ()
     54         (activate-mark)))
     55 
     56 (Then "^the region should not be active$"
     57       (lambda ()
     58         (should
     59          (not (region-active-p)))))
     60 
     61 (Then "^cursor should be at point \"\\(.+\\)\"$"
     62       (lambda (arg)
     63         (should
     64          (=
     65           (string-to-number arg)
     66           (point)))))
     67 
     68 (And "^autocopy-register is \"\\(.\\)\"$"
     69       (lambda (reg)
     70         (setq expand-region-autocopy-register reg)
     71         (set-register (aref reg 0) nil)))
     72 
     73 (Then "^register \"\\(.\\)\" should be \"\\(.+\\)\"$"
     74       (lambda (reg contents)
     75         (should
     76          (equal contents (get-register (aref reg 0))))))
     77 
     78 (When "^I go to the \\(front\\|end\\) of the word \"\\(.+\\)\"$"
     79       (lambda (pos word)
     80         (goto-char (point-min))
     81         (let ((search (re-search-forward (format "%s" word) nil t))
     82               (message "Can not go to character '%s' since it does not exist in the current buffer: %s"))
     83           (cl-assert search nil message word (espuds-buffer-contents))
     84           (if (string-equal "front" pos) (backward-word)))))
     85 
     86 (When "^I set \\(.+\\) to \\(.+\\)$"
     87       (lambda (var val)
     88         (set (intern var) (read val))))
     89 ;; Local Variables:
     90 ;; no-byte-compile: t
     91 ;; End: