Skip to content

Commit

Permalink
Change core-configuration-layer.el to not use obsolete defmethod
Browse files Browse the repository at this point in the history
  • Loading branch information
eklitzke authored and smile13241324 committed Jan 3, 2022
1 parent faaf87a commit 4625745
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions core/core-configuration-layer.el
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ subdirectory of ROOT is used."
"Boolean to track whether layers.el has been loaded."))
"A configuration layer.")

(defmethod cfgl-layer-owned-packages ((layer cfgl-layer) &optional props)
(cl-defmethod cfgl-layer-owned-packages ((layer cfgl-layer) &optional props)
"Return the list of owned packages by LAYER.
If PROPS is non-nil then return packages as lists with their properties.
LAYER has to be installed for this method to work properly."
Expand All @@ -214,11 +214,11 @@ LAYER has to be installed for this method to work properly."
(when (eq (oref layer :name) (car (oref pkg :owners))) x)))
(cfgl-layer-get-packages layer props))))

(defmethod cfgl-layer-owned-packages ((layer nil) &optional props)
(cl-defmethod cfgl-layer-owned-packages ((layer null) &optional props)
"Accept nil as argument and return nil."
nil)

(defmethod cfgl-layer-get-shadowing-layers ((layer cfgl-layer))
(cl-defmethod cfgl-layer-get-shadowing-layers ((layer cfgl-layer))
"Return the list of used layers that shadow LAYER."
(let ((rank (cl-position (oref layer :name) configuration-layer--used-layers))
(shadow-candidates (oref layer :can-shadow))
Expand All @@ -239,7 +239,7 @@ LAYER has to be installed for this method to work properly."
shadow-candidates))
shadowing-layers))

(defmethod cfgl-layer-get-packages ((layer cfgl-layer) &optional props)
(cl-defmethod cfgl-layer-get-packages ((layer cfgl-layer) &optional props)
"Return the list of packages for LAYER.
If PROPS is non-nil then return packages as lists along with their properties."
(let ((all (eq 'all (oref layer :selected-packages))))
Expand Down Expand Up @@ -308,15 +308,15 @@ If PROPS is non-nil then return packages as lists along with their properties."
:documentation
"Packages that must be enabled for this package to be enabled.")))

(defmethod cfgl-package-toggled-p ((pkg cfgl-package) &optional inhibit-messages)
(cl-defmethod cfgl-package-toggled-p ((pkg cfgl-package) &optional inhibit-messages)
"Evaluate the `toggle' slot of passed PKG.
If INHIBIT-MESSAGES is non nil then any message emitted by the toggle evaluation
is ignored."
(let ((message-log-max (unless inhibit-messages message-log-max))
(toggle (oref pkg :toggle)))
(eval toggle)))

(defmethod cfgl-package-reqs-satisfied-p ((pkg cfgl-package) &optional inhibit-messages)
(cl-defmethod cfgl-package-reqs-satisfied-p ((pkg cfgl-package) &optional inhibit-messages)
"Check if requirements of a package are all enabled.
If INHIBIT-MESSAGES is non nil then any message emitted by the toggle evaluation
is ignored."
Expand All @@ -327,7 +327,7 @@ is ignored."
(cfgl-package-enabled-p pkg-obj inhibit-messages))))
(oref pkg :requires)))))

(defmethod cfgl-package-enabled-p ((pkg cfgl-package) &optional inhibit-messages)
(cl-defmethod cfgl-package-enabled-p ((pkg cfgl-package) &optional inhibit-messages)
"Check if a package is enabled.
This checks the excluded property, evaluates the toggle, if any, and recursively
checks whether dependent packages are also enabled.
Expand All @@ -337,18 +337,18 @@ is ignored."
(cfgl-package-reqs-satisfied-p pkg inhibit-messages)
(cfgl-package-toggled-p pkg inhibit-messages)))

(defmethod cfgl-package-used-p ((pkg cfgl-package))
(cl-defmethod cfgl-package-used-p ((pkg cfgl-package))
"Return non-nil if PKG is a used package."
(and (not (null (oref pkg :owners)))
(not (oref pkg :excluded))
(cfgl-package-enabled-p pkg t)))

(defmethod cfgl-package-distant-p ((pkg cfgl-package))
(cl-defmethod cfgl-package-distant-p ((pkg cfgl-package))
"Return non-nil if PKG is a distant package (i.e. not built-in Emacs)."
(and (not (memq (oref pkg :location) '(built-in site local)))
(not (stringp (oref pkg :location)))))

(defmethod cfgl-package-get-safe-owner ((pkg cfgl-package))
(cl-defmethod cfgl-package-get-safe-owner ((pkg cfgl-package))
"Safe method to return the name of the layer which owns PKG."
;; The owner of a package is the first *used* layer in `:owners' slot.
;; Note: for packages in `configuration-layer--used-packages' the owner is
Expand All @@ -360,7 +360,7 @@ is ignored."
(when (configuration-layer/layer-used-p (car layers))
(car layers))))

(defmethod cfgl-package-set-property ((pkg cfgl-package) slot value)
(cl-defmethod cfgl-package-set-property ((pkg cfgl-package) slot value)
"Set SLOT to the given VALUE for the package PKG.
If `configuration-layer--package-properties-read-onlyp' is non-nil then VALUE
is not set for the given SLOT."
Expand Down

0 comments on commit 4625745

Please sign in to comment.