emacs-php / emacs-php/php-mode

(define-key map [tab] 'indent-for-tab-command) is a bug

Open
#688 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Emacs Lisp
Stars
602
Forks
117
Avg merge
12h 54m
Merged PRs (30d)
3

Description

```el
;; Use the Emacs standard indentation binding. This may upset c-mode
;; which does not follow this at the moment, but I see no better
;; choice.
(define-key map [tab] 'indent-for-tab-command)
```

That last line should be:

```el
(define-key map (kbd "TAB") 'indent-for-tab-command)
```

I can see that the original code correctly used `TAB` (`\t`) instead of `` (`[tab]`) and it was later changed (commit 3699acab27c92044f4c7b618c75b9194fd005e0d); but I strongly suspect that change was made for purely aesthetic purposes, as it's a bug.

Terminals don't send `` events; they only deal with `TAB`. This is why Emacs (a) translates `` to `TAB`, and then (b) uses `TAB` consistently for binding keys (and certainly the referenced `c-mode-map` binds `TAB` and not ``). This convention ensures that GUI and terminal Emacs always do the same thing.

With the current code, `C-h k TAB` tells us:
* ` runs the command indent-for-tab-command` in GUI frames
* `TAB runs the command c-indent-line-or-region` in terminal frames

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.