Giter Site home page Giter Site logo

gcentauri / xah-fly-keys-layer Goto Github PK

View Code? Open in Web Editor NEW
11.0 4.0 4.0 70 KB

Spacemacs configuration layer for the xah-fly-keys package

License: GNU General Public License v3.0

Emacs Lisp 100.00%
spacemacs spacemacs-layer keymap ergonomics productivity

xah-fly-keys-layer's Introduction

xah-fly-keys layer

img/xah-logo.png

Table of Contents

Description

This layer adds an alternative modal editing mode for Emacs.

“like vi, but the design of key/command choice is based on command frequency statistics and ease-of-key score. Most frequently used commands have most easy keys.”

xah-fly-keys has been developed over years of experience by Xah Lee, a long time contributer to the Emacs community.

Gain the modal superpowers of the dark side, without succumbing to evil!

Features:

  • You NEVER need to press 【Ctrl+x】or Meta! Use a leader key instead!
  • There are about 200 commands with leader key sequences.
  • Efficient keys for common navigation and editing tasks in command mode.
  • The key bindings are based on experience and observed frequency of use.

Install

Clone this repository into .emacs.d/private/xah-fly-keys, or where ever you keep your private layers:

git clone https://github.com/gcentauri/xah-fly-keys-layer.git ~/.emacs.d/private/xah-fly-keys

Note - the directory the layer files are in must be named xah-fly-keys.

To use this configuration layer, add it to your ~/.spacemacs. You will need to add xah-fly-keys to the existing dotspacemacs-configuration-layers list in this file. You should have the dotspacemacs-editing-style set to 'emacs.

It is recommended to change some of the defaults in your .spacemacs file, in order to avoid some unwanted cross-over with some key bindings.

  • set the dotspacemacs-leader-key to an empty string, as having it set to SPC interferes with the which-key mappings.
  • set dotspacemacs-colorize-cursor-according-to-state nil so that the cursor will reflect the xah-fly-keys state instead.

Configuration

Keyboard layout

This layer assumes a qwerty layout and uses that by default. You can configure xah-fly-keys to use other keyboard layouts with the xah-fly-keys-layout variable.

The possible values are:

  • azerty, azerty-be
  • colemak, colemak-mod-dh
  • dvorak, programer-dvorak
  • qwerty, qwerty-abnt
  • qwertz
  • workman

For example, to use the dvorak layout, add the following to your layers list:

(xah-fly-keys :variables xah-fly-keys-layout "dvorak")

Cursor appearance for command and insert modes

You can customize the appearance of the cursor using two variables:

  • xah-fly-keys-command-mode-cursor
  • xah-fly-keys-insert-mode-cursor

Both variables are a pair of the form (COLOR . CURSOR-TYPE). COLOR is a string, either one of the defined color words in the list-colors-display or a hex code for the color. The CURSOR-TYPE is one of the types that can be set on the cursor-type variable:

t               use the cursor specified for the frame
nil             don’t display a cursor
box             display a filled box cursor
hollow          display a hollow box cursor
bar             display a vertical bar cursor with default width
(bar . WIDTH)   display a vertical bar cursor with width WIDTH
hbar            display a horizontal bar cursor with default height
(hbar . HEIGHT) display a horizontal bar cursor with height HEIGHT
ANYTHING ELSE   display a hollow box cursor

For example,

(xah-fly-keys :variables
              xah-fly-keys-command-mode-cursor '("yellow" . box)
              xah-fly-keys-insert-mode-cursor '("#ff00ff" . hbar))

It defaults to very distinctive, contrasting cursors to help indicate state. 😄

Preferred incremental search function

This will default to either helm-swoop or swiper if helm/ivy layer is used. Otherwise it will be isearch-foward. You can set it to your preferred command.

(xah-fly-keys :variables xah-fly-keys-search-function 'helm-swoop)

Preferred M-x function

This defaults to the standard execute-extended-command, which seems to be remapped by helm or ivy if those layers are installed. Set this variable if you prefer another M-x command or need to configure it explicitly.

(xah-fly-keys :variables xah-fly-keys-M-x-function 'counsel-M-x)

Swap the leader keys

If you’d like to have the Spacemacs leader key on the space bar rather than the xah-fly-keys menu, then it’s possible to swap them.

I tried implementing this with a config variable, but it doesn’t quite work as expected. Until that is sorted out, add this to your dotspacemacs/user-config to swap the leader keys for Spacemacs and xah-fly-keys.

(defun xah-fly-keys-swap-spacemacs-leader ()
      (progn
        (define-key xah-fly-key-map (kbd "SPC") 'spacemacs-cmds)
        (define-key xah-fly-key-map (kbd "M-m") 'xah-fly-leader-key-map)))

(add-hook 'xah-fly-command-mode-activate-hook 'xah-fly-keys-swap-spacemacs-leader)

You’ll also need to set the dotspacemacs-emacs-leader key to an empty string. It appears that sometimes the which-key menu will be affected by this change.

Key bindings

See xah-fly-keys for the modal keymap defined by Xah Lee.

Command mode

Key bindingDescription
M-mspacemacs commands keymap
ESCxah-fly-leader-key-map
SPCxah-fly-leader-key-map
'xah-cycle-hyphen-underscore-space
,xah-next-window-or-frame
-xah-backward-punct
.xah-forward-right-bracket
/xah-goto-matching-bracket
0xah-pop-local-mark-ring
1xah-extend-selection
2xah-select-line
3delete-other-windows
4split-window-below
5delete-char
6xah-select-block
7xah-select-line
8xah-extend-selection
9xah-select-text-in-quote
;xah-end-of-line-or-block
=xah-forward-punct
[hippie-expand
`other-frame
asmex
bxah-toggle-letter-case
cxah-copy-line-or-region
dxah-delete-backward-char-or-bracket-text
ebackward-kill-word
fxah-fly-insert-mode-activate
gxah-delete-current-text-block
hxah-beginning-of-line-or-block
iprevious-line
jbackward-char
knext-line
lforward-char
mxah-backward-left-bracket
nisearch-forward
oforward-word
pxah-insert–space-before
qxah-reformat-lines
rxah-kill-word
sopen-line
tset-mark-command
ubackward-word
vxah-paste-or-paste-previous
wxah-shrink-whitespaces
xxah-cut-line-or-region
yundo
zxah-comment-dwim
DELxah-fly-leader-key-map
<C-f11>xah-previous-emacs-buffer
<C-f12>xah-next-emacs-buffer
<f11>xah-~previous-user-buffer
<f12>xah-next-user-buffer
<f8>xah-fly-command-mode-activate-no-hook
<f9>xah-fly-leader-key-map
<home>xah-fly-command-mode-activate
<menu>xah-fly-command-mode-activate

Leader Key Map

Key BindingDescription
SPC TABxah-fly–tab-key-map
SPC RETexecute-extended-command
SPC SPCxah-fly-insert-mode-activate
SPC 'xah-show-form-feed-as-line
SPC ,xah-fly-w-keymap
SPC 3delete-window
SPC 4split-window-right
SPC 5balance-windows
SPC 6xah-upcase-sentence
SPC 9ispell-word
SPC ;save-buffer
SPC \toggle-input-method
SPC amark-whole-buffer
SPC bxah-toggle-previous-letter-case
SPC cxah-copy-all-or-region
SPC dxah-fly-e-keymap
SPC exah-fly-dot-keymap
SPC fswitch-to-buffer
SPC gkill-line
SPC hbeginning-of-buffer
SPC ixah-fly-c-keymap
SPC jxah-fly-h-keymap
SPC kxah-fly-t-keymap
SPC lxah-fly-n-keymap
SPC mdired-jump
SPC nend-of-buffer
SPC oxah-fly-r-keymap
SPC precenter-top-bottom
SPC qxah-fill-or-unfill
SPC rquery-replace
SPC sexchange-point-and-mark
SPC txah-show-kill-ring
SPC uisearch-forward
SPC vxah-paste-or-paste-previous
SPC wxah-fly-comma-keymap
SPC xxah-cut-all-or-region
SPC yxah-search-current-word
SPC DELxah-fly-insert-mode-activate

Sub keymaps

You’ll notice that there are several sub keymaps after pressing a leader key. These are organized by ease of use, and should really be categorized by finger and keyboard row. I’ve listed some of the functionality for each of the keymaps, but use which-key and you’ll discover more details.

  • 【SPC ,】 - Eval, kill emacs
  • 【SPC k】 - registers, replace, occur
  • 【SPC o】 - rectangles, macros, number registers
  • 【SPC l】 - modes, view, windows
  • 【SPC j】 - help, apropos, info
  • 【SPC d】 - inserting chars, brackets, unicode
  • 【SPC i】 - files, bookmarks, external apps
  • 【SPC w】 - xref, find identifiers
  • 【SPC e】 - search, highlight, fonts
  • 【SPC TAB】 - indent, expand, abbrev

xah-fly-keys-layer's People

Contributors

duianto avatar shervinsafavi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

xah-fly-keys-layer's Issues

Wrong number of arguments while setting variables

First of all, thank you for this package. Switching to spacemacs has been seamless because of this layer. However, I am having a small issue.

I wanted my search to default to isearch-forward so I followed the README and tried this
(xah-fly-keys :variables xah-fly-keys-search-function 'isearch-forward)

But I got wrong number of arguments error. This is the stack trace.

Debugger entered--Lisp error: (wrong-number-of-arguments (0 . 1) 3)
  xah-fly-keys(:variables helm-swoop isearch-forward)
  (progn (xah-fly-keys :variables xah-fly-keys-search-function 'isearch-forward))
  eval((progn (xah-fly-keys :variables xah-fly-keys-search-function 'isearch-forward)) t)
  elisp--eval-last-sexp(nil)
  #f(compiled-function (eval-last-sexp-arg-internal) "Evaluate sexp before point; print value in the echo area.\nInteractively, with a non `-' prefix argument, print output into\ncurrent buffer.\n\nNormally, this function truncates long output according to the\nvalue of the variables `eval-expression-print-length' and\n`eval-expression-print-level'.  With a prefix argument of zero,\nhowever, there is no such truncation.\nInteger values are printed in several formats (decimal, octal,\nand hexadecimal).  When the prefix argument is -1 or the value\ndoesn't exceed `eval-expression-print-maximum-character', an\ninteger value is also printed as a character of that codepoint.\n\nIf `eval-expression-debug-on-error' is non-nil, which is the default,\nthis command arranges for all errors to enter the debugger." (interactive "P") #<bytecode 0x1fc8e6d5800f>)(nil)
  #f(compiled-function (&rest _it) #<bytecode 0x156252fdb759>)()
  eval-sexp-fu-flash-doit-simple(#f(compiled-function (&rest _it) #<bytecode 0x156252fdb759>) #f(compiled-function (&rest args2) #<bytecode 0x156252a27061>) #f(compiled-function (&rest args2) #<bytecode 0x156252a27081>))
  eval-sexp-fu-flash-doit(#f(compiled-function (&rest _it) #<bytecode 0x156252fdb759>) #f(compiled-function (&rest args2) #<bytecode 0x156252a27061>) #f(compiled-function (&rest args2) #<bytecode 0x156252a27081>))
  esf-flash-doit(#f(compiled-function (&rest _it) #<bytecode 0x156252fdb759>) #f(compiled-function (&rest args2) #<bytecode 0x156252a27061>) #f(compiled-function (&rest args2) #<bytecode 0x156252a27081>) #f(compiled-function (&rest args2) #<bytecode 0x156252a270a1>))
  ad-Advice-eval-last-sexp(#f(compiled-function (eval-last-sexp-arg-internal) "Evaluate sexp before point; print value in the echo area.\nInteractively, with a non `-' prefix argument, print output into\ncurrent buffer.\n\nNormally, this function truncates long output according to the\nvalue of the variables `eval-expression-print-length' and\n`eval-expression-print-level'.  With a prefix argument of zero,\nhowever, there is no such truncation.\nInteger values are printed in several formats (decimal, octal,\nand hexadecimal).  When the prefix argument is -1 or the value\ndoesn't exceed `eval-expression-print-maximum-character', an\ninteger value is also printed as a character of that codepoint.\n\nIf `eval-expression-debug-on-error' is non-nil, which is the default,\nthis command arranges for all errors to enter the debugger." (interactive "P") #<bytecode 0x1fc8e6d5800f>) nil)
  apply(ad-Advice-eval-last-sexp #f(compiled-function (eval-last-sexp-arg-internal) "Evaluate sexp before point; print value in the echo area.\nInteractively, with a non `-' prefix argument, print output into\ncurrent buffer.\n\nNormally, this function truncates long output according to the\nvalue of the variables `eval-expression-print-length' and\n`eval-expression-print-level'.  With a prefix argument of zero,\nhowever, there is no such truncation.\nInteger values are printed in several formats (decimal, octal,\nand hexadecimal).  When the prefix argument is -1 or the value\ndoesn't exceed `eval-expression-print-maximum-character', an\ninteger value is also printed as a character of that codepoint.\n\nIf `eval-expression-debug-on-error' is non-nil, which is the default,\nthis command arranges for all errors to enter the debugger." (interactive "P") #<bytecode 0x1fc8e6d5800f>) nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

I also tried changing the layout to dvorak by following the README and got a similar error.

Inconsistent cursor type during insert mode

First of all, thank you for the package. It has been a great help for transitioning to spacemacs.

Everything works great except for the fact that the cursor is sometimes inconsistent during insert-mode.

Expected Behaviour

  • During command mode, the cursor color is pink and the cursor type is a box.
  • During insert mode, the cursor color is blue and the cursor type is a bar.

What is happening

  • During command mode, the cursor color is pink and the cursor type is a box.(this is as expected)
  • During insert mode, the cursor color is blue but the cursor type is still a box.

Examples
Problem during autocomplete
Problem inside ansi-term

Further details
This causes minor annoyances that adds up quickly. I have found that the problem persists mostly on two occasions.

  1. When I am inside the ansi-term
  2. When company autocomplete box pops up

This problem only persists on the autocomplete if I use the company-posframe package(which I am forced to use because if I don't, my autocomplete looks like this. It works fine if I don't use company-posframe so is this a problem with company-posframe?

System details:

I am using the latest commit of develop branch of spacemacs(8b888c6a082).

In GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20)
of 2020-08-28 built on sarthakpc
Windowing system distributor 'The X.Org Foundation', version 11.0.12008000
System Description: Ubuntu 20.04.1 LTS
Configured using:
'configure --with-modules'

Fail to setup

Hi,

First of all, many thanks for putting effort to make it!

I tried to set it up, by following your instruction, but when I run emacs, I face with the following warning: "Unknown layer xah-fly-keys declared in your dotfile".

Do you have any idea why did it happen? Or any hint?

(I'm very new to emacs)

Integrate with Spacemacs helm/ivy

There are plenty of places to make better integrations with spacemacs-completion (specifically helm and ivy)... for example:

  • n in command mode does i-search but could be helm-swoop or swiper
  • a in command mode does smex but could be counsel or helm-M-x

I am sure there are plenty more :)

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.