Skip to content

Commit 4b6be25

Browse files
committed
Add buttons to warning for update cached recipes
Also, allow prefix arguments to el-get-merge-properties-into-status to specify updating as if doing update or reinstall operations.
1 parent b524367 commit 4b6be25

File tree

2 files changed

+35
-18
lines changed

2 files changed

+35
-18
lines changed

el-get-core.el

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -232,22 +232,23 @@ entry."
232232
(when (y-or-n-p
233233
(format "Really %s `%s'? "
234234
(button-get button 'el-get-pkg-verb) package))
235-
(funcall (button-get button 'el-get-pkg-fun) package))))
235+
(apply (button-get button 'el-get-pkg-fun) package
236+
(button-get button 'el-get-pkg-extra-args)))))
236237

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

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

248-
(el-get-define-pkg-op-button-type 'el-get-install)
249-
(el-get-define-pkg-op-button-type 'el-get-update)
250-
(el-get-define-pkg-op-button-type 'el-get-remove)
248+
(el-get-define-pkg-op-button-type 'el-get-install "install")
249+
(el-get-define-pkg-op-button-type 'el-get-reinstall "reinstall")
250+
(el-get-define-pkg-op-button-type 'el-get-update "update")
251+
(el-get-define-pkg-op-button-type 'el-get-remove "remove")
251252

252253
(define-button-type 'el-get-file-jump
253254
'action (lambda (button) (find-file (button-get button 'el-get-file)))

el-get-status.el

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -337,21 +337,27 @@ a list of operations that would allow a full update."
337337
(error "Package %s is nowhere to be found in el-get status file."
338338
package))))
339339

340-
(defun el-get-merge-properties-into-status (package
341-
operation
342-
&rest keys)
340+
(el-get-define-pkg-op-button-type 'el-get-merge-properties-into-status
341+
"force cached recipe update of")
342+
343+
(defun el-get-merge-properties-into-status (package operation &rest keys)
343344
"Merge updatable properties for package into status file.
344345
345346
PACKAGE is either a package source or name, in which case the
346347
source will be read using `el-get-package-def'. The named
347348
package must already be installed.
348349
349-
Warn about any non-whitelisted properties differing from the
350-
cached values."
350+
Warn about any non-whitelisted for OPERATION properties differing
351+
from the cached values.
352+
353+
Interactively, OPERATION is `update' with prefix arg, `reinstall'
354+
with double prefix arg, or `init' otherwise."
351355
(declare (advertised-calling-convention (package operation) "Oct 2016"))
352356
(interactive
353357
(list (el-get-read-package-with-status "Update cached recipe" "installed")
354-
'init))
358+
(cond ((equal '(16) current-prefix-arg) 'reinstall)
359+
(current-prefix-arg 'update)
360+
(t 'init))))
355361
(let* ((source (el-get-package-or-source package))
356362
(package (plist-get source :name))
357363
(cached (el-get-read-cached-recipe package source)))
@@ -364,8 +370,18 @@ cached values."
364370
(lwarn '(el-get recipe-cache) :warning
365371
(concat "Must %s `%s' to modify its cached recipe\n"
366372
" adding: %s"
367-
" removing: %s")
368-
(mapconcat #'symbol-name required-ops " or ") package
373+
" removing: %s"
374+
(el-get-fmt-button
375+
" Or %s if you know these changes are safe.\n"
376+
"force update the cached recipe"
377+
:type 'el-get-merge-properties-into-status
378+
'el-get-package package 'el-get-pkg-extra-args '(reinstall)))
379+
(mapconcat (lambda (op)
380+
(el-get-fmt-button
381+
"%s" op :type (intern (concat "el-get-" op))
382+
'el-get-package package))
383+
(mapcar #'symbol-name required-ops) " or ")
384+
package
369385
(if no-add (pp-to-string no-add) "()\n")
370386
(if no-rem (pp-to-string no-rem) "()\n"))))))
371387

0 commit comments

Comments
 (0)