I'm looking at the codebase of Emacs (for example gnus
codebase) and see that the code indentation style is so weird.
For example, here is source code of the functions gnus-sort-threads-recursive
in module gnus-sum.el.gz
of Emacs 27.2. It's difficult to read the if
statement in line 3 since the condition and the body in next lines are totally unaligned and unordered.
(defun gnus-sort-threads-recursive (threads func)
;; Responsible for sorting the root articles of threads.
(let ((subthread-sort-func (if (eq gnus-subthread-sort-functions ;; why is
'gnus-thread-sort-functions) ;; this
func ;; if-expr
(gnus-make-sort-function ;; so difficult
gnus-subthread-sort-functions)))) ;; to read ???
(sort (mapcar (lambda (thread)
(cons (car thread)
(and (cdr thread)
(gnus-sort-subthreads-recursive
(cdr thread) subthread-sort-func))))
threads)
func)))
If I call indent-region
by Emacs itself to indent this function, then it's much clearer to read.
(defun gnus-sort-threads-recursive (threads func)
;; Responsible for sorting the root articles of threads.
(let ((subthread-sort-func (if (eq gnus-subthread-sort-functions
'gnus-thread-sort-functions)
func
(gnus-make-sort-function
gnus-subthread-sort-functions))))
(sort (mapcar (lambda (thread)
(cons (car thread)
(and (cdr thread)
(gnus-sort-subthreads-recursive
(cdr thread) subthread-sort-func))))
threads)
func)))
I guess it might be due to a historical reason. But I'm curious if anybody can explain why code indentation of the original codebase is so difficult to read?
M-x untabify
to convert TAB chars properly to SPC chars. Then paste the result here.