all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Yves Baumes <ybaumes@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 13625@debbugs.gnu.org
Subject: bug#13625: 24.1; Enable 'package-menu-execute being non-interactive
Date: Mon, 4 Feb 2013 18:59:22 +0100	[thread overview]
Message-ID: <9FBE5450-EBAD-4826-80F8-8B28ACBE326D@gmail.com> (raw)
In-Reply-To: <jwvehgwjfln.fsf-monnier+emacs@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 3948 bytes --]


Le 4 févr. 2013 à 16:13, Stefan Monnier a écrit :

> Maybe the best option here is to add an optional `dont-query' argument.

I've fiddled around a little bit, so tell me if my reasoning is ok.
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'. As a matter
of fact I would suggest that `dont-query' must not be a good name since its value
would be 'true' when the function is called interactively while we want the user
to be queried in that case.

I made my modification with `prompt-user' as a parameter name.
One could think as another alternative, such as `query-user'.
Would it be more appropriate? I can't tell which one sounds better actually.
I am not fluent in english.. :-/

So here is the 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 17:17:41 +0000
@@ -1588,11 +1588,11 @@
 	       (length upgrades)
 	       (if (= (length upgrades) 1) "" "s")))))
 
-(defun package-menu-execute ()
+(defun package-menu-execute (&optional prompt-user)
   "Perform marked Package Menu actions.
 Packages marked for installation are downloaded and installed;
 packages marked for deletion are removed."
-  (interactive)
+  (interactive "p")
   (unless (derived-mode-p 'package-menu-mode)
     (error "The current buffer is not in Package Menu mode"))
   (let (install-list delete-list cmd id)
@@ -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
+           (not prompt-user)
+           (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
+           (not prompt-user)
+           (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))


The new code in this patch negates the `prompt-user' value since we want to
apply the changes when the user is not prompted *or* in the case he must be
prompted then he must reply 'yes'.

Maybe a good Changelog line could be:
"* emacs-lisp/package.el(package-menu-execute): Don't prompt for the user when `package-menu-execute' is called non-interactively."

Tell me if I forget something, or if something is wrong for you.

Regards
Yves






[-- Attachment #2: Type: text/html, Size: 8474 bytes --]

  reply	other threads:[~2013-02-04 17:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-03 23:49 bug#13625: 24.1; Enable 'package-menu-execute being non-interactive Yves Baumes
2013-02-04  3:39 ` Stefan Monnier
2013-02-04 11:18   ` Yves Baumes
2013-02-04 15:13     ` Stefan Monnier
2013-02-04 17:59       ` Yves Baumes [this message]
2013-02-04 19:44         ` Stefan Monnier
2013-02-04 22:09           ` Yves Baumes
2013-02-05 16:38 ` bug#13625: Rép : " Yves Baumes
2013-02-13  5:01   ` Glenn Morris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9FBE5450-EBAD-4826-80F8-8B28ACBE326D@gmail.com \
    --to=ybaumes@gmail.com \
    --cc=13625@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.