;; 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:
(define-key map (kbd "TAB") 'indent-for-tab-command)
I can see that the original code correctly used TAB (\t) instead of <tab> ([tab]) and it was later changed (commit 3699aca); but I strongly suspect that change was made for purely aesthetic purposes, as it's a bug.
Terminals don't send <tab> events; they only deal with TAB. This is why Emacs (a) translates <tab> to TAB, and then (b) uses TAB consistently for binding keys (and certainly the referenced c-mode-map binds TAB and not <tab>). This convention ensures that GUI and terminal Emacs always do the same thing.
With the current code, C-h k TAB tells us:
<tab> runs the command indent-for-tab-command in GUI frames
TAB runs the command c-indent-line-or-region in terminal frames
That last line should be:
I can see that the original code correctly used
TAB(\t) instead of<tab>([tab]) and it was later changed (commit 3699aca); but I strongly suspect that change was made for purely aesthetic purposes, as it's a bug.Terminals don't send
<tab>events; they only deal withTAB. This is why Emacs (a) translates<tab>toTAB, and then (b) usesTABconsistently for binding keys (and certainly the referencedc-mode-mapbindsTABand not<tab>). This convention ensures that GUI and terminal Emacs always do the same thing.With the current code,
C-h k TABtells us:<tab> runs the command indent-for-tab-commandin GUI framesTAB runs the command c-indent-line-or-regionin terminal frames