Skip to content

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

Open
@phil-s

Description

@phil-s
    ;; 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions