From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Kost Subject: Re: guix.el: Key bindings for a "package list" Date: Sat, 06 Sep 2014 20:45:41 +0400 Message-ID: <87lhpw66kq.fsf@gmail.com> References: <87a96e7bu3.fsf@gmail.com> <87egvq1nj2.fsf@gnu.org> <87y4ty5jl9.fsf@gmail.com> <8738c5vmuv.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48680) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XQJ7Z-0008Lo-JY for guix-devel@gnu.org; Sat, 06 Sep 2014 12:46:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XQJ7Q-00080I-DS for guix-devel@gnu.org; Sat, 06 Sep 2014 12:45:53 -0400 In-Reply-To: <8738c5vmuv.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Fri, 05 Sep 2014 22:22:32 +0200") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: guix-devel@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ludovic Court=C3=A8s (2014-09-06 00:22 +0400) wrote: > Alex Kost skribis: > >> Ludovic Court=C3=A8s (2014-09-05 12:26 +0400) wrote: >> >>> Alex Kost skribis: >>> >>>> Hello, >>>> >>>> I would like to know people's opinions about default key bindings. >>>> >>>> Currently in a buffer with a list of packages we have: "u"/"U" to >>>> unmark/unmark all. But it leaves no room for marking for upgrade and I >>>> just bound it to "^" which is not very good. >>>> >>>> So what about combining "unmark"/"unmark all" into one key and use >>>> either: >>>> >>>> 1. "U" - unmark ("C-u U" - unmark all); >>>> "u" - mark for upgrading. >>>> >>>> 2. "u" - unmark ("C-u u" - unmark all); >>>> "U" - mark for upgrade. Should it also require (for consistency) to >>>> use upper-case "I"/"D" for marking for installing/deletion? >>> >>> I=E2=80=99m hesitant, but I would vote for #2. I don=E2=80=99t think I= and D are needed >>> though. >> >> I prefer this variant as well: "u" is a too common binding for unmarking >> in Emacs (it is used in dired, buffer-menu, ibuffer, package-menu, ...). >> So unmarking should probably stay on "u" (and unmark all with prefix). > > Yes. > >>>> Also should there be a command to mark all obsolete packages for >>>> upgrading? If so, what key should it be bound to? (perhaps my favouri= te >>>> "^"). >>> >>> Actually this is what U does in package.el. But I=E2=80=99m fine with = ^ here. >> >> Taylan suggested "C-u U" for this one. And I think it would be perfect, >> but... >> >> Let's say a user has both "foo-1.0:out" and "foo-1.0:doc" installed and >> one day they become obsolete. He decides to upgrade only "out" for some >> reason. May there exist such a situation? > > Ooh. Well, why not? > >> If so, then I think "C-u U" should be used to specify a particular >> output for upgrading. Actually I implemented such specifying of outputs >> for installing and deletion ("i"/"d") but not for upgrading (I don't >> remember why). > > OK. Then I=E2=80=99m fine with ^. OK, so the summary is: - "u" to unmark ("C-u u" to unmark all); - "i" to mark for installing "out" of the current package ("C-u i" to prompt for outputs to install); - "d" to mark for deleting all outputs of the current package ("C-u d" to prompt for outputs to delete); - "U" to mark for upgrade all outputs of the current package ("C-u U" to prompt for outputs to upgrade); - "^" to mark all obsolete packages for upgrade. And here is a patch with all changes. Perhaps it would be better to split it into several commits or is it OK to push it like this? --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-emacs-Improve-key-bindings-for-marking-the-packages.patch >From b3f3e4b900f4a2d97a10410abe2561d9d1fc137a Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Sat, 6 Sep 2014 18:00:45 +0400 Subject: [PATCH] emacs: Improve key bindings for marking the packages. * emacs/guix-list.el: Use "U" to upgrade the current package, "^" to upgrade all. (guix-list-unmark): With prefix, mark all. (guix-package-list-mark-outputs): New procedure. (guix-package-list-mark-install, guix-package-list-mark-delete) (guix-package-list-mark-upgrade): Use it. (guix-package-list-mark-upgrades): New command. * doc/emacs.texi: Update the manual accordingly. --- doc/emacs.texi | 16 +++++---- emacs/guix-list.el | 98 +++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 76 insertions(+), 38 deletions(-) diff --git a/doc/emacs.texi b/doc/emacs.texi index 55feb1b..7616c8f 100644 --- a/doc/emacs.texi +++ b/doc/emacs.texi @@ -163,11 +163,9 @@ Mark the current entry. @item M Mark all entries. @item u -Unmark the current entry. +Unmark the current entry (with prefix, unmark all entries). @item @key{DEL} Unmark backward. -@item U -Unmark all entries. @item S Sort entries by a specified column. @end table @@ -179,12 +177,16 @@ A ``package-list'' buffer additionally provides the following bindings: Describe marked packages (display available information in a ``package-info'' buffer). @item i -Mark a package for installation (with prefix, prompt for output(s) to -install). +Mark "out" of the current package for installation (with prefix, prompt +for output(s) to install). @item d -Mark a package for deletion. +Mark all installed outputs of the current package for deletion (with +prefix, prompt for output(s) to delete). +@item U +Mark all installed outputs of the current package for upgrading (with +prefix, prompt for output(s) to upgrade). @item ^ -Mark a package for upgrading. +Mark all obsolete packages for upgrading. @item x Execute actions on marked packages. @end table diff --git a/emacs/guix-list.el b/emacs/guix-list.el index 08fb3cb..8d9b231 100644 --- a/emacs/guix-list.el +++ b/emacs/guix-list.el @@ -303,10 +303,13 @@ Interactively, put a general mark on all lines." (interactive '(general)) (guix-list-for-each-line #'guix-list-mark mark-name)) -(defun guix-list-unmark () - "Unmark the current line and move to the next line." - (interactive) - (guix-list-mark 'empty t)) +(defun guix-list-unmark (&optional arg) + "Unmark the current line and move to the next line. +With ARG, unmark all lines." + (interactive "P") + (if arg + (guix-list-unmark-all) + (guix-list-mark 'empty t))) (defun guix-list-unmark-backward () "Move up one line and unmark it." @@ -344,7 +347,6 @@ Same as `tabulated-list-sort', but also restore marks after sorting." (define-key map (kbd "*") 'guix-list-mark) (define-key map (kbd "M") 'guix-list-mark-all) (define-key map (kbd "u") 'guix-list-unmark) - (define-key map (kbd "U") 'guix-list-unmark-all) (define-key map (kbd "DEL") 'guix-list-unmark-backward) (define-key map [remap tabulated-list-sort] 'guix-list-sort) map) @@ -478,8 +480,9 @@ likely)." (define-key map (kbd "RET") 'guix-package-list-describe) (define-key map (kbd "x") 'guix-package-list-execute) (define-key map (kbd "i") 'guix-package-list-mark-install) - (define-key map (kbd "^") 'guix-package-list-mark-upgrade) - (define-key map (kbd "d") 'guix-package-list-mark-delete)) + (define-key map (kbd "d") 'guix-package-list-mark-delete) + (define-key map (kbd "U") 'guix-package-list-mark-upgrade) + (define-key map (kbd "^") 'guix-package-list-mark-upgrades)) (defun guix-package-list-get-name (name entry) "Return NAME of the package ENTRY. @@ -505,24 +508,33 @@ Colorize it with `guix-package-list-installed' or (eq guix-search-type 'generation)) (error "Action marks are disabled for lists of 'generation packages'"))) +(defun guix-package-list-mark-outputs (mark default + &optional prompt available) + "Mark the current package with MARK and move to the next line. +If PROMPT is non-nil, use it to ask a user for outputs from +AVAILABLE list, otherwise mark all DEFAULT outputs." + (let ((outputs (if prompt + (guix-completing-read-multiple + prompt available nil t) + default))) + (apply #'guix-list-mark mark t outputs))) + (defun guix-package-list-mark-install (&optional arg) "Mark the current package for installation and move to the next line. With ARG, prompt for the outputs to install (several outputs may be separated with \",\")." (interactive "P") (guix-package-list-marking-check) - (let* ((entry (guix-list-current-entry)) - (available (guix-get-key-val entry 'outputs)) + (let* ((entry (guix-list-current-entry)) + (all (guix-get-key-val entry 'outputs)) (installed (guix-get-installed-outputs entry)) - (to-install (if arg - (guix-completing-read-multiple - "Output(s) to install: " available nil t) - '("out"))) - (to-install (cl-set-difference to-install installed - :test #'string=))) - (if to-install - (apply #'guix-list-mark 'install t to-install) - (user-error "This package is already installed")))) + (available (cl-set-difference all installed :test #'string=))) + (or available + (user-error "This package is already installed")) + (guix-package-list-mark-outputs + 'install '("out") + (and arg "Output(s) to install: ") + available))) (defun guix-package-list-mark-delete (&optional arg) "Mark the current package for deletion and move to the next line. @@ -534,23 +546,47 @@ be separated with \",\")." (installed (guix-get-installed-outputs entry))) (or installed (user-error "This package is not installed")) - (let ((to-delete (when arg - (guix-completing-read-multiple - "Output(s) to delete: " installed nil t)))) - (if to-delete - (apply #'guix-list-mark 'delete t to-delete) - (guix-package-list-mark-delete-simple))))) - -(defun guix-package-list-mark-upgrade () - "Mark the current package for upgrading and move to the next line." - (interactive) + (guix-package-list-mark-outputs + 'delete installed + (and arg "Output(s) to delete: ") + installed))) + +(defun guix-package-list-mark-upgrade (&optional arg) + "Mark the current package for upgrading and move to the next line. +With ARG, prompt for the outputs to upgrade (several outputs may +be separated with \",\")." + (interactive "P") (guix-package-list-marking-check) - (let ((entry (guix-list-current-entry))) - (or (guix-get-installed-outputs entry) + (let* ((entry (guix-list-current-entry)) + (installed (guix-get-installed-outputs entry))) + (or installed (user-error "This package is not installed")) (when (or (guix-get-key-val entry 'obsolete) (y-or-n-p "This package is not obsolete. Try to upgrade it anyway? ")) - (guix-package-list-mark-upgrade-simple)))) + (guix-package-list-mark-outputs + 'upgrade installed + (and arg "Output(s) to upgrade: ") + installed)))) + +(defun guix-package-list-mark-upgrades () + "Mark all obsolete packages for upgrading." + (interactive) + (guix-package-list-marking-check) + (let ((obsolete (cl-remove-if-not + (lambda (entry) + (guix-get-key-val entry 'obsolete)) + guix-entries))) + (guix-list-for-each-line + (lambda () + (let* ((id (guix-list-current-id)) + (entry (cl-find-if + (lambda (entry) + (equal id (guix-get-key-val entry 'id))) + obsolete))) + (when entry + (apply #'guix-list-mark + 'upgrade nil + (guix-get-installed-outputs entry)))))))) (defun guix-package-list-execute () "Perform actions on the marked packages." -- 2.1.0 --=-=-=--