Commit Graph

102 Commits

Author SHA1 Message Date
Henrik Lissner
abfc8ced21
Add warning re :prefix-map in map! docstring
It really shouldn't be used outside of Doom proper; it has the
capability of destroying other :prefix-map's due to variable/keymap
naming collisions.
2019-07-07 02:00:36 +02:00
Henrik Lissner
9a02bd8ac8
Minor refactors across the board
- when-let* -> when-let
- Fix projectile-locate-dominating-file for connected remote files
2019-06-26 14:31:06 +02:00
Henrik Lissner
1e357310c4
Fix localleader alt key in insert mode 2019-06-26 14:28:40 +02:00
Henrik Lissner
7c33d2c2e0
Fix C-c & C-x when used as leader keys 2019-05-20 21:09:11 -04:00
Henrik Lissner
448d5fc71f
map!: fix :prefix-map for non-leader keys
Would no-op if used on a non-leader key.
2019-05-20 21:09:10 -04:00
Henrik Lissner
32f8fa9f46
Fix :prefix-map indentation in map! calls 2019-05-17 13:31:05 -04:00
Henrik Lissner
b7d1702484
Add :prefix-map to map! macro
Each prefix now defines a doom-leader-DESC-map keymap, where DESC is the
which-key description for that prefix key. This should make it easier
for users to move leader prefixes. e.g.

To move SPC TAB (workspaces) to SPC l:

  (map! :leader
        "TAB" nil
        "l" doom-leader-workspaces-map)
2019-05-13 22:30:21 -04:00
Henrik Lissner
ac55b6a826
Remove unused doom-which-key-leader-prefix-regexp 2019-04-26 17:39:13 -04:00
Henrik Lissner
a03b676297
Move leader which-key labels to core-keybinds 2019-04-26 17:29:54 -04:00
Henrik Lissner
068a324fd1
Fix which-key labels for alt leader key #1332
Also mentioned in #1240
2019-04-16 10:56:26 -04:00
Henrik Lissner
83cba583a7
with-eval-after-load -> after!
So :desc is ignored if which-key is disabled.
2019-04-11 18:29:23 -04:00
Henrik Lissner
3b352143c0
Fix commandp errors on {local,}leader keys
General would read (function ...) forms unevaluated, as a list, rather
than a function symbol.
2019-04-08 14:06:18 -04:00
Henrik Lissner
1fab389d9e
Fix #1310: use internal macro for leader binds
Creates a separate doom--define-leader-key macro for internal use (in
map!). define-leader-key! will continue to exist as a convenience macro
for users who want a general.el interface to defining leader keys.

Possibly relevant to: #1309
2019-04-07 15:55:16 -04:00
Henrik Lissner
43bc14d38e
Undo noop'ed leader binds for missing commands
This was too magical and caused more confusion than the void-function
and commandp errors before it.

Addresses #1309, #1308
Relevant to #1217
2019-04-06 11:13:17 -04:00
Henrik Lissner
9d65619d3e
Fix keybinds to keymaps being ignored 2019-04-05 03:43:27 -04:00
Henrik Lissner
d6c9520d93
Don't bind missing commands to leader keys
I don't want to litter config/default/+evil-bindings.el with conditions
for every keybind whose module may or may not be enabled. It impacts its
readability and is relatively expensive (due to the internals of map!
and general).

So instead, we no-op keybinds for commands that don't exist (and aren't
autoloaded), so you don't see missing function errors when using these
keys.
2019-04-05 02:52:49 -04:00
Henrik Lissner
ea3d9e2957
Refactor & optimize define-leader-key!
- Provides a 10-30% boost in startup time
- which-key advice is no longer needed
2019-04-05 01:24:16 -04:00
Jeffrey Chu
ec76d9acb6
Escape key regexps when building which-key leader prefix 2019-03-31 12:38:42 -07:00
Henrik Lissner
d868f5fd10
Use new ;;;###package cookie
This will later be used for doom/describe-packages to list all locations
where a package is being configured (along with def-package! and after!
blocks).
2019-03-13 01:55:50 -04:00
Henrik Lissner
dbff052c8a
Use doom-which-key-leader-prefix-regexp
Curse your sudden but inevitable betrayal, impatience.
2019-03-11 13:16:51 -04:00
Henrik Lissner
f332ba6111
Define doom-which-key-leader-prefix-regexp 2019-03-11 13:10:42 -04:00
Henrik Lissner
dadcd29f27
Refactor leader key initialization
Ensures general-override-mode is enabled and labels are correctly
registered to all (visible) leader keys.

Relevant to #1240
2019-03-11 13:06:46 -04:00
Henrik Lissner
b0bc1d925f
Minor refactors; revise docstrings+comments 2019-03-09 19:56:47 -05:00
Henrik Lissner
8e866bb37f
Improve leader key initialization
And ensure leader key always has precedence.

Indirectly fixes #1234
2019-03-09 02:42:23 -05:00
Henrik Lissner
c9e7d27317
Set leader keys later #1233
Setting them too soon means the user can't change them.
2019-03-08 14:23:42 -05:00
Henrik Lissner
a4c0bc2738
Optimize general integration
Using general to bind leader keys was responsible for 40-50% of Doom's
startup time. This change reduces that significantly, but not entirely.
It may be better that the config/default module not use map!. It is a
convenient macro, but general is a huge bottleneck.
2019-03-08 02:37:33 -05:00
Henrik Lissner
51129567d9
Mention $DOOMDIR/init.el in leader key docstrings
They need to be changed as soon as possible, otherwise leader keybinds
done before the change will use the old leader key.
2019-02-24 13:47:54 -05:00
Henrik Lissner
c82faf7f10
General reformatting & minor refactors 2019-02-19 15:53:26 -05:00
Henrik Lissner
a5f53098e3
Merge pull request #1106 from y-usuzumi/develop
Fix an issue where doom-leader-alt-key and doom-localleader-alt-key does not work in emacs mode
2019-01-20 14:15:55 -05:00
Henrik Lissner
aaee04e257
Remove unused doom-leader prefix command 2019-01-14 21:24:52 -05:00
Kenneth Zhao
0a7717786c Fix an issue where doom-leader-alt-key and doom-localleader-alt-key does not work in emacs mode 2019-01-10 11:45:32 +08:00
Henrik Lissner
069c196330
Appease byte-compiler senpai
Please notice me
2019-01-08 20:54:03 -05:00
Henrik Lissner
25b9a90c12
Fix localleader keys in replace state #1097 2019-01-07 04:57:54 -05:00
Henrik Lissner
a4cd5fafd8
Don't unbind keys when passed a label to :prefix
Fixes an issue where

  (map! :leader
        :prefix ("f" . "asdasdas")
        ...)

Would unbind SPC f before adding your new keybinds.
2019-01-03 02:26:11 -05:00
Henrik Lissner
d3882f539c
Remove :if from map!
It doesn't work as expected and would require too much work to support.
2019-01-02 13:18:19 -05:00
Henrik Lissner
afee81dfde
Fix define-leader-key! comment 2018-12-28 15:22:29 -05:00
Henrik Lissner
63a224f0e8
Fix wrong which-key labels & leader key precedence
This changes how leader keys are bound, to fix an issue where the wrong
which-key label was assigned to the wrong keys, and cases where the
leader key was being shadowed by other minor mode mappings.

Unfortunately, this new method adds 10-20% to startup times. I'll
address this in a future patch. For now, correctness is more important.

Also fixes dashboard keybind detection.
2018-12-27 00:08:47 -05:00
Henrik Lissner
b7cfa90967
Update map! docstring
And remove all references to :alt-prefix
2018-12-26 00:55:39 -05:00
Henrik Lissner
c0c84eb99b
Fix M-SPC error with helm #1059
The global leader keybind was conflicting with a global M-SPC keybind in
helm-map. This keybind should only be set in non-evil sessions, so we
unset it if evil is found.
2018-12-25 03:56:24 -05:00
Henrik Lissner
d337e255d3
Fix :leader/:localleader and :prefix
Due to issues with preset prefixes in general definers and nested
:prefix's supplied from a map! call not cooperating, many localleader
keybinds were broken and causing errors. For :leader/:localleader keys,
we now use :infix for sub-prefixes.

However, with this change, the :alt-prefix property has been removed, as
there is no simple way to support this without some major state
gymnastics in map!.

