Skip to content

Commit

Permalink
Add buttons to warning for update cached recipes
Browse files Browse the repository at this point in the history
Also, allow prefix arguments to el-get-merge-properties-into-status to
specify updating as if doing update or reinstall operations.
  • Loading branch information
npostavs committed Oct 18, 2015
1 parent 61d2ba2 commit d7a5162
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 18 deletions.
21 changes: 11 additions & 10 deletions el-get-core.el
Original file line number Diff line number Diff line change
Expand Up @@ -232,22 +232,23 @@ entry."
(when (y-or-n-p
(format "Really %s `%s'? "
(button-get button 'el-get-pkg-verb) package))
(funcall (button-get button 'el-get-pkg-fun) package))))
(apply (button-get button 'el-get-pkg-fun) package
(button-get button 'el-get-pkg-extra-args)))))

(define-button-type 'el-get-pkg-op
'action #'el-get-pkg-op-button-action
'follow-link t)

(defun el-get-define-pkg-op-button-type (operation)
(let ((verb (replace-regexp-in-string "\\`el-get-" "" (symbol-name operation))))
(define-button-type operation :supertype 'el-get-pkg-op
'el-get-pkg-fun operation
'el-get-pkg-verb verb
'help-echo (format "mouse-2, RET: %s package" verb))))
(defun el-get-define-pkg-op-button-type (operation verb)
(define-button-type operation :supertype 'el-get-pkg-op
'el-get-pkg-fun operation
'el-get-pkg-verb verb
'help-echo (format "mouse-2, RET: %s package" verb)))

(el-get-define-pkg-op-button-type 'el-get-install)
(el-get-define-pkg-op-button-type 'el-get-update)
(el-get-define-pkg-op-button-type 'el-get-remove)
(el-get-define-pkg-op-button-type 'el-get-install "install")
(el-get-define-pkg-op-button-type 'el-get-reinstall "reinstall")
(el-get-define-pkg-op-button-type 'el-get-update "update")
(el-get-define-pkg-op-button-type 'el-get-remove "remove")

(define-button-type 'el-get-file-jump
'action (lambda (button) (find-file (button-get button 'el-get-file)))
Expand Down
32 changes: 24 additions & 8 deletions el-get-status.el
Original file line number Diff line number Diff line change
Expand Up @@ -337,21 +337,27 @@ a list of operations that would allow a full update."
(error "Package %s is nowhere to be found in el-get status file."
package))))

(defun el-get-merge-properties-into-status (package
operation
&rest keys)
(el-get-define-pkg-op-button-type 'el-get-merge-properties-into-status
"force cached recipe update of")

(defun el-get-merge-properties-into-status (package operation &rest keys)
"Merge updatable properties for package into status file.
PACKAGE is either a package source or name, in which case the
source will be read using `el-get-package-def'. The named
package must already be installed.
Warn about any non-whitelisted properties differing from the
cached values."
Warn about any non-whitelisted for OPERATION properties differing
from the cached values.
Interactively, OPERATION is `update' with prefix arg, `reinstall'
with double prefix arg, or `init' otherwise."
(declare (advertised-calling-convention (package operation) "Oct 2016"))
(interactive
(list (el-get-read-package-with-status "Update cached recipe" "installed")
'init))
(cond ((equal '(16) current-prefix-arg) 'reinstall)
(current-prefix-arg 'update)
(t 'init))))
(let* ((source (el-get-package-or-source package))
(package (plist-get source :name))
(cached (el-get-read-cached-recipe package source)))
Expand All @@ -364,8 +370,18 @@ cached values."
(lwarn '(el-get recipe-cache) :warning
(concat "Must %s `%s' to modify its cached recipe\n"
" adding: %s"
" removing: %s")
(mapconcat #'symbol-name required-ops " or ") package
" removing: %s"
(el-get-fmt-button
" Or %s if you know these changes are safe.\n"
"force update the cached recipe"
:type 'el-get-merge-properties-into-status
'el-get-package package 'el-get-pkg-extra-args 'reinstall))
(mapconcat (lambda (op)
(el-get-fmt-button
"%s" op :type (intern (concat "el-get-" op))
'el-get-package package))
(mapcar #'symbol-name required-ops) " or ")
package
(if no-add (pp-to-string no-add) "()\n")
(if no-rem (pp-to-string no-rem) "()\n"))))))

Expand Down

0 comments on commit d7a5162

Please sign in to comment.