When diffing with Git, for most languages, it provides a function name in the chunk header, allowing to get a better grasp on the context, e.g.,
@@ -7,5 +7,6 @@ int main() {
if(condition()) {
task4();
task5();
+ task6();
}
}
For Emacs Lisp, git diff
seems to use some sort of fall-back mode, where apparently the closest line without indentation is used; which usually is part of a docstring, not something like (defun ...
@@ -9,4 +9,5 @@ Last docstring line."
(run-task3)
(when (run-condition)
(run-task4)
- (run-task5)))
+ (run-task5)
+ (run-task6)))
Is it possible to make Git aware of how to identify a useful line to use for the @@
line?
Complete example source
For reference I attach the full source used to produce the examples.
/// run.c
int main() {
// foo
task1();
task2();
task3();
if(condition()) {
task4();
task5();
task6();
}
}
;;; run.el
(defun run-main ()
"1st docstring line.
2nd docstring line.
Last docstring line."
(run-task1)
(run-task2)
(run-task3)
(when (run-condition)
(run-task4)
(run-task5)
(run-task6)))