Note that there are some explanatory texts on larger screens.

plurals
  1. POEmacs: Translating C-h to DEL, M-h to M-DEL
    primarykey
    data
    text
    <p>I want my C/M-h keys to be a binding for delete. </p> <p>The usual solution of global-set-key doesn't work for me, as I want these keys to behave as delete everywhere including the minibuffer and various modes, and be able to work between my various Linux/OS X/Windows emacs installations.</p> <p>I have the following near solution:</p> <pre><code>(when (&gt;= emacs-major-version 23) (setq help-char (string-to-char "&lt;f1&gt;")) ;; Bind ONLY F1 to help, not C-h (define-key input-decode-map (kbd "C-h") (kbd "DEL")) ;; Translate C-h to DEL ;; FIXME: Should be in emacs 22, doens't work. (define-key input-decode-map (kbd "M-h") (kbd "M-&lt;DEL&gt;")) ;; Translate M-h to M-DEL ;; (define-key input-decode-map (kbd "&lt;backspace&gt;") 'version) ;; Stop me using backspace for a while ) </code></pre> <p>But this obviously only works with Emacs > 22, due to <code>input-decode-map</code>. </p> <p>Would someone be able to help me find a solution that works in 22, maybe even 21? (Not a priority however). Cheers!</p> <p><strong>Edit: My Solution:</strong></p> <p>It's not quite there yet, but this has solved most of my issues:</p> <pre><code>(setq help-char [f1]) ;; I don't want help when I'm just trying to backspace! (define-key isearch-mode-map "\C-h" 'isearch-delete-char) ;; (define-key isearch-mode-map "\M-h" 'my-isearch-delete-word) (defvar my-overriding-binding-mode-map (let ((map (make-sparse-keymap))) (define-key map [?\C-h] 'delete-backward-char) (define-key map [?\M-h] 'backward-kill-word) map)) (define-minor-mode my-overriding-binding-mode "Personal global key-bindings." :global t) (my-overriding-binding-mode 1) </code></pre> <p>There's probably some caveats for some misbehaving modes that need to be written - I'll do that as I come across them. The only real problem now seems to be <code>M-h</code> in isearch, which I'll post as a seperate question.</p> <p>Thanks again guys, you've been a great help.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload