>> But diff-mode overrides this binding with diff-mode-shared-map >> where the TAB key is bound to diff-hunk-next, since >> minor-mode-overriding-map-alist takes priority over >> minor-mode-map-alist when diff-mode does this: > > I see. I knew using `minor-mode-overriding-map-alist` in `diff-mode.el` > this way was going to bite us sooner or later. > > Maybe we should use a hook on `read-only-mode` to set/unset > a `diff-mode-read-only` variable so we can add the keymap > (conditionalized on this new `diff-mode-read-only`) to > `minor-mode-map-alist` instead of `minor-mode-overriding-map-alist`. So this is because `minor-mode-map-alist` is not buffer-local. Then this requires changing `(setq buffer-read-only t)` to `(read-only-mode 1)` in diff-related places. Since `read-only-mode` always activates `view-mode` when `view-read-only` is t, it needs let-binding: (let ((view-read-only nil)) (read-only-mode 1)). This will keep the current behavior. Then special-handling of `view-mode` in `diff-mode` is not needed because `view-mode` is higher than `diff-mode-read-only` in `minor-mode-map-alist`, where `diff-mode-read-only` is at the end to not take precedence over `outline-minor-mode`.