Codebase list magit / 6e8dbe3
magit-insert-headers: don't assume headers come first Previously a function that uses `magit-insert-headers' had to be the first function on a section hook. Now it can anywhere on a hook, which allows inserting multiple separate groups of headers, or to display some other information first. Jonas Bernoulli 6 years ago
1 changed file(s) with 8 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
785785 (magit-maybe-make-margin-overlay)
786786 (setf (magit-section-content magit-insert-section--current) (point-marker)))
787787
788 (defvar magit-insert-headers-hook nil "For internal use only.")
788 (defvar magit-insert-headers--hook nil "For internal use only.")
789 (defvar magit-insert-headers--beginning nil "For internal use only.")
789790
790791 (defun magit-insert-headers (hooks)
791792 (let ((magit-insert-section-hook
793794 (if (listp magit-insert-section-hook)
794795 magit-insert-section-hook
795796 (list magit-insert-section-hook))))
796 (magit-insert-headers-hook hooks)
797 (magit-insert-headers--hook hooks)
797798 wrapper)
798 (while (and (setq wrapper (pop magit-insert-headers-hook))
799 (= (point) (point-min)))
799 (setq magit-insert-headers--beginning (point))
800 (while (and (setq wrapper (pop magit-insert-headers--hook))
801 (= (point) magit-insert-headers--beginning))
800802 (funcall wrapper))))
801803
802804 (defun magit-insert-remaining-headers ()
803 (if (= (point) (point-min))
805 (if (= (point) magit-insert-headers--beginning)
804806 (magit-cancel-section)
805807 (magit-insert-heading)
806808 (remove-hook 'magit-insert-section-hook 'magit-insert-remaining-headers)
807 (mapc #'funcall magit-insert-headers-hook)
809 (mapc #'funcall magit-insert-headers--hook)
808810 (insert "\n")))
809811
810812 (defun magit-insert-child-count (section)