1

I have back-to-indentation bound to M-u.
When I hold Shift with M-u I'm unable to select the text because M-U (note the capital 'U') is bound to upcase-word

So I disabled that bind by putting: (global-set-key (kbd "M-U") 'ignore) in my init file.
But by doing so, holding Shift with M-u now does nothing.

So how can I disable a keybind getting in the way of shift selecting with my custom cursor moving keybind?

closed as off-topic by Drew, DoMiNeLa10 Dec 27 '18 at 11:32

  • This question does not appear to be about emacs, within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • AFAIK, there is no M-U binding by default, so you'll need to try and find the offending binding of M-U to upcase-word. You could start with C-h k M-U which may tell you "(found in ...)" if you're lucky. – Stefan Jun 21 '18 at 12:31
  • I just did (global-set-key (kbd "M-u") 'back-to-indentation) and it works like you describe it should work with alt+shift+u. It selects text back to indentation. – Maxim Kim Aug 20 '18 at 12:29
  • I also get the desired behaviour after setting M-u to 'back-to-indentation, as @MaximKim said. Can you show us the code you used to set your keybindings? – Tyler Sep 18 '18 at 19:52
  • @Tyler It works now. I honestly can't remember how I solved the problem. I should probably delete this question. – John DeBord Sep 18 '18 at 23:59
  • 1
    I'm voting to close this question as off-topic because OP wants to delete the question (see comments). – Drew Dec 27 '18 at 4:07
1

As noted by @Maxim Kim, it should be as simple as

(global-set-key (kbd "M-u") 'back-to-indentation)

The fact that it's not that simple implies there is a collision happening somewhere in your configuration.

Here's how we can tell if it's a collision: start Emacs using emacs -q. That loads Emacs without loading init.el. Run the above code. If things work as you expect, then there's something in your configuration that's overriding the desired behavior.

Finding where the problem is exactly can be tricky. I find it helpful to select half of my init.el and then do eval-region. If the problem occurs, then we know the conflict is introduced in the first half of the code. I then select half of the first half of the code and do eval-region again. Eventually, you find the offending line(s) and can begin researching the specific cause.


Sometimes when there's a collision, the simplest solution is to find an alternative. While I don't think that's necessary in your case, here are a few options that provide identical/similar functionality.

It seems like back-to-indentation does the same thing as ^ does in evil-mode, namely placing point at the first non-white character.

Alternatively, here's a script from my init.el, garnered from some kind soul on the Internet:

(defun smart-beginning-of-line ()
  "Move point to first non-whitespace character or beginning-of-line.

Move point to the first non-whitespace character on this line.
If point was already at that position, move point to beginning of line."
  (interactive)
  (let ((oldpos (point)))
    (back-to-indentation)
    (and (= oldpos (point))
     (beginning-of-line))))

(global-set-key [home] 'smart-beginning-of-line)
(global-set-key "\C-a" 'smart-beginning-of-line)
0

Try (global-unset-key (kbd "M-U"))? (It is equivalent to (global-set-key (kbd "M-U") nil).)

  • Just tried it; it didn't work.. – John DeBord Jun 20 '18 at 19:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.