Giter Site home page Giter Site logo

god-mode's Introduction

God Mode — no more RSI

melpa-badge melpa-stable-badge gh-actions-badge

NOTE: Emacs 25.1 is required for this package to work well.

This is a global minor mode for entering Emacs commands without modifier keys. It's similar to Vim's separation of command mode and insert mode.

All existing key bindings will work in God mode. It's only there to reduce your usage of modifier keys.

Example

In the example below, you can see how much effort is reduced:

Before: 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
After:    p   k   n g ^ )   j   y g r     . .   2 g f   x   s

(Regarding ., see the useful key bindings section.)

You'll find this mode surprisingly natural, as you would already know how to use your existing Emacs commands. Whenever you feel like it, you can explicitly use modifier keys too.

See the key mapping section for a complete walk-through of key translations.

Setup

You can load and activate God mode as follows:

(require 'god-mode)
(god-mode)

This will activate God mode in all future buffers. However, activation of God mode itself is buffer-local.

God mode can be toggled through god-local-mode using the escape key (ESC) as follows:

(global-set-key (kbd "<escape>") #'god-local-mode)

If you want to toggle God mode on all active and future buffers, use god-mode-all as follows:

(global-set-key (kbd "<escape>") #'god-mode-all)

If God mode is activated through god-mode or god-mode-all, you might want to ensure that no buffers are skipped, as follows:

(setq god-exempt-major-modes nil)
(setq god-exempt-predicates nil)

This means that magit-mode or dired-mode, for example, will also enter God mode when you activate it in all buffers. This means you can always reliably use God mode commands in any buffer.

When God mode is enabled, entering function keys will be translated to use appropriate key modifiers. For example, entering <f5> is translated to C-<f5>. To disable this translation, you can set the god-mode-enable-function-key-translation variable to nil before loading God mode, as follows:

(setq god-mode-enable-function-key-translation nil)
(require 'god-mode)

Also, you can add this to your .xmodmap to rebind the caps lock key to the escape key:

remove Lock = Caps_Lock
keysym Caps_Lock = Escape

And run xmodmap .xmodmap for the changes to take effect immediately.

Or use dconf:

dconf write /org/gnome/desktop/input-sources/xkb-options "['caps:escape']"

See this link for more details.

Key mapping

This package defines the following key mappings:

  • All commands are assumed to use the control modifier (C-) unless otherwise indicated. Here are some examples:

    • x → C-x
    • f → C-f
    • x s → C-x C-s
    • x SPC s → C-x s

    Note the use of the space key (SPC) to produce C-x s.

  • The literal key (SPC) is sticky. This means you don't have to enter SPC repeatedly for key bindings such as C-x r t. The literal key can be changed through god-literal-key. Here are some examples:

    • x SPC r t → C-x r t
    • x SPC r y → C-x r y
  • g is used to indicate the meta modifier (M-). This means that there is no way to enter C-g in God mode, and you must therefore type in C-g directly. This key can be changed through god-mode-alist. Here are some examples:

    • g x → M-x
    • g f → M-f
  • G is used to indicate both the control and meta modifiers (C-M-). This key can also be changed through god-mode-alist. Here are some examples:

    • G x → C-M-x
    • G f → C-M-f
  • Digit arguments can also be used:

    • 1 2 f → M-12 C-f
  • If you use some of the useful key bindings, z or . can repeat the previous command:

    • g f . . → M-f M-f M-f
  • Universal arguments can also be specified using u:

    • u c o → C-u C-c C-o

Lookup a key sequence

You 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.

By default, god-mode-describe-key is bound to C-h k in god-local-mode-map.

Note 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.

Visual indicators for God mode

God mode allows you to customize its minor mode lighter by customizing the god-mode-lighter-string variable and the god-mode-lighter face. For example, if you don't want any lighter, you can set the string to nil. On the other hand, if you want the lighter to stand out, you can change the face, e.g. by making it inherit from error. You can do this using M-x customize-face RET god-mode-lighter or as follows:

(custom-set-faces
 '(god-mode-lighter ((t (:inherit error)))))

Additionally, you can change the cursor style to visually indicate whether God mode is active as follows:

(defun my-god-mode-update-cursor-type ()
  (setq cursor-type (if (or god-local-mode buffer-read-only) 'box 'bar)))

(add-hook 'post-command-hook #'my-god-mode-update-cursor-type)

You can also change the foreground and background of the mode line to indicate whether God mode is active as follows:

(defun my-god-mode-update-mode-line ()
  (cond
   (god-local-mode
    (set-face-attribute 'mode-line nil
                        :foreground "#604000"
                        :background "#fff29a")
    (set-face-attribute 'mode-line-inactive nil
                        :foreground "#3f3000"
                        :background "#fff3da"))
   (t
    (set-face-attribute 'mode-line nil
			:foreground "#0a0a0a"
			:background "#d7d7d7")
    (set-face-attribute 'mode-line-inactive nil
			:foreground "#404148"
			:background "#efefef"))))

(add-hook 'post-command-hook #'my-god-mode-update-mode-line)

Note that using post-command-hook here should not be an issue for performance. If you are concerned about performance for any reason, you can use god-mode-enabled-hook and god-mode-disabled-hook. With Emacs 27.1+, you can also use window hooks.

overwrite-mode

You can pause or resume God mode depending on whether overwrite-mode is activated as follows:

(defun my-god-mode-toggle-on-overwrite ()
  "Toggle god-mode on overwrite-mode."
  (if (bound-and-true-p overwrite-mode)
      (god-local-mode-pause)
    (god-local-mode-resume)))

(add-hook 'overwrite-mode-hook #'my-god-mode-toggle-on-overwrite)

isearch integration

There is an optional feature for providing God mode behaviour in isearch. It allows you to hit ESC, for example, while in isearch to enable God mode. Here's a more complete example:

s h e y ESC s s s RET → C-s h e y C-s C-s C-s RET

You can load and activate this feature as follows:

(require 'god-mode-isearch)
(define-key isearch-mode-map (kbd "<escape>") #'god-mode-isearch-activate)
(define-key god-mode-isearch-map (kbd "<escape>") #'god-mode-isearch-disable)

You can also configure god-mode-isearch-map for additional keybindings.

Rebinding self-insert-command

You can rebind self-insert-command as you prefer. For example, here's a mapping that calls org-self-insert-command in org-mode:

(defun my-god-mode-self-insert ()
  (interactive)
  (if (and (bolp)
           (eq major-mode 'org-mode))
      (call-interactively 'org-self-insert-command)
    (call-interactively 'god-mode-self-insert)))

(define-key god-local-mode-map [remap self-insert-command] #'my-god-mode-self-insert)

Useful key bindings

The following key bindings are popular:

(define-key god-local-mode-map (kbd "z") #'repeat)
(define-key god-local-mode-map (kbd "i") #'god-local-mode)

Although I personally prefer:

(define-key god-local-mode-map (kbd ".") #'repeat)

These are also handy:

(global-set-key (kbd "C-x C-1") #'delete-other-windows)
(global-set-key (kbd "C-x C-2") #'split-window-below)
(global-set-key (kbd "C-x C-3") #'split-window-right)
(global-set-key (kbd "C-x C-0") #'delete-window)

(define-key god-local-mode-map (kbd "[") #'backward-paragraph)
(define-key god-local-mode-map (kbd "]") #'forward-paragraph)

So that you can run x 1, x 2, x 3, and x 0 in God mode.

Exempt major modes

NOTE: This is less necessary in recent versions of God mode, as it overrides all printable single byte keys and bindings in most major modes.

Sometimes, God mode is enabled in buffers where it makes no sense. In such cases, you can add the major mode to god-exempt-major-modes:

(add-to-list 'god-exempt-major-modes 'dired-mode)

Since dired-mode is already in the list, that's a no-op, but you get the idea. Consider opening an issue or pull request if you find a major mode that should be on the official list.

Another option to control the behavior of God mode in new buffers is to provide a function with no arguments that must return non-nil if God mode should be disabled in the current buffer. See the god-exempt-predicates variable and its default members god-exempt-mode-p, god-comint-mode-p, god-view-mode-p and god-special-mode-p for further details.

Usage with Evil

Evil is a popular Emacs package that provides modal editing in the style of Vi. While Evil doesn't always work well with God mode, there are a few simple customizations that enable them to be used together smoothly.

  • For running occasional and single commands in God mode, the built-in god-execute-with-current-bindings command works well with Evil without additional customization. This is quite similar to Evil's evil-execute-in-emacs-state command. All Evil bindings remain available when using god-execute-with-current-bindings. For example, executing god-execute-with-current-bindings and entering v will execute evil-visual-block, which is bound to C-v in Evil's Normal state.

  • For sustained usage of God mode, it's a bit trickier as keybindings in Evil states generally override God mode. For example, if God mode is activated in Normal state, entering v executes evil-visual-char, which is bound to v in Normal state, instead of executing evil-visual-block. A good option to use Evil's state-specific keybindings through God mode is to create an intercept keymap using evil-make-intercept-map and god-local-mode-map. For example, you can enable use of God mode in Normal state as follows:

    (with-eval-after-load 'god-mode
      (evil-make-intercept-map god-local-mode-map 'normal)
      (add-hook 'god-local-mode-hook #'evil-normalize-keymaps))
  • Another option to use God mode with Evil is to use the evil-god-state package, which provides a dedicated Evil state for using God mode. For running occasional, single commands through God mode, use the evil-execute-in-god-state command. This works similar to god-execute-with-current-bindings. For sustained use of God mode, use the evil-god-state command. evil-god-state is also useful for accessing default Emacs keybindings through God mode. However, a disadvantage of evil-god-state is that Evil's state-specific keybindings will not be available in God mode.

god-mode's People

Contributors

acowley avatar akibazmain avatar andyjda avatar bradwright avatar chrisdone avatar conorbev avatar darth10 avatar dillonkearns avatar dragonwasrobot avatar drainful avatar felipeochoa avatar fgallina avatar fishyfriend avatar kyleam avatar luispauloml avatar magnars avatar proofit404 avatar purcell avatar pyluyten avatar ruediger avatar tarsius avatar yangzhao11 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

god-mode's Issues

Per buffer state retention.

Hey. Thank you for creating this mode. I have used it for few days now and it really improves the editing experience. I was wondering if there is a way for the 'god-local-mode' toggle to attach a variable to the current buffer indicating on whether this buffer is
in god state or not. Or perhaps god-mode already does that and I missed it? I have adapted your config to change the color of the cursor when god-mode is activated/deactivated. However, if I have multiple buffers opened and only one of them is in god state, after switching to another buffer, the cursor color is indicating the god state but the buffer is actually in the normal state. I have tried advising the switch-to-buffer function but for that I need to know the state of the buffer I am switching to. I am kinda new to Elisp programming but I think this should be possible. Perhaps one could somehow advise creation of the buffer to set such a variable?

Possible redefinition for g/G keys.

I use god-mode together with dvorak-mode. I want to remap g/G keys to i/I keys as it defined in Dvorak keyboard layout. I look at source code and seems like this isn't customizable option.

Did you consider to make it customizable?

Mid-sequence meta key? (and switching modifiers in general)

The readme file says that g followed by some KEY is the way to type M-KEY, but this only seems to work at the very beginning of a sequence?

I can't figure out how to type a M-KEY in mid-sequence.

e.g. How do I type C-x M-: or M-g M-t ?

(And for that matter, how can I use the control modifier mid-sequence, if the sequence didn't start with it? e.g. How could I type M-s C-/ ?)

The readme says "there is no way to write C-g in this mode, you must therefore type C-g directly"; but unless it's the first key, C-g is exactly what typing g produces? (as indeed the example at the beginning of the readme shows, which I thought was a mistake in the documentation (see #58) until I started using the mode).

Is any of this possible with the current implementation?

Buffer gets marked as changed when I hit the "n" key in god-mode

I am using god-mode-all, and if I open a buffer, and just hit the "n" key, the buffer detects a change, even though nothing has actually changed. The cursor does actually move like it's supposed to.

If I hit p my cursor will move up a line, and no change is detected.

If I hit C-n in god-mode, my cursor moves and the buffer is not marked as being changed.

When I hit C-h k C-n I get:

C-n runs the command next-line, which is an interactive compiled Lisp
function in `simple.el'.

It is bound to C-n.
…

Any ideas? I have a lot of custom key bindings, but I thought I'd ask in case someone had experienced this before.

God-mode does not capture key correctly

I am using smartparens package; it rebinds self-insert-command to sp--self-insert-command, even in God-mode. Because of this, when combining with numeric argument with some motion command (like C-f), instead of executing that command nth times (according to the numeric argument), it inserts a character nth times.

God-mode + haskell-unicode input method

god-mode doesn't quite play nice with the haskell-unicode input method from haskell-mode. Everything still works as expected (I think), but characters are written to the screen (though they are removed on completion of a command). I suspect it's because haskell-unicode doesn't use a delimiter for Unicode entry.

I've been trying to write an appropriate function to toggle the input method in tandem with god-mode (though really I think I'll just remove it from the hook since it was kinda goofy to begin with).

Any thoughts on this?

Can it be compatible with speed command in org-mode

Hi chrisdone,

God-mode is really a great package for me to use emacs. Thanks for your work.

I am not sure if you are familiar with speed command of org-mode. It is really useful for me to operate something with just one key if the cursor is in the beginning of the headline. For example, I can use k to close the subheadline and so on. However, when i turn on god-mode, the k is conflicted.

So can you accomplish that if the cursor is in the beginning of headline, the god-mode can be temporarily turned off?

Best regards!

Reference to free variable error

I get this error when starting my Emacs with God mode configured.

.emacs.d/elpa/god-mode-20140228.432/god-mode.elc:Warning: reference to free
    variable `god-local-mode'

Any clue?

Digit arguments with Meta

Currently we can observe the following behavior:
1g -> C-g
2g -> C-g

I think it'd be a huge improvement if:
1g -> C-g
2ga -> M-2 M-a
11ga -> M-11 M-a

or in more words, digit arguments immediatly followed by 'g' would still do the magic of using g for meta, except when the only digit typed was 1, in which case it could recognize we want the usual behavior of the 'C-g'

god-mode and term-mode interacting poorly

When running emacs graphically, I find that I can enter god-mode while visiting a term-mode buffer, but the letters I type are simply entered into the term rather than triggering god mode commands.

Eg I have this config:

(use-package god-mode
  :ensure t
  :defer t
  :bind (("<escape>" . god-mode-all)
         ("C-x C-o" . other-window)
         ("C-x C-0" . delete-window)
         ("C-x C-1" . delete-other-windows)
         ("C-x C-2" . split-window-below)
         ("C-x C-4" . winner-undo))
  :config
  (bind-key "." 'repeat god-local-mode-map))

And I have two windows open: one with a file, one with term-mode buffer. When the file buffer is active, I can press ESC and God appears in the modelines for both windows, then if I type xo the active window correctly changes, but if I type xo again, it is simply entered into the term despite saying God in the modeline.

I checked god-exempt-predicates and tried removing god-comint-mode-p from it, but it made no change in behavior.

I'm curious what the reasoning behind disabling god-mode for comint buffers by default was. I use terminals a lot and it's too confusing if I have one way to switch into the term mode buffer and then require a different way to switch back.

Any thoughts? Thanks.

<space> behaves strangely (navigation issues)

Today I upgraded the package to v. 20140811.1125 and I started encountering some very weird issues with the space key.
When I am in a org or haskell buffer, typing space prints a space instead of doing set-mark-command, while in any other buffer (AFAIK - I tried with Fundamental and Python mode), <space> does call set-mark-command (or equivalent), but the region breaks when typing n.

E.g To reproduce: <space> p p n

If I don't use god-mode or I am in god-mode but I use C-, C-n etc. this issue does not appear.

god-exempt-major-modes does not work as expected

I use god-local-mode, and I wanted to exclude few major modes, e.g.:

(add-to-list 'god-exempt-major-modes 'org-agenda-mode)
(add-to-list 'god-exempt-major-modes 'gnus-group-mode)

However, the god-local-mode command activated the god-mode in the exempt major modes regardless of the settings above. I wrote a function (below) which behaves in a "correct way". Could this behaviour be implemented by default?

(defun mk/god-local-toggle ()
  "Toggle God mode locally if allowed."
  (interactive)
  (let ((new-status (if (bound-and-true-p god-local-mode) -1 1)))
  (when (and (not (minibufferp))
             (god-passes-predicates-p))
    (god-local-mode new-status))))

Digit arguments with 'z' (repeat)

Currently we can observe the following behavior:
1z -> C-z
2z -> C-z

I think it'd be a huge improvement if:
1z -> C-z
2z -> M-2 repeat
11z -> M-11 repeat

or in more words, digit arguments immediatly followed by 'z' would still do the magic of using z for repeat, except when the only digit typed was 1, in which case it could recognize we want the usual behavior of the 'C-z'

God-mode not triggering on escape in terminal

I realize this is more of a support request, but I don't know of a better forum on which to ask it.

On Debian testing, with XFCE 4.10.1 and emacs 24.3.1, in either urxvt or xfce4-terminal, launching emacs -nw and (after successfully requiring god-mode) running (global-set-key (kbd "<escape>") 'god-mode-all) does not result in pressing escape enabling god-mode. `(global-set-key (kbd "q") 'god-mode-all) behaves as expected.

cua-selection-mode

god-mode and cua-selection-mode do not appear to go along well with each other: If I have activated the latter in god-mode and a region is active, my input is treated as if god-mode was disabled. So I always have to use C-w etc. instead of just w, or havoc is wreaked to my selected buffer contents.

Is there a simple work-around?

Shift Modifier not applied

Currently we can observe the following behavior:
P -> C-p ;; read P as hold shift and press p

I think it'd be an improvement if:
P -> C-S-p

or in more words, shift doesn't seem to be applied at all except for 'g' which is a special key right now

literal key stickiness

It is very uncommon for Emacs commands to have the form C-x x C-x. However, quite a few have the form C-x r y.

Would it be possible to have the literal key be sticky? So I could type x ry instead of x r y which is a bother.

Define minor mode properly

As I found out in yet another discussion on #emacs, the god-mode function is a normal function taking no argument to toggle. This is pretty weird since the majority of (major and) minor modes is defined with the define-derived-mode macro which takes care of the toggling and activation behaviour (and a good bit more).

I'd suggest rewriting the function definition that way unless this breaks backwards compatibility.

Alternate way of drawing attention to god-mode in terminal (-nw)

God mode is great, but sometimes I wish I could better remember if it was on or not. I know it shows up in the modeline but it is hard for my brain to parse that text quickly. One suggestion I thought of was font-locking the God in the modeline to a standout color. Are there other suggestions? Currently you suggest changing the cursor type, but that is difficult in a terminal (hence the -nw in the title of this issue).

This probably wouldn't be built-in to god-mode.el, but might be offered as a suggestion in the README. I'd be glad to code it up if I was pointed in the right direction.

Suggestion: Bind specials commands to god keymap

This is maybe a refactoring suggestion:

Bind the special keys directly on god-local-mode-map. That way it's not necessary to have customizable vars for every type of key - it could just be overwritten using normal define-key calls.

small documentation issue

The instructions here on using xmodmap to swap capslock and escape weren't working for me. The change would happen, but the keyswap would revert to its normal state after the computer went to sleep or restarted. I was told that xmodmap is growing obsolete, and a search online yielded this command instead:

dconf write /org/gnome/desktop/input-sources/xkb-options "['caps:escape']"

It worked well for me on Ubuntu 14.04. I understand you can use :swapescape instead of just :escape, also.

Here's the original question, and the above solution is listed as a comment under it.

http://askubuntu.com/questions/363346/how-to-permanently-switch-caps-lock-and-esc

Best!
steven arntson

Guide-key support

Hi,

following the advice of the author of evil-scout, I am now using god-mode together with evil-god-state. This is a great combination, but I have a hard time remembering all those C-something keybindings that are suddenly within easy reach.
It seems to me that your mode is ideally suited for guide-key integration. For instance, if you change god-mode-lookup-command to

(defun god-mode-lookup-command (key-string)
  "Execute extended keymaps such as C-c, or if it is a command,
call it."
  (let* ((key-vector (read-kbd-macro key-string t))
         (binding (key-binding key-vector)))
    (cond ((commandp binding)
           (setq last-command-event (aref key-vector (- (length key-vector) 1)))
           (guide-key/close-guide-buffer)
           binding)
          ((keymapp binding)
           (guide-key/popup-function key-vector)
           (god-mode-lookup-key-sequence nil key-string))
          (:else
           (error "God: Unknown key binding for `%s`" key-string)))))

then every multi-key command will automatically pop up guide-key buffers. As a bonus, this doesn't require constantly polling timers unlike the plain vanilla guide-key package. Please consider officially integrating guide-key with god mode. Ideally the labels should also be remapped accordingly (i.e., [C-f] would be displayed as [f] and [f] as [ f] as long as god-mode is not interpreting keys literally; pressing the god-literal-key would then change [f] to [ f] and vice versa).

If you're willing to add this, but don't actually have the time to implement it, I could try to prepare a pull request (though my elisp experience is very, very limited).

allow to customize modifiers

god-mode does hardcode "C-", "M-" and "C-M-" prefixes it adds to key sequences.

This might be fine with standard keymap, but is not correct and makes this incompatible with some specific keymaps.

here is what i had to change :

"god-mode automatic modifier"
(defvar god-auto-modifier "C-")

"god-mode modifier when g key is pressed"
(defvar god-g-modifier "M-")

Plus the two rows on the below function
(defun key-string-after-consuming-key (key key-string-so-far)
"Interpret god-mode special keys for key (consumes more keys if
appropriate). Append to keysequence."
(let ((key-consumed t) next-modifier next-key)
(message key-string-so-far)
(setq next-modifier
(cond
((string= key god-literal-key)
(setq god-literal-sequence t)
"")
(god-literal-sequence
(setq key-consumed nil)
"")
((string= key "g") god-g-modifier)
((string= key "G") "C-M-")
(t
(setq key-consumed nil)
god-auto-modifier
)))

ReadMe file inconsistency regarding C-g

In the first example, 'C-g' is twice reduced to 'g', while 'g' is also used as a prefix for Meta bindings.

The subsequent text covers this point and explains that it is necessary to always type C-g using the regular modifier key; so it would seem that the original example is incorrect.

`god-mode-all` doesn't autoload

It causes this error to appear in the *Messages* buffer:

Symbol's function definition is void: god-mode-maybe-activate

This is on Version 2.10.4 (although I got it from Melpa).

Check both keys and shadow one of them

Currently god mode seems to me shadow all bindings without C- prefix, such as common keymap check: C-h k.

I propose that after the first key, check both <key> and C-<key> and only when both exist, shadow the former.

Digit arguments not work

3f inserts fff instead of forwarding char three times. So does 3n and 3b. But 3p works fine. Any idea what is wrong?

Symbol's function definition is void: tab

If I press xs (for C-x C-s) or all other "double combo" commands, I get this error message:

 Symbol's function definition is void: tab

Emacs Version: GNU Emacs 24.3.1

Broken backspace

Sorry if this is just me being an idiot, but it seems like my backspace key has stopped working recently.

While in god-mode, if I hit backspace it used to execute backward-delete-char-untabify. But now it seems god-mode is trying, and failing, to remap it. I get this output:

god-mode-lookup-command: God: Unknown key binding for C-^?

Are there any solutions for modal repeated searching?

One of the things I really like about god-mode is the modal behavior it introduces into emacs without turning it into vim. Unfortunately, it would seem that control keys are needed for repeated searching. Is there any way this can be effected as desired?


I would note that the 'intuitive' behavior would be to press <escape> (or whichever toggle key you have set) in the search buffer and that would activate god-mode again in the minibuffer. I'm not savvy to how the minibuffer behaves in this respect, though. Can it have active minor modes?

Not exactly an issue

Chris,

Someone changing from emacs keybindings to ergoemacs keybindings mentioned god-mode. I developed something similar for ergoemacs-mode, but didn't include the g G SPC arguments. But I'm working on incorporating this

ergoemacs/ergoemacs-mode#148

I just wanted to make sure your OK with me taking the idea, as long as I acknowledge it. As far as I can tell, the code is quite different (though it does similar things).

Ergoemacs-mode also supports key themes, so I think that once universal arguments are supported, I could implement an alternative diety-mode for plain emacs keybindings.

Rebind more commands than just self-insert-command

Some modes bind some keys to functions other than self-insert-command. This is so that they can do something clever as well as insert the character. eg. in c-mode "/" is bound to c-electric-slash. This means that when in god-mode, pressing these keys will still insert the character instead of doing C-key.

I have these workarounds in my init.el:

(define-key god-local-mode-map [remap c-electric-slash] 'god-mode-self-insert)
(define-key god-local-mode-map [remap c-electric-brace] 'god-mode-self-insert)
; etc

This appears to have been encountered by people before (tickets #16 and #41). I'd imagine that "/" doing c-electric-slash instead of undo is a common problem. Perhaps it would be sensible to have a customisable list of commands god-mode should remap, and maintain a default list (which people are encouraged to submit pull requests to modify, like for god-exempt-major-modes).

Or perhaps not, in which case feel free to close and I'll just stick with remapping some commands myself.

Suggestion: i for insert

In Emacs C-i is TAB, and the <tab> key is mapped to it. This means pretty much no one rebinds C-i to anything else.

So, my suggestion is binding i to insert - ie, switching out of god-local-mode.

I'd be happy to open a pull request with this (perhaps optional but default on?) behavior.

`C-/` to undo does not work

C-/ is one of the keybindings to undo:

C-/ runs the command undo, which is an interactive compiled Lisp
function in `simple.el'.

It is bound to C-_, <undo>, C-/, C-x u, <menu-bar> <edit> <undo>.

(undo &optional ARG)

Undo some previous changes.
Repeat this command to undo more changes.
A numeric ARG serves as a repeat count.

In Transient Mark mode when the mark is active, only undo changes within
the current region.  Similarly, when not in Transient Mark mode, just C-u
as an argument limits undo to changes within the current region.

But / in god-mode does not execute (undo).

cannot go back to god-mode with 'emacs -nw' or plain console

I'm using XUbuntu 12.10, Emacs 24.3+1, and not remap my caps lock yet.

These are my configuration, installed from elpa:

(god-mode)                                                                                                                                           
(global-set-key (kbd "<escape>") 'god-local-mode)
(define-key god-local-mode-map (kbd "i") 'god-local-mode)                                                                                            
(define-key god-local-mode-map (kbd ".") 'repeat)
(defun my-update-cursor ()
  (setq cursor-type (if (or god-local-mode buffer-read-only)
                        'box
                      'bar)))

(add-hook 'god-mode-enabled-hook 'my-update-cursor)
(add-hook 'god-mode-disabled-hook 'my-update-cursor)

When using just emacs in Xubuntu/XFCE, I can go back between 'insert mode' and 'god mode' (i and ESC key). But when running emacs:

  • with options -nw from LXTerminal, and not on remote server,
  • or from CTRL-ALT-F1 and running just emacs (without option)

I can go to 'insert mode', but cannot go back to 'god mode' with ESC key.

TIA

`C-x C-s` should be easier to press than `C-x h`

Presently to achieve C-x C-s you press Xs, which is one less key pressed, but is less efficient than C-x h which is simply xh. The problem is that the C-c C-* commands are more frequently pressed, (which makes sense because chaining Ctrl chords are known to be faster than separate keys) so they should be easier to press.

I'm proposing we try out the opposite:

  • xsC-x C-s
  • XhC-x h

I'm making a ticket so that anyone watching this project receives notification.

Treat digits as themselves after C-x

More generally, treat digits as themselves when they are not the first thing pressed. It's my impression that this is much more common than C-.

God mode does not work with default binding for just-one-space (M-SPC)

Any idea on how to get God mode to play well with the default binding for just-one-space (M-SPC)? In God mode, "g " does not activate anything (probably because of the special handling of the space key/character) and "g " (two spaces) gives an error. I can of course bind that command to any other key, but old habits die hard... ;)

Thanks!

God-mode should integrate overwrite-mode

There are many cases in which we only want to change one or a few characters. It is inconvenient to exit god-mode, delete chars, enter new chars and go back to god-mode. Currently Emacs has overwrite-mode available; it should be integrated into god-mode such that when overwrite-mode is enabled, god-mode allows character to be inserted and when overwite-mode is disabled, the editing buffer goes back to god-mode.

Hooks trigerred per buffer

Binding (global-set-key (kbd "<escape>") 'god-mode-all) causes god-mode-enabled-hook and god-mode-disabled-hook to be triggered per buffer. So if you have a cursor update on this hook, emacs will freeze and cursor will blink fast for a few seconds.

Inherit god-mode state when creating buffers?

When I'm in an org-mode buffer, in god-mode, and want to edit some source code (c ' with god-mode), the buffer that is opened does not inherit the god-mode status. Its cursor, however, does not reflect this (I have added the cursor configuration proposed in the README).

Is there a way to inherit the current god-mode status when creating buffers? Or to make sure the cursor correctly reflect the current god-mode status?

Persistent M-

It would be a good idea to allow the user to "hold M-", so to speak. This would facilitate quick navigation shortcuts M-f, M-b, M-v, M-a, M-e.

The best trigger I can think of is "gg" (that is, 2x the meta key). The user would then get out of M- mode by hitting "g" a third time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.