Hide diffs by default.

* magit.el (magit-new-section): Type rest arg for initializing the new
section structure.
(magit-with-section): Generalize type argument to allow a list of
keyword value pair and pass them to magit-new-section.
(magit-wash-diff): Make diffs hidden by default.
This commit is contained in:
Marius Vollmer 2008-09-08 23:21:01 +03:00
parent 2bf9c19866
commit 4f8dd6f841

View file

@ -303,10 +303,11 @@ Many Magit faces inherit from this one by default."
(defvar magit-old-top-section nil) (defvar magit-old-top-section nil)
(defun magit-new-section (title type) (defun magit-new-section (title &rest args)
(let* ((s (make-magit-section :parent magit-top-section (let* ((s (apply #'make-magit-section
:title title :parent magit-top-section
:type type)) :title title
args))
(old (and magit-old-top-section (old (and magit-old-top-section
(magit-find-section (magit-section-path s) (magit-find-section (magit-section-path s)
magit-old-top-section)))) magit-old-top-section))))
@ -328,10 +329,12 @@ Many Magit faces inherit from this one by default."
(delq section (magit-section-children parent))) (delq section (magit-section-children parent)))
(setq magit-top-section nil)))) (setq magit-top-section nil))))
(defmacro magit-with-section (title type &rest body) (defmacro magit-with-section (title args &rest body)
(declare (indent 2)) (declare (indent 2))
(let ((s (gensym))) (let ((s (gensym)))
`(let* ((,s (magit-new-section ,title ,type)) `(let* ((,s (magit-new-section ,title ,@(if (keywordp (car args))
args
`(:type ,args))))
(magit-top-section ,s)) (magit-top-section ,s))
(setf (magit-section-beginning ,s) (point)) (setf (magit-section-beginning ,s) (point))
,@body ,@body
@ -851,7 +854,7 @@ Please see the manual for a complete description of Magit.
(defun magit-wash-diff () (defun magit-wash-diff ()
(cond ((looking-at "^diff") (cond ((looking-at "^diff")
(magit-with-section (magit-current-line) 'diff (magit-with-section (magit-current-line) (:type 'diff :hidden t)
(let ((file (magit-diff-line-file)) (let ((file (magit-diff-line-file))
(end (save-excursion (end (save-excursion
(forward-line) ;; skip over "diff" line (forward-line) ;; skip over "diff" line