Skip to content

Commit

Permalink
magit-section: Ensure internal slots are only set carefully
Browse files Browse the repository at this point in the history
Certain slots should only be set using dedicated code.
This makes it impossible to set them by passing these
initargs to `magit-insert-section'.
  • Loading branch information
tarsius committed Apr 28, 2024
1 parent 8ece720 commit f5189a6
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions lisp/magit-section.el
Original file line number Diff line number Diff line change
Expand Up @@ -380,15 +380,15 @@ no effect. This also has no effect for Emacs >= 28, where
(defclass magit-section ()
((type :initform nil :initarg :type)
(keymap :initform nil)
(value :initform nil :initarg :value)
(start :initform nil :initarg :start)
(value :initform nil)
(start :initform nil)
(content :initform nil)
(end :initform nil)
(hidden :initform nil)
(washer :initform nil :initarg :washer)
(inserter :initform (symbol-value 'magit--current-section-hook))
(heading-highlight-face :initform nil :initarg :heading-highlight-face)
(parent :initform nil :initarg :parent)
(parent :initform nil)
(children :initform nil)))

;;; Mode
Expand Down Expand Up @@ -1406,15 +1406,10 @@ anything this time around.
(setq type class)
(setq class (or (cdr (assq class magit--section-type-alist))
'magit-section)))
(let ((obj (apply
class
:type type
:value value
:start (if magit-section-inhibit-markers
(point)
(point-marker))
:parent magit-insert-section--parent
args)))
(let ((obj (apply class :type type args)))
(oset obj value value)
(oset obj parent magit-insert-section--parent)
(oset obj start (if magit-section-inhibit-markers (point) (point-marker)))
(oset obj hidden
(if-let ((value (run-hook-with-args-until-success
'magit-section-set-visibility-hook obj)))
Expand Down

0 comments on commit f5189a6

Please sign in to comment.