Commit 537ff524 authored by Ryan C. Thompson's avatar Ryan C. Thompson

Add function el-get-plist-get-with-default

It encapsulates the following common pattern, used several times in
el-get to allow recipe properties to override defaults if present:

(if (plist-member plist prop)
    (plist-get plist prop)
  default)
parent c9944fda
......@@ -335,7 +335,7 @@ makes it easier to conditionally splice a command into the list.
(args (if shell
(mapcar #'shell-quote-argument (plist-get c :args))
(plist-get c :args)))
(sync (if (plist-member c :sync) (plist-get c :sync)
(sync (el-get-plist-get-with-default c :sync
el-get-default-process-sync))
(stdin (plist-get c :stdin))
(default-directory (if cdir
......@@ -430,4 +430,16 @@ out if it's nil."
name))
command)))))
(defun el-get-plist-get-with-default (plist prop def)
"Same as (plist-get PLIST PROP), but falls back to DEF.
Specifically, if (plist-member PLIST PROP) is nil, then returns
DEF instead. Note that having a property set to nil is not the
same as having it unset."
(if (plist-member plist prop)
(plist-get plist prop)
def))
(put 'el-get-plist-get-with-default 'lisp-indent-function
(get 'prog2 'lisp-indent-function))
(provide 'el-get-core)
......@@ -51,9 +51,8 @@ found."
(not submodule-prop)))
(checkout (or (plist-get source :checkout)
(plist-get source :checksum)))
(shallow (if (plist-member source :shallow)
(plist-get source :shallow)
el-get-git-shallow-clone))
(shallow (el-get-plist-get-with-default source :shallow
el-get-git-shallow-clone))
(clone-args (append '("--no-pager" "clone")
(when shallow '("--depth" "1"))
(cond
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment