[
  {
    "path": ".github/CONTRIBUTING.md",
    "content": "# Contributing\n\nPlease write a failing test before submitting pull requests. All new features should be accompanied by new tests.\n\nTests are written in [Ecukes](https://github.com/ecukes/ecukes), an integration testing framework for Emacs.\n\n## Setup\n\nTo fetch the test dependencies, install [cask](https://github.com/cask/cask):\n\n```bash\ncurl -fsSkL https://raw.github.com/cask/cask/master/go | python\n```\n\nthen:\n\n```bash\ncd /path/to/god-mode\ncask\n```\n\nRun the tests with:\n\n```bash\ncask exec ecukes\n```\n"
  },
  {
    "path": ".github/README.md",
    "content": "# God Mode — no more RSI\n\n[![melpa-badge][melpa-badge]][melpa-link]\n[![melpa-stable-badge][melpa-stable-badge]][melpa-stable-link]\n[![gh-actions-badge][gh-actions-badge]][gh-actions-link]\n\n_NOTE_: This package requires Emacs 26.3 to work well.\n\nThis is a global minor mode for entering Emacs commands without\nmodifier keys. It's similar to Vim's separation of command mode and\ninsert mode.\n\nAll existing key bindings will work in God mode. It's only there to reduce your\nusage of modifier keys.\n\n## Example\n\nIn the example below, you can see how much effort is reduced:\n\n```\nBefore: C-p C-k C-n M-^ ) C-j C-y M-r C-x z z M-2 M-f C-x C-s\nAfter:    p   k   n g ^ )   j   y g r     . .   2 g f   x   s\n```\n\n(Regarding <kbd>.</kbd>, see the [useful key bindings section][useful-key-bindings].)\n\nYou'll find this mode surprisingly natural, as you would already know how to use\nyour existing Emacs commands. Whenever you feel like it, you can explicitly use\nmodifier keys too.\n\nSee the [key mapping section][key-mapping] for a complete walk-through of key\ntranslations.\n\n## Setup\n\nYou can load and activate God mode as follows:\n\n```emacs-lisp\n(require 'god-mode)\n(god-mode)\n```\n\nThis will activate God mode in all future buffers. However, activation of God\nmode itself is buffer-local.\n\nGod mode can be toggled through `god-local-mode` using the escape key\n(<kbd>ESC</kbd>) as follows:\n\n```emacs-lisp\n(global-set-key (kbd \"<escape>\") #'god-local-mode)\n```\n\nIf you want to toggle God mode on _all active and future buffers_, use\n`god-mode-all` as follows:\n\n```emacs-lisp\n(global-set-key (kbd \"<escape>\") #'god-mode-all)\n```\n\nIf God mode is activated through `god-mode` or `god-mode-all`, you might want to\nensure that no buffers are skipped, as follows:\n\n```emacs-lisp\n(setq god-exempt-major-modes nil)\n(setq god-exempt-predicates nil)\n```\n\nThis means that `magit-mode` or `dired-mode`, for example, will also enter God\nmode when you activate it in all buffers. This means you can always reliably use\nGod mode commands in any buffer.\n\nWhen God mode is enabled, entering function keys will be translated to use\nappropriate key modifiers. For example, entering <kbd>&lt;f5></kbd> is\ntranslated to <kbd>C-&lt;f5></kbd>. To disable this translation, you can set the\n`god-mode-enable-function-key-translation` variable to `nil` before loading God\nmode, as follows:\n\n``` emacs-lisp\n(setq god-mode-enable-function-key-translation nil)\n(require 'god-mode)\n```\n\nAlso, you can add this to your `.xmodmap` to rebind the caps lock key to the\nescape key:\n\n```\nremove Lock = Caps_Lock\nkeysym Caps_Lock = Escape\n```\n\nAnd run `xmodmap .xmodmap` for the changes to take effect immediately.\n\nOr use `dconf`:\n\n``` sh\ndconf write /org/gnome/desktop/input-sources/xkb-options \"['caps:escape']\"\n```\n\nSee [this link][switch-caps-lock-and-esc] for more details.\n\n## Key mapping\n\nThis package defines the following key mappings:\n\n* All commands are assumed to use the control modifier (<kbd>C-</kbd>) unless \n  otherwise indicated. Here are some examples:\n\n   * <kbd>x</kbd> → <kbd>C-x</kbd>\n   * <kbd>f</kbd> → <kbd>C-f</kbd>\n   * <kbd>x</kbd> <kbd>s</kbd> → <kbd>C-x</kbd> <kbd>C-s</kbd>\n   * <kbd>x</kbd> <kbd>SPC</kbd> <kbd>s</kbd> → <kbd>C-x</kbd> <kbd>s</kbd>\n\n   Note the use of the space key (<kbd>SPC</kbd>)\n   to produce <kbd>C-x</kbd> <kbd>s</kbd>.\n\n* The literal key (<kbd>SPC</kbd>) is sticky. This means you don't have to enter \n  <kbd>SPC</kbd> repeatedly for key bindings such as <kbd>C-x</kbd> <kbd>r</kbd> <kbd>t</kbd>.\n  Entering the literal key again toggles its state.\n  The literal key can be changed through `god-literal-key`. Here are some examples:\n  \n   * <kbd>x</kbd> <kbd>SPC</kbd> <kbd>r</kbd> <kbd>t</kbd> → <kbd>C-x</kbd> <kbd>r</kbd> <kbd>t</kbd>\n   * <kbd>x</kbd> <kbd>SPC</kbd> <kbd>r</kbd> <kbd>SPC</kbd> <kbd>g</kbd> <kbd>w</kbd> → <kbd>C-x</kbd> <kbd>r</kbd> <kbd>M-w</kbd>\n\n* <kbd>g</kbd> is used to indicate the meta modifier (<kbd>M-</kbd>). This means\n  that there is no way to enter <kbd>C-g</kbd> in God mode, and you must\n  therefore type in <kbd>C-g</kbd> directly. This key can be changed through\n  `god-mode-alist`. Here are some examples:\n\n   * <kbd>g</kbd> <kbd>x</kbd> → <kbd>M-x</kbd>\n   * <kbd>g</kbd> <kbd>f</kbd> → <kbd>M-f</kbd>\n\n* <kbd>G</kbd> is used to indicate both the control and meta modifiers\n  (<kbd>C-M-</kbd>). This key can also be changed through `god-mode-alist`. Here\n  are some examples:\n\n   * <kbd>G</kbd> <kbd>x</kbd> → <kbd>C-M-x</kbd>\n   * <kbd>G</kbd> <kbd>f</kbd> → <kbd>C-M-f</kbd>\n\n* Digit arguments can also be used:\n\n  * <kbd>1</kbd> <kbd>2</kbd> <kbd>f</kbd> → <kbd>M-12</kbd> <kbd>C-f</kbd>\n\n* If you use some of the [useful key bindings][useful-key-bindings],\n  <kbd>z</kbd> or <kbd>.</kbd> can repeat the previous command:\n\n  * <kbd>g</kbd> <kbd>f</kbd> <kbd>.</kbd> <kbd>.</kbd> → <kbd>M-f</kbd>\n    <kbd>M-f</kbd> <kbd>M-f</kbd>\n\n* Universal arguments can also be specified using <kbd>u</kbd>:\n\n  * <kbd>u</kbd> <kbd>c</kbd> <kbd>o</kbd> → <kbd>C-u</kbd> <kbd>C-c</kbd>\n    <kbd>C-o</kbd>\n\n## \tLookup a key sequence\nYou can use `god-mode-describe-key` to check what command would be triggered by particular keys. This function works similarly to `describe-key`: it prompts for a key combination, translates it into a command, and display its information in the Help buffer.\n\nBy default, `god-mode-describe-key` is bound to `C-h k` in `god-local-mode-map`.\n\nNote that `god-mode-describe-key` is only able to interpret key-bindings that are specific to `god-mode`. For other key-bindings, mouse-clicks, and menu items, it's better to use `describe-key`.\n\n## Visual indicators for God mode\n\nGod mode allows you to customize its minor mode lighter by customizing the `god-mode-lighter-string` variable and the `god-mode-lighter` face.\nFor example, if you don't want any lighter, you can set the string to nil.\nOn the other hand, if you want the lighter to stand out, you can change the face, e.g. by making it inherit from `error`.\nYou can do this using `M-x customize-face RET god-mode-lighter` or as follows:\n\n```emacs-lisp\n(custom-set-faces\n '(god-mode-lighter ((t (:inherit error)))))\n```\n\nAdditionally, you can change the cursor style to visually indicate whether God mode is active\nas follows:\n\n```emacs-lisp\n(defun my-god-mode-update-cursor-type ()\n  (setq cursor-type (if (or god-local-mode buffer-read-only) 'box 'bar)))\n\n(add-hook 'post-command-hook #'my-god-mode-update-cursor-type)\n```\n\nYou can also change the foreground and background of the mode line to indicate\nwhether God mode is active as follows:\n\n```emacs-lisp\n(defun my-god-mode-update-mode-line ()\n  (cond\n   (god-local-mode\n    (set-face-attribute 'mode-line nil\n                        :foreground \"#604000\"\n                        :background \"#fff29a\")\n    (set-face-attribute 'mode-line-inactive nil\n                        :foreground \"#3f3000\"\n                        :background \"#fff3da\"))\n   (t\n    (set-face-attribute 'mode-line nil\n\t\t\t:foreground \"#0a0a0a\"\n\t\t\t:background \"#d7d7d7\")\n    (set-face-attribute 'mode-line-inactive nil\n\t\t\t:foreground \"#404148\"\n\t\t\t:background \"#efefef\"))))\n\n(add-hook 'post-command-hook #'my-god-mode-update-mode-line)\n```\n\nNote that using `post-command-hook` here should not be an issue for performance.\nIf you are concerned about performance for any reason, you can use\n`god-mode-enabled-hook` and `god-mode-disabled-hook`.\nWith Emacs 27.1+, you can also use [window hooks][window-hooks].\n\n\n## `overwrite-mode`\n\nYou can pause or resume God mode depending on whether `overwrite-mode` is\nactivated as follows:\n\n```emacs-lisp\n(defun my-god-mode-toggle-on-overwrite ()\n  \"Toggle god-mode on overwrite-mode.\"\n  (if (bound-and-true-p overwrite-mode)\n      (god-local-mode-pause)\n    (god-local-mode-resume)))\n\n(add-hook 'overwrite-mode-hook #'my-god-mode-toggle-on-overwrite)\n```\n\n## `isearch` integration\n\nThere is an optional feature for providing God mode behaviour in `isearch`. It\nallows you to hit <kbd>ESC</kbd>, for example, while in `isearch` to enable God\nmode. Here's a more complete example:\n\n<kbd>s</kbd> <kbd>h</kbd> <kbd>e</kbd> <kbd>y</kbd> <kbd>ESC</kbd> \n<kbd>s</kbd> <kbd>s</kbd> <kbd>s</kbd> <kbd>RET</kbd> → <kbd>C-s</kbd>\n<kbd>h</kbd> <kbd>e</kbd> <kbd>y</kbd> <kbd>C-s</kbd> <kbd>C-s</kbd>\n<kbd>C-s</kbd> <kbd>RET</kbd>\n\nYou can load and activate this feature as follows:\n\n```emacs-lisp\n(require 'god-mode-isearch)\n(define-key isearch-mode-map (kbd \"<escape>\") #'god-mode-isearch-activate)\n(define-key god-mode-isearch-map (kbd \"<escape>\") #'god-mode-isearch-disable)\n```\n\nYou can also configure `god-mode-isearch-map` for additional keybindings.\n\n## Rebinding `self-insert-command`\n\nYou can rebind `self-insert-command` as you prefer. For example, here's a\nmapping that calls `org-self-insert-command` in `org-mode`:\n\n```emacs-lisp\n(defun my-god-mode-self-insert ()\n  (interactive)\n  (if (and (bolp)\n           (eq major-mode 'org-mode))\n      (call-interactively 'org-self-insert-command)\n    (call-interactively 'god-mode-self-insert)))\n\n(define-key god-local-mode-map [remap self-insert-command] #'my-god-mode-self-insert)\n```\n\n## Useful key bindings\n\nFor vim refugees, consider using `i` and `<escape>` to toggle god-mode off and\non:\n\n```emacs-lisp\n(define-key god-local-mode-map (kbd \"i\") #'god-local-mode)\n(global-set-key (kbd \"<escape>\") #'(lambda () (interactive) (god-local-mode 1)))\n```\n\nThe following key binding is also popular:\n\n```emacs-lisp\n(define-key god-local-mode-map (kbd \"z\") #'repeat)\n```\n\nAlthough I personally prefer:\n\n```emacs-lisp\n(define-key god-local-mode-map (kbd \".\") #'repeat)\n```\n\nThese are also handy:\n\n```emacs-lisp\n(global-set-key (kbd \"C-x C-1\") #'delete-other-windows)\n(global-set-key (kbd \"C-x C-2\") #'split-window-below)\n(global-set-key (kbd \"C-x C-3\") #'split-window-right)\n(global-set-key (kbd \"C-x C-0\") #'delete-window)\n\n(define-key god-local-mode-map (kbd \"[\") #'backward-paragraph)\n(define-key god-local-mode-map (kbd \"]\") #'forward-paragraph)\n```\n\nSo that you can run <kbd>x</kbd> <kbd>1</kbd>, <kbd>x</kbd>\n<kbd>2</kbd>, <kbd>x</kbd> <kbd>3</kbd>, and <kbd>x</kbd> <kbd>0</kbd> in God mode.\n\n## Exempt major modes\n\n_NOTE_: This is less necessary in recent versions of God mode, as\nit overrides all printable single byte keys and bindings in \nmost major modes.\n\nSometimes, God mode is enabled in buffers where it makes no sense. In\nsuch cases, you can add the major mode to `god-exempt-major-modes`:\n\n```emacs-lisp\n(add-to-list 'god-exempt-major-modes 'dired-mode)\n```\n\nSince `dired-mode` is already in the list, that's a no-op, but you get\nthe idea. Consider opening an issue or pull request if you find a\nmajor mode that should be on the official list.\n\nAnother option to control the behavior of God mode in new buffers is to provide\na function with no arguments that must return non-nil if God mode should be\ndisabled in the current buffer. See the `god-exempt-predicates` variable and its\ndefault members `god-exempt-mode-p`, `god-comint-mode-p`, `god-view-mode-p` and\n`god-special-mode-p` for further details.\n\n## Usage with Evil\n\n[Evil][evil] is a popular Emacs package that provides modal editing in the style\nof Vi. While Evil doesn't always work well with God mode, there are a few simple\ncustomizations that enable them to be used together smoothly.\n\n* For running occasional and single commands in God mode, the built-in\n  `god-execute-with-current-bindings` command works well with Evil without\n  additional customization. This is quite similar to Evil's\n  `evil-execute-in-emacs-state` command. All Evil bindings remain available when\n  using `god-execute-with-current-bindings`. For example, executing\n  `god-execute-with-current-bindings` and entering <kbd>v</kbd> will execute\n  `evil-visual-block`, which is bound to <kbd>C-v</kbd> in Evil's Normal state.\n\n* For sustained usage of God mode, it's a bit trickier as keybindings in Evil\n  states generally override God mode. For example, if God mode is activated in\n  Normal state, entering <kbd>v</kbd> executes `evil-visual-char`, which is\n  bound to <kbd>v</kbd> in Normal state, instead of executing\n  `evil-visual-block`. A good option to use Evil's state-specific keybindings\n  through God mode is to create an intercept keymap using\n  `evil-make-intercept-map` and `god-local-mode-map`. For example, you can\n  enable use of God mode in Normal state as follows:\n\n  ```emacs-lisp\n  (with-eval-after-load 'god-mode\n    (evil-make-intercept-map god-local-mode-map 'normal)\n    (add-hook 'god-local-mode-hook #'evil-normalize-keymaps))\n  ```\n\n* Another option to use God mode with Evil is to use the\n  [`evil-god-state`][evil-god-state] package, which provides a dedicated Evil\n  state for using God mode. For running occasional, single commands through God\n  mode, use the `evil-execute-in-god-state` command. This works similar to\n  `god-execute-with-current-bindings`. For sustained use of God mode, use the\n  `evil-god-state` command. `evil-god-state` is also useful for accessing\n  default Emacs keybindings through God mode. However, a disadvantage of\n  `evil-god-state` is that Evil's state-specific keybindings will not be\n  available in God mode.\n \n* [`evil-god-toggle`][evil-god-toggle] is an expanded version of\n  `evil-god-state` with features like persistence of visual selections\n  to corresponding active regions, global `god-mode` scope, and a\n  `god-off` which is like `emacs-state` but more easy to toggle in and\n  out of.  The ability to use a persistent `god-state` is also better\n  documented.\n\n[useful-key-bindings]: #useful-key-bindings\n[key-mapping]: #key-mapping\n[switch-caps-lock-and-esc]: https://askubuntu.com/questions/363346/how-to-permanently-switch-caps-lock-and-esc\n[melpa-link]: https://melpa.org/#/god-mode\n[melpa-stable-link]: https://stable.melpa.org/#/god-mode\n[melpa-badge]: https://melpa.org/packages/god-mode-badge.svg\n[melpa-stable-badge]: https://stable.melpa.org/packages/god-mode-badge.svg\n[gh-actions-link]: https://github.com/emacsorphanage/god-mode/actions?query=workflow%3ACI+branch%3Amaster\n[gh-actions-badge]: https://github.com/emacsorphanage/god-mode/actions/workflows/test.yml/badge.svg?branch=master\n[evil]: https://github.com/emacs-evil/evil\n[evil-god-state]: https://github.com/gridaphobe/evil-god-state\n[evil-god-toggle]: https://github.com/jam1015/evil-god-toggle\n[window-hooks]: https://www.gnu.org/software/emacs/manual/html_node/elisp/Window-Hooks.html\n"
  },
  {
    "path": ".github/workflows/test.yml",
    "content": "name: CI\n\non: [push, pull_request]\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        emacs_version:\n          - 26.3\n          - 27.2\n          - 28.1\n          - 28.2\n          - 29.1\n          - 29.2\n          - 29.3\n          - 29.4\n          - 30.1\n          - snapshot\n        include:\n          - emacs_version: snapshot\n            allow_failure: true\n    steps:\n    - uses: purcell/setup-emacs@master\n      with:\n        version: ${{ matrix.emacs_version }}\n    - uses: actions/checkout@v1\n    - uses: conao3/setup-cask@master\n      if: steps.cache-cask-executable.outputs.cache-hit != 'true'\n      with:\n        version: snapshot\n    - name: Install dependencies\n      run: 'cask install'\n    - name: Run tests\n      if: matrix.allow_failure != true\n      run: 'cask exec ecukes'\n    - name: Run tests (allow failure)\n      if: matrix.allow_failure == true\n      run: 'cask exec ecukes || true'\n"
  },
  {
    "path": ".gitignore",
    "content": ".cask\n.ecukes-failing-scenarios\n*.elc\n"
  },
  {
    "path": "Cask",
    "content": "(source gnu)\n(source melpa)\n\n(package \"god-mode\" \"2.19.0\" \"God-like command entering minor mode.\")\n\n(development\n (depends-on \"ecukes\")\n (depends-on \"ansi\"))\n"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<http://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<http://www.gnu.org/philosophy/why-not-lgpl.html>.\n"
  },
  {
    "path": "features/c-commands.feature",
    "content": "Feature: C- commands\n  Background:\n    Given I am in buffer \"god-mode-test\"\n    And the buffer is empty\n    And I insert:\n    \"\"\"\n    laziness\n    impatience\n    hubris\n    \"\"\"\n    Then I have god-mode on\n\n  Scenario: map k into kill-line\n    Given I go to line \"1\"\n    When I send the key sequence \"kk\"\n    Then the buffer's contents should be:\n    \"\"\"\n    impatience\n    hubris\n    \"\"\"\n\n  Scenario: map / into undo\n    Given I go to line \"1\"\n    And I send the key sequence \"kk\"\n    When I send the key sequence \"//\"\n    Then the buffer's contents should be:\n    \"\"\"\n    laziness\n    impatience\n    hubris\n    \"\"\"\n\n  Scenario: execute named keyboard macro\n    Given I go to line \"1\"\n    And I bind a named keyboard macro which kills line to C-c C-r\n    When I send the key sequence \"cr\"\n    Then the buffer's contents should be:\n    \"\"\"\n    impatience\n    hubris\n    \"\"\"\n\n  Scenario: execute C-[god-literal-key]\n    Given I bind \"C-SPC\" to \"set-mark-command\"\n    And I go to beginning of buffer\n    And I send the key sequence \"SPC\"\n    And I go to end of buffer\n    When I send the key sequence \"u SPC\"\n    Then the cursor should be at point \"1\"\n\n  Scenario: execute long sequence of literals\n    Given I bind \"C-c b e g\" to \"beginning-of-buffer\"\n    And I go to end of buffer\n    When I send the key sequence \"c SPC b e g\"\n    Then the cursor should be at point \"1\"\n\n  Scenario: toggle god-literal-key\n    Given I bind \"C-c k M-l\" to \"beginning-of-buffer\"\n    And I go to end of buffer\n    When I send the key sequence \"c SPC k SPC g l\"\n    Then the cursor should be at point \"1\"\n\n  Scenario: toggle god-literal-key (sticky)\n    Given I bind \"C-c k l\" to \"beginning-of-buffer\"\n    And I go to end of buffer\n    When I send the key sequence \"c SPC k l\"\n    Then the cursor should be at point \"1\"\n\n  Scenario: execute commands with C-arrow\n    Given I bind \"C-x C-<left>\" to \"backward-word\"\n    And I go to line \"1\"\n    And I go to end of line\n    When I send the key sequence \"x <left>\"\n    Then the cursor should be at point \"1\"\n\n  Scenario: execute commands with uppercase letters (control)\n    Given I bind \"C-S-A\" to \"beginning-of-buffer\"\n    And I go to end of buffer\n    When I send the key sequence \"A\"\n    Then the cursor should be at point \"1\"\n\n  Scenario: execute commands with uppercase letters (control+meta)\n    Given I bind \"C-M-S-A\" to \"beginning-of-buffer\"\n    And I go to end of buffer\n    When I send the key sequence \"GA\"\n    Then the cursor should be at point \"1\"\n\n  Scenario: execute commands with uppercase letters (meta)\n    Given I bind \"M-A\" to \"beginning-of-buffer\"\n    And I go to end of buffer\n    When I send the key sequence \"g A\"\n    Then the cursor should be at point \"1\"\n\n  Scenario: execute commands with uppercase letters (combination)\n    Given I bind \"C-x C-S-A\" to \"beginning-of-buffer\"\n    And I go to end of buffer\n    When I send the key sequence \"xA\"\n    Then the cursor should be at point \"1\"\n\n  Scenario: execute commands with uppercase letters (literal)\n    Given I bind \"C-c L\" to \"beginning-of-buffer\"\n    And I go to end of buffer\n    When I send the key sequence \"c SPC L\"\n    Then the cursor should be at point \"1\"\n\n  Scenario: execute commands with delete (control)\n    Given I bind \"C-c C-<delete>\" to \"beginning-of-buffer\"\n    And I go to end of buffer\n    When I send the key sequence \"c <delete>\"\n    Then the cursor should be at point \"1\"\n\n  Scenario: execute commands with shifted arrows (control)\n    Given I bind \"C-x C-S-<left>\" to \"beginning-of-buffer\"\n    And I go to end of buffer\n    When I send the key sequence \"x S-<left>\"\n    Then the cursor should be at point \"1\"\n\n  Scenario: execute commands with shifted arrows (meta)\n    Given I bind \"M-S-<left>\" to \"beginning-of-buffer\"\n    And I go to end of buffer\n    When I send the key sequence \"g S-<left>\"\n    Then the cursor should be at point \"1\"\n\n  Scenario: execute commands with shifted arrows (shift)\n    Given I bind \"C-c C-S-<left>\" to \"beginning-of-buffer\"\n    And I go to end of buffer\n    When I send the key sequence \"c S-<left>\"\n    Then the cursor should be at point \"1\"\n\n  Scenario: execute commands with numbered function keys (literal)\n    Given I bind \"C-c <f12>\" to \"beginning-of-buffer\"\n    And I go to end of buffer\n    When I send the key sequence \"c SPC <f12>\"\n    Then the cursor should be at point \"1\"\n\n  Scenario: execute commands with numbered function keys (control)\n    Given I bind \"C-c C-<f12>\" to \"beginning-of-buffer\"\n    And I go to end of buffer\n    When I send the key sequence \"c <f12>\"\n    Then the cursor should be at point \"1\"\n\n  Scenario: execute commands with numbered function keys (meta)\n    Given I bind \"C-c M-<f12>\" to \"beginning-of-buffer\"\n    And I go to end of buffer\n    When I send the key sequence \"c g <f12>\"\n    Then the cursor should be at point \"1\"\n\n  Scenario: execute commands with numbered function keys (control+shift)\n    Given I bind \"C-c C-S-<f12>\" to \"beginning-of-buffer\"\n    And I go to end of buffer\n    When I send the key sequence \"c S-<f12>\"\n    Then the cursor should be at point \"1\"\n\n  Scenario: execute commands with shift and space (control+shift)\n    Given I bind \"C-c C-S-SPC\" to \"beginning-of-buffer\"\n    And I go to end of buffer\n    When I send the key sequence \"c S-SPC\"\n    Then the cursor should be at point \"1\"\n\n  Scenario: execute commands with shift and return (control+shift)\n    Given I bind \"C-c C-S-<return>\" to \"beginning-of-buffer\"\n    And I go to end of buffer\n    When I send the key sequence \"c <S-return>\"\n    Then the cursor should be at point \"1\"\n\n  Scenario: execute commands with fallback lookup\n    Given I bind \"C-c a\" to \"beginning-of-buffer\"\n    And I go to end of buffer\n    When I send the key sequence \"c a\"\n    Then the cursor should be at point \"1\"\n\n  Scenario: execute commands with shift and tab (control+shift)\n    Given I bind \"C-c C-S-<iso-lefttab>\" to \"beginning-of-buffer\"\n    And I go to end of buffer\n    When I send the key sequence \"c <S-iso-lefttab>\"\n    Then the cursor should be at point \"1\"\n\n  Scenario: execute commands with shift and backspace (control+shift)\n    Given I bind \"C-c C-S-<backspace>\" to \"beginning-of-buffer\"\n    And I go to end of buffer\n    When I send the key sequence \"c <S-backspace>\"\n    Then the cursor should be at point \"1\"\n\n  Scenario: execute commands with shift and delete (control+shift)\n    Given I bind \"C-c C-S-<delete>\" to \"beginning-of-buffer\"\n    And I go to end of buffer\n    When I send the key sequence \"c <S-delete>\"\n    Then the cursor should be at point \"1\"\n\n  Scenario: execute commands with shift and space (meta+shift)\n    Given I bind \"M-S-SPC\" to \"beginning-of-buffer\"\n    And I go to end of buffer\n    When I send the key sequence \"g S-SPC\"\n    Then the cursor should be at point \"1\"\n\n  Scenario: execute commands with shift and return (meta+shift)\n    Given I bind \"M-S-<return>\" to \"beginning-of-buffer\"\n    And I go to end of buffer\n    When I send the key sequence \"g S-<return>\"\n    Then the cursor should be at point \"1\"\n\n  Scenario: execute commands with shift and tab (meta+shift)\n    Given I bind \"M-S-<iso-lefttab>\" to \"beginning-of-buffer\"\n    And I go to end of buffer\n    When I send the key sequence \"g <S-iso-lefttab>\"\n    Then the cursor should be at point \"1\"\n\n  Scenario: execute commands with shift and backspace (meta+shift)\n    Given I bind \"M-S-<backspace>\" to \"beginning-of-buffer\"\n    And I go to end of buffer\n    When I send the key sequence \"g S-<backspace>\"\n    Then the cursor should be at point \"1\"\n\n  Scenario: execute commands with shift and backspace (meta+shift)\n    Given I bind \"M-S-<delete>\" to \"beginning-of-buffer\"\n    And I go to end of buffer\n    When I send the key sequence \"g S-<delete>\"\n    Then the cursor should be at point \"1\"\n"
  },
  {
    "path": "features/digit-arguments.feature",
    "content": "Feature: Digit arguments\n  Background:\n    Given I am in buffer \"god-mode-test\"\n    And the buffer is empty\n    And I insert \"abcdefghijklmnopqrstuvwxyz\"\n    And I have god-mode on\n    And I go to line \"1\"\n\n  Scenario: M-5 C-d does delete 5 times\n    When I send the key sequence \"M-5 C-d\"\n    Then the buffer's contents should be \"fghijklmnopqrstuvwxyz\"\n\n  Scenario: 5d does delete 5 times\n    When I send the key sequence \"5d\"\n    Then the buffer's contents should be \"fghijklmnopqrstuvwxyz\"\n"
  },
  {
    "path": "features/execute-with-current-bindings.feature",
    "content": "Feature: Execute with current bindings\n  Background:\n    Given I am in buffer \"god-mode-test\"\n    And I bind \"C-e\" to \"god-execute-with-current-bindings\"\n    And the buffer is empty\n    And I insert \"abcdefghijkl\"\n    And I go to beginning of buffer\n\n  Scenario: no effect when already in God mode\n    Given I have god-mode on\n    When I send the key sequence \"C-e q Z\"\n    Then the buffer's contents should be \"Zabcdefghijkl\"\n    And god-mode is enabled\n    \n  Scenario: runs one command in God mode\n    Given I am in insertion mode\n    When I send the key sequence \"C-e q Z\"\n    Then the buffer's contents should be \"Zabcdefghijkl\"\n    And god-mode is disabled\n\n  Scenario: handles prefix arguments\n    Given I am in insertion mode\n    When I send the key sequence \"C-u 1 C-e 0 f\"\n    Then the cursor should be at point \"11\"\n"
  },
  {
    "path": "features/insertion-mode.feature",
    "content": "Feature: Insertion mode\n  Background:\n    Given I am in buffer \"god-mode-test\"\n    And the buffer is empty\n    And I am in insertion mode\n\n  Scenario: C-u u inserts u 4 times\n    When I send the key sequence \"C-u u\"\n    Then the buffer's contents should be \"uuuu\"\n\n  Scenario: C-u C-u u inserts u 16 times\n    When I send the key sequence \"C-u C-u u\"\n    Then the buffer's contents should be \"uuuuuuuuuuuuuuuu\"\n"
  },
  {
    "path": "features/last-command-event.feature",
    "content": "Feature: Prefix arguments\n  Background:\n    Given I am in buffer \"god-mode-test\"\n    And the buffer is empty\n    And I insert \"abcdefghijklmnopqrstuvwxyz\"\n    And I have god-mode on\n    And I go to line \"1\"\n\n  Scenario: M-4 C-d does delete 4 times\n    When I send the key sequence \"M-4 C-d\"\n    Then the buffer's contents should be \"efghijklmnopqrstuvwxyz\"\n\n  Scenario: g4d does delete 4 times\n    When I send the key sequence \"g4d\"\n    Then the buffer's contents should be \"efghijklmnopqrstuvwxyz\"\n"
  },
  {
    "path": "features/predicates-disable.feature",
    "content": "Feature: Predicate based disable\n  Background:\n    Given god-mode is enabled for all buffers\n    And I am in buffer \"god-mode-test\"\n    And I describe function \"god-mode\"\n    And I grep current directory\n    And I start ielm\n\n  Scenario: God mode is automatically enabled for fundamental-mode\n    When I switch to buffer \"god-mode-test\"\n    Then god-mode is enabled\n\n  Scenario: God mode is disabled for help-mode (a special derived mode)\n    When I switch to buffer \"*Help*\"\n    Then god-mode is disabled\n\n  Scenario: God mode is disabled for grep-mode (an explicitly disabled mode)\n    When I switch to buffer \"*grep*\"\n    Then god-mode is disabled\n\n  Scenario: God mode is disabled in buffers with view-mode\n    When I open a view-mode buffer\n    Then god-mode is disabled\n\n  Scenario: God mode is disabled in comint derived buffers\n    When I switch to buffer \"*ielm*\"\n    Then god-mode is disabled\n\n  Scenario: God mode is disabled in mode-class special buffers\n    When I open a test-special-mode buffer\n    Then god-mode is disabled\n"
  },
  {
    "path": "features/prefix-arguments.feature",
    "content": "Feature: Prefix arguments\n  Background:\n    Given I am in buffer \"god-mode-test\"\n    And the buffer is empty\n    And I insert \"abcdefghijklmnopqrstuvwxyz\"\n    And I have god-mode on\n    And I go to line \"1\"\n\n  Scenario: C-u C-d does delete 4 times\n    When I send the key sequence \"C-u C-d\"\n    Then the buffer's contents should be \"efghijklmnopqrstuvwxyz\"\n\n  Scenario: ud does delete 4 times\n    When I send the key sequence \"ud\"\n    Then the buffer's contents should be \"efghijklmnopqrstuvwxyz\"\n\n  Scenario: C-u C-u C-d does delete 16 times\n    When I send the key sequence \"C-u C-u C-d\"\n    Then the buffer's contents should be \"qrstuvwxyz\"\n\n  Scenario: uud does delete 16 times\n    When I send the key sequence \"uud\"\n    Then the buffer's contents should be \"qrstuvwxyz\"\n"
  },
  {
    "path": "features/prefix-help.feature",
    "content": "Feature: Prefix help\n  Background:\n    Given I am in buffer \"god-mode-test\"\n    And the buffer is empty\n    And I have god-mode on\n    And I bind \"C-c C-e\" to \"end-of-line\"\n    And I bind \"M-s C-e\" to \"end-of-line\"\n\n  Scenario: shows help on entering C-h (control)\n    When I send the key sequence \"C-c C-h\"\n    Then there is a \"*Help*\" buffer\n\n  Scenario: help buffer shows relevant bindings (control)\n    Given I send the key sequence \"C-c C-h\"\n    When I switch to buffer \"*Help*\"\n    Then the buffer's contents should contain \"Major Mode Bindings Starting With C-c:\"\n    And the buffer's contents should contain \"Global Bindings Starting With C-c:\"\n\n  Scenario: shows help on entering C-h (meta)\n    When I send the key sequence \"M-s C-h\"\n    Then there is a \"*Help*\" buffer\n\n  Scenario: help buffer shows relevant bindings (meta)\n    Given I send the key sequence \"M-s C-h\"\n    When I switch to buffer \"*Help*\"\n    Then the buffer's contents should contain \"Major Mode Bindings Starting With M-s:\"\n    And the buffer's contents should contain \"Global Bindings Starting With M-s:\"\n"
  },
  {
    "path": "features/regions.feature",
    "content": "Feature: Regions\n  Background:\n    Given I am in buffer \"god-mode-test\"\n    And the buffer is empty\n    And I insert \"Here we go\"\n    And I have god-mode on\n    And I go to beginning of buffer\n    And I set the mark\n\n  Scenario: mark is preserved (control)\n    When I send the key sequence \"f\"\n    Then the region should be \"H\"\n\n  Scenario: mark is preserved (meta)\n    When I send the key sequence \"gf\"\n    Then the region should be \"Here\"\n\n  Scenario: mark is preserved (control+meta)\n    When I send the key sequence \"gfGf\"\n    Then the region should be \"Here we\"\n"
  },
  {
    "path": "features/repeat.feature",
    "content": "Feature: Repeat\n  Background:\n    Given I am in buffer \"god-mode-test\"\n    And the buffer is empty\n    And I insert \"abcdefghijklmnopqrstuvwxyz one two three\"\n    And I have god-mode on\n    And I go to line \"1\"\n\n  Scenario: M-5 C-d C-x z does delete 5 times then 5 more times\n    When I send the key sequence \"M-5 C-d C-x z\"\n    Then the buffer's contents should be \"klmnopqrstuvwxyz one two three\"\n\n  Scenario: 5dx z does delete 5 times then 5 more times\n    When I send the key sequence \"5dx SPC z\"\n    Then the buffer's contents should be \"klmnopqrstuvwxyz one two three\"\n\n  Scenario: M-f C-x z M-d deletes the second word\n    When I send the key sequence \"M-f C-x z M-d\"\n    Then the buffer's contents should be \"abcdefghijklmnopqrstuvwxyz one three\"\n\n  Scenario: gfx zgd deletes the second word\n    When I send the key sequence \"gfx SPC zgd\"\n    Then the buffer's contents should be \"abcdefghijklmnopqrstuvwxyz one three\"\n"
  },
  {
    "path": "features/step-definitions/god-mode-steps.el",
    "content": ";; This file contains your project specific step definitions. All\n;; files in this directory whose names end with \"-steps.el\" will be\n;; loaded automatically by Ecukes.\n\n(require 'seq)\n\n(Given \"^I bind a named keyboard macro which kills line to C-c C-r$\"\n       (lambda ()\n         (fset 'god-mode-test-keyboard-macro\n               \"\\C-a\\C-k\\C-k\")\n         (global-set-key (kbd \"C-c C-r\") 'god-mode-test-keyboard-macro)))\n\n(Given \"^I bind \\\"\\\\([^\\\"]+\\\\)\\\" to \\\"\\\\([^\\\"]+\\\\)\\\"\"\n       (lambda (key cmd)\n         (local-set-key (kbd key) (intern cmd))))\n\n(Given \"^god-mode is enabled for all buffers$\"\n       (lambda ()\n         (when (not god-global-mode)\n           (god-mode))))\n\n(Given \"^I describe function \\\"\\\\(.+\\\\)\\\"$\"\n       (lambda (fn)\n         (describe-function (intern fn))))\n\n(Given \"^I grep current directory\"\n       (lambda ()\n         (set-process-query-on-exit-flag\n          (get-buffer-process (grep \"grep -Rin god .\"))\n          nil)))\n\n(Given \"^I open a view-mode buffer\"\n       (lambda ()\n         (set-buffer (get-buffer-create \"*view-mode-buffer*\"))\n         (view-mode)\n         (god-local-mode 0)\n         (god-mode-maybe-activate)))\n\n(Given \"^I open a test-special-mode buffer\"\n       (lambda ()\n         (set-buffer (get-buffer-create \"*test-special-mode*\"))\n         (test-special-mode)))\n\n(Given \"^I start ielm$\"\n       (lambda ()\n         (require 'ielm)\n         (ielm)))\n\n(When \"I send the key sequence \\\"\\\\(.+\\\\)\\\"\"\n      (lambda (keys)\n        (execute-kbd-macro (kbd keys))))\n\n(Then \"^god-mode is enabled$\"\n      (lambda ()\n        (cl-assert (not (null god-local-mode)))))\n\n(Then \"^god-mode is disabled$\"\n      (lambda ()\n        (cl-assert (null god-local-mode))))\n\n(Then \"^I have god-mode on$\"\n      \"Turn god-mode on.\"\n      (lambda ()\n        (god-local-mode 1)))\n\n(Then \"^I am in insertion mode$\"\n      \"Turn god-mode off.\"\n      (lambda ()\n        (god-local-mode -1)))\n\n(Then \"^there is a \\\"\\\\([^\\\"]+\\\\)\\\" buffer$\"\n      (lambda (name)\n        (cl-assert\n         (seq-filter (lambda (b) (string-prefix-p name (buffer-name b)))\n                     (buffer-list)))))\n\n(Then \"^the buffer's contents should be\\\\(?: \\\"\\\\(.+\\\\)\\\"\\\\|:\\\\)$\"\n      \"Asserts that the current buffer includes some text.\n\nExamples:\n - Then the buffer's contents should be  \\\"CONTENTS\\\"\n - Then the buffer's contents should be:\n     \\\"\\\"\\\"\n     CONTENTS\n     \\\"\\\"\\\"\"\n      (lambda (expected)\n        (let ((actual (buffer-string))\n              (message \"Expected buffer's contents to be '%s', but was '%s'\"))\n          (cl-assert (s-equals? expected actual) nil message expected actual))))\n\n(Then \"^the buffer's contents should contain\\\\(?: \\\"\\\\(.+\\\\)\\\"\\\\|:\\\\)$\"\n      \"Asserts that the current buffer contains some text.\n\nExamples:\n - Then the buffer's contents should contain  \\\"CONTENTS\\\"\n - Then the buffer's contents should contain:\n     \\\"\\\"\\\"\n     CONTENTS\n     \\\"\\\"\\\"\"\n      (lambda (expected)\n        (let ((actual (buffer-string))\n              (message \"Expected buffer's contents to contain '%s', but was '%s'\"))\n          (cl-assert (s-contains? expected actual) nil message expected actual))))\n"
  },
  {
    "path": "features/support/env.el",
    "content": "(require 'f)\n(require 'cl-lib)\n\n(defvar god-mode-support-path\n  (f-dirname load-file-name))\n\n(defvar god-mode-features-path\n  (f-parent god-mode-support-path))\n\n(defvar god-mode-root-path\n  (f-parent god-mode-features-path))\n\n(add-to-list 'load-path god-mode-root-path)\n\n(define-derived-mode test-special-mode fundamental-mode \"Test\"\n  \"This mode is marked special via its mode class rather than\nthrough inheritance.\")\n\n(put 'test-special-mode 'mode-class 'special)\n\n(require 'god-mode)\n(require 'espuds)\n\n(Setup\n ;; Before anything has run\n )\n\n(Before\n ;; Before each scenario is run\n )\n\n(After\n ;; After each scenario is run\n )\n\n(Teardown\n ;; After when everything has been run\n )\n"
  },
  {
    "path": "god-mode-isearch.el",
    "content": ";;; god-mode-isearch.el --- God mode behaviour for isearch  -*- lexical-binding: t; -*-\n\n;; Copyright (C) 2014 Chris Done\n;; Copyright (C) 2020 Akhil Wali\n\n;; Author: Chris Done <chrisdone@gmail.com>\n;; URL: https://github.com/emacsorphanage/god-mode\n;; Version: 2.19.0\n;; Package-Requires: ((emacs \"26.3\"))\n\n;; This file is free software; you can redistribute it and/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation; either version 3, or (at your option)\n;; any later version.\n\n;; This file is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n;; GNU General Public License for more details.\n\n;; You should have received a copy of the GNU General Public License\n;; along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\n;;; Commentary:\n\n;; Global minor mode for entering Emacs commands without modifier keys.\n\n;;; Code:\n\n;; Recommended use:\n\n;; (define-key isearch-mode-map (kbd \"<escape>\") 'god-mode-isearch-activate)\n;; (define-key god-mode-isearch-map (kbd \"<escape>\") 'god-mode-isearch-disable)\n\n(defvar god-mode-isearch-map\n  (let ((map (copy-keymap isearch-mode-map)))\n    (define-key map (kbd \"s\") 'isearch-repeat-forward)\n    (define-key map (kbd \"r\") 'isearch-repeat-backward)\n    (define-key map (kbd \"w\") 'isearch-yank-word-or-char)\n    map)\n  \"Keymap for modal isearch.\")\n\n(defun god-mode-isearch-activate ()\n  \"Activate God mode in the isearch buffer.\"\n  (interactive)\n  (setq overriding-terminal-local-map god-mode-isearch-map))\n\n(defun god-mode-isearch-disable ()\n  \"Deactivate God mode in the isearch buffer.\"\n  (interactive)\n  (setq overriding-terminal-local-map isearch-mode-map))\n\n(provide 'god-mode-isearch)\n\n;;; god-mode-isearch.el ends here\n"
  },
  {
    "path": "god-mode.el",
    "content": ";;; god-mode.el --- Minor mode for God-like command entering  -*- lexical-binding: t; -*-\n\n;; Copyright (C) 2013 Chris Done\n;; Copyright (C) 2013 Magnar Sveen\n;; Copyright (C) 2013 Rüdiger Sonderfeld\n;; Copyright (C) 2013 Dillon Kearns\n;; Copyright (C) 2013 Fabián Ezequiel Gallina\n;; Copyright (C) 2020 Akhil Wali\n\n;; Author: Chris Done <chrisdone@gmail.com>\n;; URL: https://github.com/emacsorphanage/god-mode\n;; Version: 2.19.0\n;; Package-Requires: ((emacs \"26.3\"))\n\n;; This file is not part of GNU Emacs.\n\n;; This file is free software; you can redistribute it and/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation; either version 3, or (at your option)\n;; any later version.\n\n;; This file is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n;; GNU General Public License for more details.\n\n;; You should have received a copy of the GNU General Public License\n;; along with GNU Emacs; see the file COPYING.  If not, write to\n;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,\n;; Boston, MA 02110-1301, USA.\n\n;;; Commentary:\n\n;; Global minor mode for entering Emacs commands without modifier keys.\n\n;;; Code:\n\n(require 'cl-lib)\n\n(add-hook 'after-change-major-mode-hook 'god-mode-maybe-activate)\n\n(defvar god-local-mode-paused nil)\n(make-variable-buffer-local 'god-local-mode-paused)\n\n;; DEPRECATED\n(defvaralias 'god-mod-alist 'god-mode-alist\n  \"Alias of `god-mode-alist' for backward compatibility.\nUse `god-mode-alist' instead.\")\n(make-obsolete 'god-mod-alist 'god-mode-alist \"2.16.1\")\n\n(defcustom god-mode-alist\n  '((nil . \"C-\")\n    (\"g\" . \"M-\")\n    (\"G\" . \"C-M-\"))\n  \"List of keys and their associated modifer.\"\n  :group 'god\n  :type '(alist))\n\n(defcustom god-literal-key\n  \"SPC\"\n  \"The key used for literal interpretation.\"\n  :group 'god\n  :type 'string)\n\n(defcustom god-exempt-major-modes\n  '(Custom-mode\n    Info-mode\n    ag-mode\n    calculator-mode\n    calendar-mode\n    cider-test-report-mode\n    compilation-mode\n    debugger-mode\n    dired-mode\n    edebug-mode\n    ediff-mode\n    eww-mode\n    geben-breakpoint-list-mode\n    git-commit-mode                     ; For versions prior to Magit 2.1.0\n    grep-mode\n    ibuffer-mode\n    magit-popup-mode\n    org-agenda-mode\n    pdf-outline-buffer-mode\n    recentf-dialog-mode\n    sldb-mode\n    sly-db-mode\n    vc-annotate-mode\n    wdired-mode)\n  \"List of major modes that should not start with `god-local-mode' enabled.\"\n  :group 'god\n  :type '(repeat symbol))\n\n(defcustom god-exempt-predicates\n  (list #'god-exempt-mode-p\n        #'god-comint-mode-p\n        #'god-git-commit-mode-p\n        #'god-view-mode-p\n        #'god-special-mode-p)\n  \"List of predicates checked before enabling `god-local-mode'.\nAll predicates must return nil for `god-local-mode' to start.\"\n  :group 'god\n  :type '(repeat function))\n\n(defcustom god-mode-enable-function-key-translation t\n  \"Enables translation of function keys to use modifier keys.\nFor example, if this variable is non-nil, then entering `<f5>'\nin God mode will be translated to `C-<f5>'.\"\n  :group 'god\n  :type 'boolean)\n\n(defcustom god-mode-lighter-string\n  \"God\"\n  \"String displayed on the mode line when God mode is active.\nSet it to nil if you don't want a mode line indicator.\"\n  :group 'god\n  :type '(choice string (const :tag \"None\" nil)))\n\n(defface god-mode-lighter\n  '((t))\n  \"Face for God mode's lighter.\"\n  :group 'god)\n\n(defun god-mode-make-f-key (n &optional shift)\n  \"Get the event for numbered function key N, with shift status SHIFT.\nFor example, calling with arguments 5 and t yields the symbol `S-f5'.\"\n  (intern (format \"%sf%d\" (if shift \"S-\" \"\") n)))\n\n(defvar god-local-mode-map\n  (let ((map (make-sparse-keymap)))\n    (suppress-keymap map t)\n    (define-key map [remap self-insert-command] 'god-mode-self-insert)\n    (let ((i ?\\s))\n      (while (< i 256)\n        (define-key map (vector i) 'god-mode-self-insert)\n        (setq i (1+ i))))\n    (when god-mode-enable-function-key-translation\n      (dotimes (i 35)\n        (define-key map (vector (god-mode-make-f-key (1+ i))) 'god-mode-self-insert)\n        (define-key map (vector (god-mode-make-f-key (1+ i) t)) 'god-mode-self-insert)))\n    (define-key map (kbd \"DEL\") nil)\n    (define-key map (kbd \"C-h k\") #'god-mode-describe-key)\n    map))\n\n;;;###autoload\n(define-minor-mode god-local-mode\n  \"Minor mode for running commands.\"\n  :init-value nil\n  :lighter (god-mode-lighter-string\n            ((\" \"\n             (:propertize god-mode-lighter-string face god-mode-lighter))))\n  :keymap god-local-mode-map\n  (if god-local-mode\n      (run-hooks 'god-mode-enabled-hook)\n    (run-hooks 'god-mode-disabled-hook)))\n\n(defun god-local-mode-pause ()\n  \"Pause `god-local-mode' if it is enabled.\nSee also `god-local-mode-resume'.\"\n  (when god-local-mode\n    (god-local-mode -1)\n    (setq god-local-mode-paused t)))\n\n(defun god-local-mode-resume ()\n  \"Re-enable `god-local-mode'.\nIf it was not active when `god-local-mode-pause' was called, nothing happens.\"\n  (when (bound-and-true-p god-local-mode-paused)\n    (setq god-local-mode-paused nil)\n    (god-local-mode 1)))\n\n(defvar god-global-mode nil\n  \"Enable `god-local-mode' on all buffers.\")\n\n(defvar god-literal-sequence nil\n  \"Toggled when `god-literal-key' is pressed in a command sequence.\")\n\n;;;###autoload\n(defun god-mode ()\n  \"Toggle global `god-local-mode'.\"\n  (interactive)\n  (setq god-global-mode (not god-global-mode))\n  (if god-global-mode\n      (god-local-mode 1)\n    (god-local-mode -1)))\n\n;;;###autoload\n(defun god-mode-all (&optional arg)\n  \"Toggle `god-local-mode' in all buffers.\n\nToggle the mode if ARG is nil. If ARG is non-nil, enable the mode\nif ARG is zero or a positive number, or disable the mode if ARG\nis a negative number.\"\n  (interactive)\n  (let ((new-status\n\t (cond\n\t  ((null arg) (if (bound-and-true-p god-local-mode) -1 1))\n\t  ((> 0 arg) -1)\n\t  (t 1))))\n    (setq god-global-mode t)\n    (mapc (lambda (buffer)\n            (with-current-buffer buffer\n              (god-mode-activate new-status)))\n          (buffer-list))\n    (setq god-global-mode (= new-status 1))))\n\n(defun god-mode-maybe-universal-argument-more ()\n  \"If `god-local-mode' is enabled, call `universal-argument-more'.\"\n  (interactive)\n  (if god-local-mode\n      (call-interactively #'universal-argument-more)\n    (let ((binding (god-mode-lookup-command \"u\")))\n      (if (commandp binding t)\n          (call-interactively binding)\n        (execute-kbd-macro binding)))))\n\n(define-key universal-argument-map (kbd \"u\")\n  #'god-mode-maybe-universal-argument-more)\n\n(defun god-mode-self-insert ()\n  \"Handle self-insert keys.\"\n  (interactive)\n  (let* ((initial-key (aref (this-command-keys-vector)\n                            (- (length (this-command-keys-vector)) 1)))\n         (binding (god-mode-lookup-key-sequence initial-key)))\n    (when binding\n      ;; For now, set the shift-translation status only for alphabetic keys.\n      (when (god-mode-upper-p initial-key)\n        (setq this-command-keys-shift-translated t))\n      (setq this-original-command binding)\n      (setq this-command binding)\n      ;; `real-this-command' is used by emacs to populate\n      ;; `last-repeatable-command', which is used by `repeat'.\n      (setq real-this-command binding)\n      (setq god-literal-sequence nil)\n      (if (commandp binding t)\n          (call-interactively binding)\n        (execute-kbd-macro binding)))))\n\n(defun god-mode-upper-p (key)\n  \"Check if KEY is an upper case character not present in `god-mode-alist'.\"\n  (and (characterp key)\n       (not (member (char-to-string key) (mapcar #'car god-mode-alist)))\n       (>= key ?A)\n       (<= key ?Z)))\n\n(defun god-mode-lookup-key-sequence (&optional key key-string-so-far)\n  \"Lookup the command for the given KEY (or the next keypress, if KEY is nil).\nThis function sometimes recurses.\nKEY-STRING-SO-FAR should be nil for the first call in the sequence.\"\n  (interactive)\n  (let ((sanitized-key\n         (god-mode-sanitized-key-string\n          (or key (read-event key-string-so-far)))))\n    (god-mode-lookup-command\n     (god-key-string-after-consuming-key sanitized-key key-string-so-far))))\n\n(defvar god-mode-sanitized-key-alist\n  (append\n   '((tab . \"TAB\")\n     (?\\  . \"SPC\")\n     (left . \"<left>\")\n     (right . \"<right>\")\n     (up . \"<up>\")\n     (down . \"<down>\")\n     (prior . \"<prior>\")\n     (next . \"<next>\")\n     (backspace . \"DEL\")\n     ;; FIXME delete key is not picked up `god-mode-self-insert'.\n     (delete . \"<delete>\")\n     (return . \"RET\")\n     (S-iso-lefttab . \"<S-iso-lefttab>\")\n     ;; Use key code for S-SPC\n     (33554464 . \"S-SPC\")\n     (S-left . \"S-<left>\")\n     (S-right . \"S-<right>\")\n     (S-up . \"S-<up>\")\n     (S-down . \"S-<down>\")\n     (S-backspace . \"<S-backspace>\")\n     (S-delete . \"<S-delete>\")\n     (S-return . \"<S-return>\"))\n   ;; f1..f35 and S-f1..S-f35\n   (cl-mapcan (lambda (i)\n                (list (cons (god-mode-make-f-key i)   (format \"<f%d>\" i))\n                      (cons (god-mode-make-f-key i t) (format \"S-<f%d>\" i))))\n              (number-sequence 1 35)))\n  \"Association list mapping special events to their textual representations.\")\n\n(defun god-mode-sanitized-key-string (key)\n  \"Convert any special events in KEY to textual representation.\"\n  (or (cdr (assq key god-mode-sanitized-key-alist))\n      (char-to-string key)))\n\n(defun god-mode-help-char-dispatch (_help-key key-string-so-far)\n  \"Invokes `prefix-help-command' by entering the key sequence KEY-STRING-SO-FAR\nfollowed by the `help-char' key.\nHELP-KEY contains the key that caused `god-mode-help-char-dispatch' to be called\nfrom the command loop.\"\n  ;; Adding an element (t . key) to `unread-command-events' will add key to\n  ;; the current command's key sequence.\n  (setq unread-command-events\n        (cl-loop for key in (append (read-kbd-macro key-string-so-far t)\n                                    (list help-char))\n                 collect (cons t key)))\n  ;; Return nil so that `god-mode-lookup-command' doesn't perform any action.\n  nil)\n\n(defun god-key-string-after-consuming-key (key key-string-so-far)\n  \"Interpret god-mode special keys for KEY.\nConsumes more keys if appropriate.\nAppends to key sequence KEY-STRING-SO-FAR.\"\n  (let ((modifier \"\")\n        (next-key (lambda () (god-mode-sanitized-key-string (read-event key-string-so-far)))))\n    (message key-string-so-far)\n    (when key-string-so-far ; Don't check for `god-literal-key' with the first key.\n      (while (string= key god-literal-key)\n        (setq god-literal-sequence (not god-literal-sequence)\n              key (funcall next-key))))\n    (unless god-literal-sequence\n      (let ((modifier-lookup (and (stringp key) (assoc key god-mode-alist))))\n        (if modifier-lookup\n            (setq modifier (cdr modifier-lookup)\n                  key (funcall next-key))\n          (setq modifier (cdr (assoc nil god-mode-alist))))))\n    (if (and key-string-so-far (string= key (format \"%c\" help-char)))\n        (god-mode-help-char-dispatch key key-string-so-far)\n      (when (and (= (length key) 1)\n                 (string= (get-char-code-property (aref key 0) 'general-category) \"Lu\")\n                 ;; If C- is part of the modifier, S- needs to be given\n                 ;; in order to distinguish the uppercase from the\n                 ;; lowercase bindings. If C- is not in the modifier,\n                 ;; then emacs natively treats uppercase differently\n                 ;; from lowercase, and the S- modifier should not be\n                 ;; supplied.\n                 (string-prefix-p \"C-\" modifier))\n        (setq modifier (concat modifier \"S-\")))\n      (if key-string-so-far\n          (concat key-string-so-far \" \" modifier key)\n        (concat modifier key)))))\n\n(defun god-mode-lookup-command (key-string)\n  \"Look up and return the command for KEY-STRING.\nTries fallback for the last key by removing Control modifier. If no command is found,\nreturns a keymap to allow further key input, or nil if completely unbound.\"\n  (when key-string\n    (let* ((key-vector (read-kbd-macro key-string t))\n           (binding (key-binding key-vector)))\n      (cond\n       ;; Case 1: found an actual command\n       ((commandp binding)\n        (setq last-command-event (aref key-vector (1- (length key-vector))))\n        binding)\n\n       ;; Case 2: it's a keymap (partial key sequence)\n       ((keymapp binding)\n        (god-mode-lookup-key-sequence nil key-string))\n\n       ;; Case 3: try fallback by removing C- from the last key\n       ((string-match \"\\\\(.*\\\\) C-\\\\(.\\\\)$\" key-string)\n        (let* ((prefix (match-string 1 key-string))\n               (last (match-string 2 key-string))\n               (key-str (format \"%s %s\" prefix last))\n               (fallback-key (if (>= emacs-major-version 28)\n                                 (string-trim-right key-str)\n                               (replace-regexp-in-string\n                                \"[ \\t\\n\\r]+$\" \"\" ;; Remove trailing whitespace\n                                key-str)))\n               (fallback-vector (read-kbd-macro fallback-key t))\n               (fallback-binding (key-binding fallback-vector)))\n          (cond\n           ((commandp fallback-binding)\n            (message \"Using fallback command: %s\" fallback-key)\n            (setq last-command-event (aref fallback-vector (1- (length fallback-vector))))\n            fallback-binding)\n\n           ((keymapp fallback-binding)\n            (message \"Using fallback keymap: %s\" fallback-key)\n            (god-mode-lookup-key-sequence nil fallback-key))\n\n           ;; Not a command nor a map — wait for more input, don't fail\n           )))))))\n\n;;;###autoload\n(defun god-mode-maybe-activate (&optional status)\n  \"Activate `god-local-mode' on individual buffers when appropriate.\nSTATUS is passed as an argument to `god-mode-activate'.\"\n  (when (not (minibufferp))\n    (god-mode-activate status)))\n\n(defun god-mode-activate (&optional status)\n  \"Activate `god-local-mode' on individual buffers when appropriate.\nSTATUS is passed as an argument to `god-local-mode'.\"\n  (when (and god-global-mode\n             (god-passes-predicates-p))\n    (god-local-mode (if status status 1))))\n\n(defun god-exempt-mode-p ()\n  \"Return non-nil if `major-mode' is exempt.\nMembers of the `god-exempt-major-modes' list are exempt.\"\n  (memq major-mode god-exempt-major-modes))\n\n(defun god-mode-child-of-p (mode parent-mode)\n  \"Return non-nil if MODE is derived from PARENT-MODE.\"\n  (let ((parent (get mode 'derived-mode-parent)))\n    (cond ((eq parent parent-mode))\n          ((not (null parent))\n           (god-mode-child-of-p parent parent-mode))\n          (t nil))))\n\n(defun god-comint-mode-p ()\n  \"Return non-nil if `major-mode' is derived from `comint-mode'.\"\n  (god-mode-child-of-p major-mode 'comint-mode))\n\n(defun god-special-mode-p ()\n  \"Return non-nil if `major-mode' is special or derived from `special-mode'.\"\n  (eq (get major-mode 'mode-class) 'special))\n\n(defun god-view-mode-p ()\n  \"Return non-nil if variable `view-mode' is non-nil in current buffer.\"\n  view-mode)\n\n(defun god-git-commit-mode-p ()\n  \"Return non-nil if a `git-commit-mode' will be enabled in this buffer.\"\n  (and (bound-and-true-p global-git-commit-mode)\n       ;; `git-commit-filename-regexp' defined in the same library as\n       ;; `global-git-commit-mode'.  Expression above maybe evaluated\n       ;; to true because of autoload cookie.  So we perform\n       ;; additional check.\n       (boundp 'git-commit-filename-regexp)\n       buffer-file-name\n       (string-match-p git-commit-filename-regexp buffer-file-name)))\n\n(defun god-passes-predicates-p ()\n  \"Return non-nil if all `god-exempt-predicates' return nil.\"\n  (not\n   (catch 'disable\n     (let ((preds god-exempt-predicates))\n       (while preds\n         (when (funcall (car preds))\n           (throw 'disable t))\n         (setq preds (cdr preds)))))))\n\n;;;###autoload\n(defun god-execute-with-current-bindings (&optional called-interactively)\n  \"Execute a single command from God mode, preserving current keybindings.\n\nThis command activates God mode temporarily, and deactivates God\nmode as soon as the next command is run.  Prefix arguments do not\ncount as commands for this purpose, and do not cause God mode to\nexit.  Moreover, any prefix argument that exists at the time of\nthis command's invocation is passed along to the next command.\n\nUnlike normal use of God mode, this command makes available all\nkeybindings that were active at the time of its invocation,\nincluding keybindings that are normally invisible to God mode,\nsuch as those in `emulation-mode-map-alists' or text overlay\nproperties.  This makes it suitable for use with packages like\nEvil that utilize such higher-priority keymaps.  (See Info\nnode `(elisp)Active Keymaps' for technical details on keymap\nprecedence.  For an alternative to this command, check out the\nevil-god-state package, available on MELPA.)\n\nThis command has no effect when called from within God mode.\n\nFor interactive use only.  CALLED-INTERACTIVELY is a dummy\nparameter to help enforce this restriction.\"\n  (interactive \"d\")\n  (if called-interactively\n      (unless god-local-mode\n        (message \"Switched to God mode for the next command ...\")\n        (letrec ((caller this-command)\n                 (buffer (current-buffer))\n                 (cleanup\n                  (lambda ()\n                    ;; Perform cleanup in original buffer even if the command\n                    ;; switched buffers.\n                    (if (buffer-live-p buffer)\n                        (with-current-buffer buffer\n                          (unwind-protect (god-local-mode 0)\n                            (remove-hook 'post-command-hook post-hook)))\n                      (remove-hook 'post-command-hook post-hook))))\n                 (kill-transient-map\n                  (set-transient-map\n                   god-local-mode-map 'god-prefix-command-p cleanup))\n                 (post-hook\n                  (lambda ()\n                    (unless (and\n                             (eq this-command caller)\n                             ;; If we've entered the minibuffer, this implies\n                             ;; a non-prefix command was run, even if\n                             ;; `this-command' has not changed.  For example,\n                             ;; `execute-extended-command' behaves this way.\n                             (not (window-minibuffer-p)))\n                      (funcall kill-transient-map)))))\n          (add-hook 'post-command-hook post-hook)\n          ;; Pass the current prefix argument along to the next command.\n          (setq prefix-arg current-prefix-arg)\n          ;; Technically we don't need to activate God mode since the\n          ;; transient keymap is already in place, but it's useful to provide\n          ;; a mode line lighter and run any hook functions the user has set\n          ;; up.  This could be made configurable in the future.\n          (god-local-mode 1)))\n    (error \"This function should only be called interactively\")))\n\n(defun god-prefix-command-p ()\n  \"Return non-nil if the current command is a \\\"prefix\\\" command.\nThis includes prefix arguments and any other command that should\nbe ignored by `god-execute-with-current-bindings'.\"\n  (memq this-command '(god-mode-self-insert\n                       digit-argument\n                       negative-argument\n                       universal-argument\n                       universal-argument-more)))\n\n\n(defvar god-latest-described-command nil\n  \"The latest command recorded by `god-mode-describe-key'.\")\n\n(defun god-mode--help-fn-describe-function (_arg)\n  \"Insert information about `god-mode' key-bindings for the described function.\nThe argument _ARG is ignored: it's only needed because all hooks in\n`help-fns-describe-function-functions' take the function-name as argument.\nBut in our case it's redundant\"\n  (insert\n   (format-message \"\\n  %s\\n  %s%s\\n  %s%s%s\\n\\n\"\n                   \"(`god-local-mode' is enabled. \"\n                   \" The given key-sequence: \"\n                   (god-mode-get-described-key-seq)\n                   \" corresponds to this key-binding: \"\n                   (if (> emacs-major-version 27)\n                       (help--key-description-fontified\n                        god-latest-described-command)\n                     god-latest-described-command)\n                   \")\")))\n\n(defun god-mode-get-described-key-seq ()\n  \"Return the keys that were pressed after `god-mode-describe-key' was called.\"\n  (let* ((latest-keys (recent-keys 'include-cmds))\n         (latest-describe-key-index\n          (cl-position '(nil . god-mode-self-insert)\n                       latest-keys :from-end t :test #'equal))\n         (start-index (+ 3 latest-describe-key-index))\n         (key-sequence (key-description (seq-subseq latest-keys start-index))))\n    (if (> emacs-major-version 27)\n        (propertize key-sequence\n                    'font-lock-face 'help-key-binding\n                    'face 'help-key-binding)\n      key-sequence)))\n\n(defun god-mode-describe-key ()\n  \"Describe a key-sequence as interpreted by `god-mode'.\nPrompt for a key sequence, use `god-mode-lookup-key-sequence' to translate it\ninto the appropriate command, and use `describe-function' to describe it\"\n  (interactive)\n  (message \"Describe the following god-mode key: \")\n  (advice-add #'god-mode-lookup-command :filter-args\n              (lambda (key-string)\n                (setq god-latest-described-command key-string)))\n  ;; use unwind-protect, and remove the advice / hook in the unwind forms\n  (unwind-protect\n      (let ((command\n             ;; if the key is not recognized by god-mode,\n             ;; we will pass it to the regular `describe-key'\n             (condition-case err\n                 (god-mode-lookup-key-sequence)\n               (wrong-type-argument\n                ;; due to how errors are passed,\n                ;; we do not have enough information\n                ;; to pass menu items\n                (if (not (equal (cddr err) '((menu-bar))))\n                    (describe-key (vector (caddr err))))))))\n        (if command\n            (progn\n              (add-hook 'help-fns-describe-function-functions\n                        #'god-mode--help-fn-describe-function)\n              (describe-function command))))\n    ;; unwind forms:\n    (advice-remove #'god-mode-lookup-command\n                   (lambda (key-string)\n                     (setq god-latest-described-command key-string)))\n    (remove-hook 'help-fns-describe-function-functions\n                 #'god-mode--help-fn-describe-function)))\n\n(provide 'god-mode)\n\n;;; god-mode.el ends here\n"
  }
]