Commit b0b7bc7a authored by Jonas Bernoulli's avatar Jonas Bernoulli

Restore treatment of module sections as file sections

The transition from section types to section classes and automatic
inheritance is not complete, making these hacks necessary to restore
some functionality that was lost when the `module' type was created.

Deriving `magit-module-section-map' from `magit-file-section-map'
isn't a hack, that would be necessary even if the transition were
already complete.
parent f3b99797
......@@ -2337,11 +2337,12 @@ Do not confuse this with `magit-diff-scope' (which see)."
(if (memq stype '(staged unstaged tracked untracked))
stype
(pcase stype
(`file (let* ((parent (oref it parent))
(type (oref parent type)))
(if (eq type 'file)
(magit-diff-type parent)
type)))
((or `file `module)
(let* ((parent (oref it parent))
(type (oref parent type)))
(if (memq type '(file module))
(magit-diff-type parent)
type)))
(`hunk (-> it
(oref parent)
(oref parent)
......@@ -2393,6 +2394,8 @@ actually a `diff' but a `diffstat' section."
(`(hunk ,_ ,_ ,_) 'hunk)
(`(file t t nil) 'files)
(`(file ,_ ,_ ,_) 'file)
(`(module t t nil) 'files)
(`(module ,_ ,_ ,_) 'file)
(`(,(or `staged `unstaged `untracked)
nil ,_ ,_) 'list)))))
......@@ -2484,6 +2487,8 @@ are highlighted."
(not (eq this-command 'mouse-drag-region))))
(`(file t) 'magit-diff-file-heading-selection)
(`(file nil) 'magit-diff-file-heading-highlight)
(`(module t) 'magit-diff-file-heading-selection)
(`(module nil) 'magit-diff-file-heading-highlight)
(`(hunk t) 'magit-diff-hunk-heading-selection)
(`(hunk nil) 'magit-diff-hunk-heading-highlight))))
......
......@@ -448,6 +448,7 @@ or, failing that, the abbreviated HEAD commit hash."
(defvar magit-module-section-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map magit-file-section-map)
(unless (featurep 'jkl)
(define-key map "\C-j" 'magit-submodule-visit))
(define-key map [C-return] 'magit-submodule-visit)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment