Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ctrl+U Alt+A (C-u M-x) eats the first character #133

Closed
pdg137 opened this issue Dec 15, 2013 · 23 comments
Closed

Ctrl+U Alt+A (C-u M-x) eats the first character #133

pdg137 opened this issue Dec 15, 2013 · 23 comments
Labels

Comments

@pdg137
Copy link
Contributor

pdg137 commented Dec 15, 2013

To reproduce, type Ctrl+U Alt+A shell, and you will see "C-u M-x hell" in the minibuffer (with no "s").

I verified this with a fresh emacs with ergoemacs-mode-20131210.815 installed via Melpa, executing:

(package-initialize)
(setq ergoemacs-theme nil)
(setq ergoemacs-keyboard-layout "us")
(ergoemacs-mode 1)
@mattfidler
Copy link
Member

What a devilish bug for a sunday...I will look into it.

@mattfidler
Copy link
Member

I can't exactly reproduce it. However, Ctrl+u Alt+a doesn't even bring up an execute kbd-macro for me... Something is wrong.

@mattfidler
Copy link
Member

I'm kind of stumped on this bug. I can't see where a read-key or unread-command-events wasn't handled properly. I even made sure that execute-extended-command is not called to ergoemacs-shortcut and that still doesn't work.

@pdg137
Copy link
Contributor Author

pdg137 commented Dec 17, 2013

Thanks for looking into it! I don't remember this being a problem with Xah Lee's package from before it was on MELPA. Have you considered doing something like a binary search to determine when it broke? I also wonder, since you are not seeing the same symptoms as I am, whether you have something like helm installed that could affect the behavior.

@pdg137
Copy link
Contributor Author

pdg137 commented Dec 17, 2013

I tried using "git bisect" to investigate further and found that the problem appears (for me, at least) at commit 95fa49c.

@mattfidler
Copy link
Member

I now reproduce the behavior. I'm not sure why I wasn't reproducing it before. It does the same thing in helm and smex, unfortunately.

I tried reverting to the commit you pointed out and it didn't really work for me. I'm going to have to look into this more...

@mattfidler
Copy link
Member

Thanks for the git bisect tip. Facinating.

@mattfidler
Copy link
Member

By the way, an easy way to start a clean ergoemacs session is to use the key <menu> h z or C-h z.

@mattfidler
Copy link
Member

You look like someone I know... Is your first name Tom?

@mattfidler
Copy link
Member

I got to the same place....

@pdg137
Copy link
Contributor Author

pdg137 commented Dec 17, 2013

Sorry, it's Paul. Anyway, 95fa49c is the first bad commit; the parent, i.e. 95fa49c^ should work. It looks like the commit throws away a lot of keyboard bindings in a strange way, but I don't understand it because it is in the middle of a monster function. The code seems to have been cleaned up a lot since then, and the particular condition-case that broke Ctrl+U is no longer present.

The bad commit also caused some tests in ergoemacs-test to fail, but there don't seem to be tests for the bug that was supposedly fixed, and I don't know how write tests myself, so I have no idea about how to proceed.

@mattfidler
Copy link
Member

Sometimes I can't figure out how to write a test for a bug. This is one that I can't figure out how to write a test for.

@mattfidler
Copy link
Member

The funny thing about this bug, is ergoemacs-mode shouldn't be even calling this function.

By setting

(setq ergoemacs-show-true-bindings t)

The actual function bound to M-a is execute-extended-command, whereas bindings such as M-k run this function.

@mattfidler
Copy link
Member

Even taking out the post-command-hook and pre-command-hook functions, this doesn't work.

@mattfidler
Copy link
Member

By taking out all refenreces to this function, the bug still occurs. This is done by:

(defun ergoemacs-setup-keys-for-layout (layout &optional base-layout)
  "Setup keys based on a particular LAYOUT. All the keys are based on QWERTY layout."
  (ergoemacs-setup-translation layout base-layout)
  ;; Reset shortcuts layer.
  (setq ergoemacs-command-shortcuts-hash (make-hash-table :test 'equal))
  (let ((setup-ergoemacs-keymap nil))
    (ergoemacs-setup-keys-for-keymap ergoemacs-keymap))
...

@mattfidler
Copy link
Member

I don't think that function is causing the bug....

mattfidler added a commit that referenced this issue Dec 17, 2013
@mattfidler mattfidler reopened this Dec 17, 2013
@mattfidler
Copy link
Member

Right now, I have a work-around. If execute-extended-command helm-M-x or smex is called pretend you typed a p. Then the p is eaten instead of the next key... Its a horrible work-around, but I think it solves the issue tempoaraily.

@pdg137
Copy link
Contributor Author

pdg137 commented Dec 17, 2013

Thanks for working so hard on this! By the way, the bug also occurs with some other prefixed commands like Ctrl+U Ctrl+O (though I'm not sure why one would use that.) When I was testing on commit 95fa49c, the function was definitely called many times after pressing Ctrl+U, and it reached condition-case but never add-to-list.

@mattfidler
Copy link
Member

I think this bug occurs whenever there is a prefix argument and the command enters the minibuffer.

@mattfidler
Copy link
Member

Hm. It may be the universal-argument-other-key that is eating the character.

(defun universal-argument-other-key (arg)
  (interactive "P")
  (setq prefix-arg arg)
  (let* ((key (this-command-keys))
     (keylist (listify-key-sequence key)))
    (setq unread-command-events
      (append (nthcdr universal-argument-num-events keylist)
          unread-command-events)))
  (reset-this-command-lengths)
  (restore-overriding-map))

@mattfidler
Copy link
Member

It is run right after ergoemacs starts the minibuffer.

mattfidler added a commit that referenced this issue Dec 17, 2013
change one command-keys to single-command-keys
mattfidler added a commit that referenced this issue Dec 17, 2013
@mattfidler
Copy link
Member

This should be fixed. Even for the Ctrl+o example

@pdg137
Copy link
Contributor Author

pdg137 commented Dec 18, 2013

The current version in MELPA now works great. Thanks!

mattfidler added a commit that referenced this issue Dec 20, 2013
- Added option to allow setup of ergoemacs keys every time a hook is
  run instead of just once.
- Fix escape to work with org-mode date/time stamps
- Fixed handling of prefixes that caused Ctrl+U Alt+a to eat the first
  character:
  #133
- Fixed shift-selection-mode:
  #137
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants