Cleaned up section creation a bit.

* magit.el (magit-section-hidden-default): New.
(magit-new-section): Only expect type as argument, not a general list
of slots.  Take 'hidden' value from magit-section-hidden-default.
(magit-with-section): Likewise.
(magit-wash-diff): Adapted.
This commit is contained in:
Marius Vollmer 2009-01-25 00:39:03 +02:00
parent 583ecc7a12
commit a6bc339e9c

View file

@ -384,11 +384,13 @@ Many Magit faces inherit from this one by default."
(defvar magit-old-top-section nil)
(defun magit-new-section (title &rest args)
(let* ((s (apply #'make-magit-section
:parent magit-top-section
(defvar magit-section-hidden-default nil)
(defun magit-new-section (title type)
(let* ((s (make-magit-section :parent magit-top-section
:title title
args))
:type type
:hidden magit-section-hidden-default))
(old (and magit-old-top-section
(magit-find-section (magit-section-path s)
magit-old-top-section))))
@ -409,13 +411,10 @@ Many Magit faces inherit from this one by default."
(delq section (magit-section-children parent)))
(setq magit-top-section nil))))
(defmacro magit-with-section (title args &rest body)
(defmacro magit-with-section (title type &rest body)
(declare (indent 2))
(let ((s (gensym)))
`(let* ((,s (magit-new-section ,title ,@(if (and (listp args)
(keywordp (car args)))
args
`(:type ,args))))
`(let* ((,s (magit-new-section ,title ,type))
(magit-top-section ,s))
(setf (magit-section-beginning ,s) (point))
,@body
@ -1211,9 +1210,8 @@ Please see the manual for a complete description of Magit.
(defun magit-wash-diff ()
(cond ((looking-at "^diff")
(magit-with-section
(magit-current-line)
(:type 'diff :hidden magit-hide-diffs)
(let ((magit-section-hidden-default magit-hide-diffs))
(magit-with-section (magit-current-line) 'diff
(let ((file (magit-diff-line-file))
(end (save-excursion
(forward-line) ;; skip over "diff" line
@ -1257,8 +1255,9 @@ Please see the manual for a complete description of Magit.
(magit-set-section-info (list status file file2))
(insert "\t" status-text "\n")
(goto-char end)
(magit-wash-sequence #'magit-wash-hunk)
t))))
(let ((magit-section-hidden-default nil))
(magit-wash-sequence #'magit-wash-hunk))
t)))))
(t
nil)))