GNU bug report logs - #13625
24.1; Enable 'package-menu-execute being non-interactive

Previous Next

Package: emacs;

Reported by: Yves Baumes <ybaumes <at> gmail.com>

Date: Mon, 4 Feb 2013 00:20:02 UTC

Severity: normal

Found in version 24.1

Fixed in version 24.4

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #23 received at 13625 <at> debbugs.gnu.org (full text, mbox):

From: Yves Baumes <ybaumes <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 13625 <at> debbugs.gnu.org
Subject: Re: bug#13625: 24.1;
	Enable 'package-menu-execute being non-interactive
Date: Mon, 4 Feb 2013 23:09:40 +0100
Ok! I was stuck, with the `interactive' ... Then here is the revised diff:

=== modified file 'lisp/emacs-lisp/package.el'                                                                          
--- lisp/emacs-lisp/package.el  2013-01-01 09:11:05 +0000                                                               
+++ lisp/emacs-lisp/package.el	2013-02-04 21:49:41 +0000
@@ -1588,7 +1588,7 @@
 	       (length upgrades)
 	       (if (= (length upgrades) 1) "" "s")))))
 
-(defun package-menu-execute ()
+(defun package-menu-execute (&optional dont-query)
   "Perform marked Package Menu actions.
 Packages marked for installation are downloaded and installed;
 packages marked for deletion are removed."
@@ -1611,26 +1611,30 @@
 		 (push (car id) install-list))))
 	(forward-line)))
     (when install-list
-      (if (yes-or-no-p
-	   (if (= (length install-list) 1)
-	       (format "Install package `%s'? " (car install-list))
-	     (format "Install these %d packages (%s)? "
-		     (length install-list)
-		     (mapconcat 'symbol-name install-list ", "))))
+      (if (or
+           dont-query
+           (yes-or-no-p
+            (if (= (length install-list) 1)
+                (format "Install package `%s'? " (car install-list))
+              (format "Install these %d packages (%s)? "
+                      (length install-list)
+                      (mapconcat 'symbol-name install-list ", ")))))
 	  (mapc 'package-install install-list)))
     ;; Delete packages, prompting if necessary.
     (when delete-list
-      (if (yes-or-no-p
-	   (if (= (length delete-list) 1)
-	       (format "Delete package `%s-%s'? "
-		       (caar delete-list)
-		       (cdr (car delete-list)))
-	     (format "Delete these %d packages (%s)? "
-		     (length delete-list)
-		     (mapconcat (lambda (elt)
-				  (concat (car elt) "-" (cdr elt)))
-				delete-list
-				", "))))
+      (if (or
+           dont-query
+           (yes-or-no-p
+            (if (= (length delete-list) 1)
+                (format "Delete package `%s-%s'? "
+                        (caar delete-list)
+                        (cdr (car delete-list)))
+              (format "Delete these %d packages (%s)? "
+                      (length delete-list)
+                      (mapconcat (lambda (elt)
+                                   (concat (car elt) "-" (cdr elt)))
+                                 delete-list
+                                 ", ")))))
 	  (dolist (elt delete-list)
 	    (condition-case-unless-debug err
 		(package-delete (car elt) (cdr elt))

As you wrote in previous emails, every possible call to
`package-menu-execute' remains compatible as is.
And I just needed to add a `t' parameter in my script.
Just perfect. :-)

Regards
Yves


Le 4 févr. 2013 à 20:44, Stefan Monnier a écrit :

>> I've found that whatever you do, an interactive call provide a numeric
>> value of '1'.  Reading the Emacs Lisp Reference Manual, I didn't find
>> a way to negate the boolean value with `interactive'.
> 
> But since it's an optional parameter, you can just not provide it, in
> which case it defaults to nil.
> 
>> -(defun package-menu-execute ()
>> +(defun package-menu-execute (&optional prompt-user)
>                                          ^^^^^^^^^^^
>                                          dont-query
> 
>>   "Perform marked Package Menu actions.
>> Packages marked for installation are downloaded and installed;
>> packages marked for deletion are removed."
>> -  (interactive)
>> +  (interactive "p")
> 
> Leave it as (interactive) which will not provide any argument, so
> dont-query will be nil for interactive calls. And for your own calls,
> you can pass a non-nil argument.
> 
> 
>        Stefan





This bug report was last modified 12 years and 187 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.