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) (defvar magit-old-top-section nil)
(defun magit-new-section (title &rest args) (defvar magit-section-hidden-default nil)
(let* ((s (apply #'make-magit-section
:parent magit-top-section (defun magit-new-section (title type)
(let* ((s (make-magit-section :parent magit-top-section
:title title :title title
args)) :type type
:hidden magit-section-hidden-default))
(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))))
@ -409,13 +411,10 @@ 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 args &rest body) (defmacro magit-with-section (title type &rest body)
(declare (indent 2)) (declare (indent 2))
(let ((s (gensym))) (let ((s (gensym)))
`(let* ((,s (magit-new-section ,title ,@(if (and (listp args) `(let* ((,s (magit-new-section ,title ,type))
(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
@ -1211,9 +1210,8 @@ 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 (let ((magit-section-hidden-default magit-hide-diffs))
(magit-current-line) (magit-with-section (magit-current-line) 'diff
(:type 'diff :hidden magit-hide-diffs)
(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
@ -1257,8 +1255,9 @@ Please see the manual for a complete description of Magit.
(magit-set-section-info (list status file file2)) (magit-set-section-info (list status file file2))
(insert "\t" status-text "\n") (insert "\t" status-text "\n")
(goto-char end) (goto-char end)
(magit-wash-sequence #'magit-wash-hunk) (let ((magit-section-hidden-default nil))
t)))) (magit-wash-sequence #'magit-wash-hunk))
t)))))
(t (t
nil))) nil)))