Fixes #1059
2018-12-25 02:29:29 -05:00
Henrik Lissner
5ad0b749a1
Refactor map! & tests
This resolves issues with :leader/:localleader keys not working when
evil states are specified. Evil states are now ignored. Also, some of
map!'s internals have been optimized to yield a ~10% improvement in
macro expansion time.
2018-12-23 23:12:10 -05:00
Henrik Lissner
0efa915164
Fix :leader/:localleader targeting preceding keys
This fixes an issue where even the keys preceding :leader/:localleader
were registered as leader/localleader keys.
2018-12-23 00:10:18 -05:00
Henrik Lissner
91474c98ee
Fix localleader binds hijacking SPC in insert mode 2018-12-22 19:33:20 -05:00
Henrik Lissner
4383531b32
Ensure gerneral-implicit-kbd=t in map!
Also updates map! tests (TODO: abstract all those cdr-caddr's!)
2018-12-22 17:11:20 -05:00
Henrik Lissner
604a41527f
Use general custom definers rather than :definer
The former approach was the cause for a huge increase in startup
time (adding ~0.4s) when :leader and :localleader were used. This is
because general-define-key was called for every key-def pair.

This new approach batches these calls, which has decreased the
performance impact by at least 80%.
2018-12-22 16:50:01 -05:00
Henrik Lissner
4d3587c8d0
Fix void-variable list error in multi-state binds
Caused by overzealous re-setting of a variable in a loop, when it should
only be set once.
2018-12-22 05:20:43 -05:00
Henrik Lissner
4daa9271a0
Introduce general.el & rewrite map!
+ Now uses an overriding keymap for leader keys, so that it is always
  available, even outside of normal/visual states. In insert/emacs
  states, or in sessions where evil is absent, an alternative prefix is
  used for leader/localleader keys. See these variables:
  + doom-leader-prefix
  + doom-leader-alt-prefix
  + doom-localleader-prefix
  + doom-localleader-alt-prefix
+ Keybinds now support alternative prefixes through the new :alt-prefix
  property. This is useful for non-evil users and non-normal evil
  states. By default, this is M-SPC (leader) and M-SPC m (localleader).
+ Removed +evil-commands flag from config/default (moved to
  feature/evil/+commands.el).
+ config/default/+bindings.el has been split into
  config/default/+{evil,emacs}-bindings.el, which one is loaded depends
  on whether evil is present or not. The latter is blank, but will soon
  be populated with a keybinding scheme for non-evil users (perhaps
  inspired by #641).
+ The define-key! macro has been replaced; it is now an alias for
  general-def.
+ Added unmap! as an alias for general-unbind.
+ The following modifier key conventions are now enforced for
  consistency, across all OSes:
    alt/option      = meta
    windows/command = super
  It used to be
    alt/option      = alt
    windows/command = meta
  Many of the default keybinds have been updated to reflect this switch,
  but it is likely to affect personal meta/super keybinds!

The map! macro has also been rewritten to use general-define-key. Here
is what has been changed:

+ map! no longer works with characters, e.g. (map! ?x #'do-something) is
  no longer supported. Keys must be kbd-able strings like "C-c x" or
  vectors like [?C-c ?x].
+ The :map and :map* properties are now the same thing. If specified
  keymaps aren't defined when binding keys, it is automatically
  deferred.
+ The way you bind local keybinds has changed:

    ;; Don't do this
    (map! :l "a" #'func-a
          :l "b" #'func-b)
    ;; Do this
    (map! :map 'local "a" #'func-a
                      "b" #'func-b)

+ map! now supports the following new blocks:
  + (:if COND THEN-FORM ELSE-FORM...)
  + (:alt-prefix PREFIX KEYS...) -- this prefix will be used for
    non-normal evil states. Equivalent to :non-normal-prefix in general.
+ The way you declare a which-key label for a prefix key has changed:

    ;; before
    (map! :desc "label" :prefix "a" ...)
    ;; now
    (map! :prefix ("a" . "label") ...)

+ It used to be that map! supported binding a key to a key sequence,
  like so:

    (map! "a" [?x])  ; pressing a is like pressing x

  This functionality was removed *temporarily* while I figure out the
  implementation.

Addresses: #448, #814, #860
Mentioned in: #940
2018-12-22 04:14:43 -05:00
Henrik Lissner
0c39e73a1e Refactor/reformat core-ui
+ Move minibuffer fringe disabler to ui/doom
+ Disable blink-cursor-mode (too distracting, causes other issues e.g.
  #892)
2018-09-18 15:19:50 -04:00
Henrik Lissner
895df84f8b Add key-to-key binding support to map!
Experimental, and will eventually be replaced by general-simulate-key.
2018-09-18 15:19:50 -04:00
Henrik Lissner
57579b883b
Refactor doom core files 2018-09-09 09:58:20 -04:00