Skip to content

Commit 340c71d

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 72be104 commit 340c71d

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
@@ -240,22 +240,23 @@ entry."
240240
(when (y-or-n-p
241241
(format "Really %s `%s'? "
242242
(button-get button 'el-get-pkg-verb) package))
243-
(funcall (button-get button 'el-get-pkg-fun) package))))
243+
(apply (button-get button 'el-get-pkg-fun) package
244+
(button-get button 'el-get-pkg-extra-args)))))
244245

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

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

256-
(el-get-define-pkg-op-button-type 'el-get-install)
257-
(el-get-define-pkg-op-button-type 'el-get-update)
258-
(el-get-define-pkg-op-button-type 'el-get-remove)
256+
(el-get-define-pkg-op-button-type 'el-get-install "install")
257+
(el-get-define-pkg-op-button-type 'el-get-reinstall "reinstall")
258+
(el-get-define-pkg-op-button-type 'el-get-update "update")
259+
(el-get-define-pkg-op-button-type 'el-get-remove "remove")
259260

260261
(define-button-type 'el-get-file-jump
261262
'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
@@ -336,20 +336,26 @@ a list of operations that would allow a full update."
336336
(error "Package %s is nowhere to be found in el-get status file."
337337
package))))
338338

339-
(defun el-get-merge-properties-into-status (package
340-
operation
341-
&rest keys)
339+
(el-get-define-pkg-op-button-type 'el-get-merge-properties-into-status
340+
"force cached recipe update of")
341+
342+
(defun el-get-merge-properties-into-status (package operation &rest keys)
342343
"Merge updatable properties for package into status file.
343344
344345
PACKAGE is either a package source or name, in which case the
345346
source will be read using `el-get-package-def'. The named
346347
package must already be installed.
347348
348-
Warn about any non-whitelisted properties differing from the
349-
cached values."
349+
Warn about any non-whitelisted for OPERATION properties differing
350+
from the cached values.
351+
352+
Interactively, OPERATION is `update' with prefix arg, `reinstall'
353+
with double prefix arg, or `init' otherwise."
350354
(interactive
351355
(list (el-get-read-package-with-status "Update cached recipe" "installed")
352-
'init))
356+
(cond ((equal '(16) current-prefix-arg) 'reinstall)
357+
(current-prefix-arg 'update)
358+
(t 'init))))
353359
(let* ((source (el-get-package-or-source package))
354360
(package (plist-get source :name))
355361
(cached (el-get-read-cached-recipe package source)))
@@ -362,8 +368,18 @@ cached values."
362368
(lwarn '(el-get recipe-cache) :warning
363369
(concat "Must %s `%s' to modify its cached recipe\n"
364370
" adding: %s"
365-
" removing: %s")
366-
(mapconcat #'symbol-name required-ops " or ") package
371+
" removing: %s"
372+
(el-get-fmt-button
373+
" Or %s if you know these changes are safe.\n"
374+
"force update the cached recipe"
375+
:type 'el-get-merge-properties-into-status
376+
'el-get-package package 'el-get-pkg-extra-args '(reinstall)))
377+
(mapconcat (lambda (op)
378+
(el-get-fmt-button
379+
"%s" op :type (intern (concat "el-get-" op))
380+
'el-get-package package))
381+
(mapcar #'symbol-name required-ops) " or ")
382+
package
367383
(if no-add (pp-to-string no-add) "()\n")
368384
(if no-rem (pp-to-string no-rem) "()\n"))))))
369385

0 commit comments

Comments
 (0)