emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/git-commit b3d319786d 14/20: magit-insert-section: Pass al


From: ELPA Syncer
Subject: [nongnu] elpa/git-commit b3d319786d 14/20: magit-insert-section: Pass along keyword arguments to constructor
Date: Sun, 28 Apr 2024 16:03:26 -0400 (EDT)

branch: elpa/git-commit
commit b3d319786dfe674d54baa46aa649b572b6c5738e
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    magit-insert-section: Pass along keyword arguments to constructor
---
 lisp/magit-base.el      | 16 ++++++++--------
 lisp/magit-diff.el      | 46 +++++++++++++++++++++++-----------------------
 lisp/magit-section.el   | 19 ++++++++++---------
 lisp/magit-submodule.el | 17 +++++++++--------
 4 files changed, 50 insertions(+), 48 deletions(-)

diff --git a/lisp/magit-base.el b/lisp/magit-base.el
index 81e7e510a1..e624ebbc2c 100644
--- a/lisp/magit-base.el
+++ b/lisp/magit-base.el
@@ -482,22 +482,22 @@ and delay of your graphical environment or operating 
system."
 
 (defclass magit-file-section (magit-diff-section)
   ((keymap :initform 'magit-file-section-map)
-   (source :initform nil)
-   (header :initform nil)
-   (binary :initform nil)))
+   (source :initform nil :initarg :source)
+   (header :initform nil :initarg :header)
+   (binary :initform nil :initarg :binary)))
 
 (defclass magit-module-section (magit-file-section)
   ((keymap :initform 'magit-module-section-map)
-   (range  :initform nil)))
+   (range  :initform nil :initarg :range)))
 
 (defclass magit-hunk-section (magit-diff-section)
   ((keymap      :initform 'magit-hunk-section-map)
    (refined     :initform nil)
-   (combined    :initform nil)
-   (from-range  :initform nil)
+   (combined    :initform nil :initarg :combined)
+   (from-range  :initform nil :initarg :from-range)
    (from-ranges :initform nil)
-   (to-range    :initform nil)
-   (about       :initform nil)))
+   (to-range    :initform nil :initarg :to-range)
+   (about       :initform nil :initarg :about)))
 
 (setf (alist-get 'file   magit--section-type-alist) 'magit-file-section)
 (setf (alist-get 'module magit--section-type-alist) 'magit-module-section)
diff --git a/lisp/magit-diff.el b/lisp/magit-diff.el
index 97a624fe0d..b48eb1f0c5 100644
--- a/lisp/magit-diff.el
+++ b/lisp/magit-diff.el
@@ -2421,9 +2421,12 @@ section or a child thereof."
 
 (defun magit-diff-insert-file-section
     (file orig status modes rename header binary long-status)
-  (magit-insert-section section
-    (file file (or (equal status "deleted")
-                   (derived-mode-p 'magit-status-mode)))
+  (magit-insert-section
+      ( file file
+        (or (equal status "deleted") (derived-mode-p 'magit-status-mode))
+        :source (and (not (equal orig file)) orig)
+        :header header
+        :binary binary)
     (insert (propertize (format "%-10s %s" status
                                 (if (or (not orig) (equal orig file))
                                     file
@@ -2434,10 +2437,6 @@ section or a child thereof."
           ((or binary long-status)
            (insert (format " (%s)" (if binary "binary" long-status)))))
     (magit-insert-heading)
-    (unless (equal orig file)
-      (oset section source orig))
-    (oset section header header)
-    (oset section binary binary)
     (when modes
       (magit-insert-section (hunk '(chmod))
         (insert modes)
@@ -2528,19 +2527,18 @@ section or a child thereof."
            (combined (length= ranges 3))
            (value    (cons about ranges)))
       (magit-delete-line)
-      (magit-insert-section section (hunk value)
+      (magit-insert-section
+          ( hunk value nil
+            :washer #'magit-diff-paint-hunk
+            :combined combined
+            :from-range (if combined (butlast ranges) (car ranges))
+            :to-range (car (last ranges))
+            :about about)
         (insert (propertize (concat heading "\n")
                             'font-lock-face 'magit-diff-hunk-heading))
         (magit-insert-heading)
         (while (not (or (eobp) (looking-at "^[^-+\s\\]")))
-          (forward-line))
-        (oset section washer #'magit-diff-paint-hunk)
-        (oset section combined combined)
-        (if combined
-            (oset section from-ranges (butlast ranges))
-          (oset section from-range (car ranges)))
-        (oset section to-range (car (last ranges)))
-        (oset section about about)))
+          (forward-line))))
     t))
 
 (defun magit-diff-expansion-threshold (section)
@@ -2643,9 +2641,9 @@ or a ref which is not a branch, then it inserts nothing."
                             'magit-section-secondary-heading)))
       (magit-insert-heading)
       (forward-line)
-      (magit-insert-section section (message)
-        (oset section heading-highlight-face
-              'magit-diff-revision-summary-highlight)
+      (magit-insert-section
+          ( message nil nil
+            :heading-highlight-face 'magit-diff-revision-summary-highlight)
         (let ((beg (point)))
           (forward-line)
           (magit--add-face-text-property
@@ -2674,8 +2672,9 @@ or a ref which is not a branch, then it inserts nothing."
 
 (defun magit-insert-revision-message ()
   "Insert the commit message into a revision buffer."
-  (magit-insert-section section (commit-message)
-    (oset section heading-highlight-face 
'magit-diff-revision-summary-highlight)
+  (magit-insert-section
+      ( commit-message nil nil
+        :heading-highlight-face 'magit-diff-revision-summary-highlight)
     (let ((beg (point))
           (rev magit-buffer-revision))
       (insert (with-temp-buffer
@@ -2746,8 +2745,9 @@ or a ref which is not a branch, then it inserts nothing."
   (let* ((var "core.notesRef")
          (def (or (magit-get var) "refs/notes/commits")))
     (dolist (ref (magit-list-active-notes-refs))
-      (magit-insert-section section (notes ref (not (equal ref def)))
-        (oset section heading-highlight-face 
'magit-diff-hunk-heading-highlight)
+      (magit-insert-section
+          ( notes ref (not (equal ref def))
+            :heading-highlight-face 'magit-diff-hunk-heading-highlight)
         (let ((beg (point))
               (rev magit-buffer-revision))
           (insert (with-temp-buffer
diff --git a/lisp/magit-section.el b/lisp/magit-section.el
index b4f8e6873d..28f282fce1 100644
--- a/lisp/magit-section.el
+++ b/lisp/magit-section.el
@@ -385,9 +385,9 @@ no effect.  This also has no effect for Emacs >= 28, where
    (content  :initform nil)
    (end      :initform nil)
    (hidden   :initform nil)
-   (washer   :initform nil)
+   (washer   :initform nil :initarg :washer)
    (process  :initform nil)
-   (heading-highlight-face :initform nil)
+   (heading-highlight-face :initform nil :initarg :heading-highlight-face)
    (inserter :initform (symbol-value 'magit--current-section-hook))
    (parent   :initform nil :initarg :parent)
    (children :initform nil)))
@@ -1377,16 +1377,16 @@ anything this time around.
 \(fn [NAME] (CLASS &optional VALUE HIDE) &rest BODY)"
   (declare (indent defun)
            (debug ([&optional symbolp]
-                   (&or [("eval" form) &optional form form]
-                        [symbolp &optional form form])
+                   (&or [("eval" form) &optional form form &rest form]
+                        [symbolp &optional form form &rest form])
                    body)))
   (pcase-let* ((bind (and (symbolp (car args))
                           (pop args)))
-               (`((,class ,value ,hide) . ,body) args)
+               (`((,class ,value ,hide . ,args) . ,body) args)
                (obj (cl-gensym "section")))
     `(let* ((,obj (magit-insert-section--create
                    ,(if (eq (car-safe class) 'eval) (cadr class) `',class)
-                   ,value ,hide))
+                   ,value ,hide ,@args))
             (magit-insert-section--current ,obj)
             (magit-insert-section--oldroot
              (or magit-insert-section--oldroot
@@ -1399,7 +1399,7 @@ anything this time around.
          (magit-insert-section--finish ,obj))
        ,obj)))
 
-(defun magit-insert-section--create (class value hide)
+(defun magit-insert-section--create (class value hide &rest args)
   (let (type)
     (if (class-p class)
         (setq type (or (car (rassq class magit--section-type-alist))
@@ -1407,14 +1407,15 @@ anything this time around.
       (setq type class)
       (setq class (or (cdr (assq class magit--section-type-alist))
                       'magit-section)))
-    (let ((obj (funcall
+    (let ((obj (apply
                 class
                 :type type
                 :value value
                 :start (if magit-section-inhibit-markers
                            (point)
                          (point-marker))
-                :parent magit-insert-section--parent)))
+                :parent magit-insert-section--parent
+                args)))
       (oset obj hidden
             (if-let ((value (run-hook-with-args-until-success
                              'magit-section-set-visibility-hook obj)))
diff --git a/lisp/magit-submodule.el b/lisp/magit-submodule.el
index 1d6eb2f0ba..491ba1bbb8 100644
--- a/lisp/magit-submodule.el
+++ b/lisp/magit-submodule.el
@@ -605,18 +605,19 @@ These sections can be expanded to show the respective 
commits."
               (let ((default-directory
                      (expand-file-name (file-name-as-directory module))))
                 (when (file-accessible-directory-p default-directory)
-                  (magit-insert-section sec (magit-module-section module t)
+                  (magit-insert-section
+                      ( magit-module-section module t
+                        :range range)
                     (magit-insert-heading
                       (propertize module
                                   'font-lock-face 'magit-diff-file-heading)
                       ":")
-                    (oset sec range range)
-                    (magit-git-wash
-                        (apply-partially #'magit-log-wash-log 'module)
-                      "-c" "push.default=current" "log" "--oneline" range)
-                    (when (> (point)
-                             (oref sec content))
-                      (delete-char -1))))))))
+                    (let ((pos (point)))
+                      (magit-git-wash
+                          (apply-partially #'magit-log-wash-log 'module)
+                        "-c" "push.default=current" "log" "--oneline" range)
+                      (when (> (point) pos)
+                        (delete-char -1)))))))))
         (magit-cancel-section 'if-empty)
         (insert ?\n)))))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]