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:
parent
583ecc7a12
commit
a6bc339e9c
1 changed files with 59 additions and 60 deletions
27
magit.el
27
magit.el
|
@ -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)))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue