From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.devel Subject: Extend tabulated-list-mode to support marks Date: Sat, 25 Jul 2020 02:00:30 +0700 Message-ID: References: <20200724005105.11f85d5f@pineapple> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14915"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Emacs developers , Matthew White To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jul 24 21:02:06 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jz2xK-0003mr-BT for ged-emacs-devel@m.gmane-mx.org; Fri, 24 Jul 2020 21:02:06 +0200 Original-Received: from localhost ([::1]:39486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jz2xJ-00060N-7d for ged-emacs-devel@m.gmane-mx.org; Fri, 24 Jul 2020 15:02:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59518) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jz2w0-00055R-EV for emacs-devel@gnu.org; Fri, 24 Jul 2020 15:00:44 -0400 Original-Received: from mail-ua1-x931.google.com ([2607:f8b0:4864:20::931]:42728) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jz2vy-0006I7-Lq for emacs-devel@gnu.org; Fri, 24 Jul 2020 15:00:44 -0400 Original-Received: by mail-ua1-x931.google.com with SMTP id r63so3273822uar.9 for ; Fri, 24 Jul 2020 12:00:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=1NATpEgm8VQ+1Rdt1k5WncHTsI4wobYubEN09mzIWnw=; b=D6b8hP3WbFS5Bl0LTMgAobtN6ib6bzIZFFhyjN6U0xKC+suYasa+hxrmZeVe2l0bAR wj1TvJXhP1rwLcW8TuJrTBvxzFxk3+9r8tbpe8nKqUmHJNarH17QfR8fWF5RrVHS7ITl SORZidQ/pq1m7qrJKvL1TItKegBz54TkJldDz2i+RfDyHF8TMPuoiGxnisSJhHBVeJI4 NmrHWXEr6wNx7f6xJBMa0HnqNetw9pl6OEk0BILuQ0FzLcCnk4PPQeWDXhv0M0Bc6Xv+ qzS+PBITkKQt4Fnc6G70UA3bCNnx/s2HvoncNEBCsGyn9MZOFhCyYayTN12/a/G27cTJ uB6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=1NATpEgm8VQ+1Rdt1k5WncHTsI4wobYubEN09mzIWnw=; b=nTQvsJlSDOdvGVpT4HzMmHZphsH3QvocIUAU89OTQUZzD1kTlSlv8FHoTjWIrMNcbk RVuiRsCDAiV5y6i6OZ+hGtyW2X+3MOOWZoWlNHkkOGNHGOUJ0poirez+FoXsAf8WHCB7 VcXABmoy/ZxCBFk07Wmne7Cmdl0c9b2MVbYXeFK432d2STrWX5QndleCeEXtisfSKI2p 4FCYhyKtCOyDsJZPpOTjfSBtwY5zZJ9j/WLjZ7WM7oqY/PiKSO7Sk2J8GWU4rWMuuubN +KqAP1m2i72pyf80SKwE3Ts34iW6LfU8PuNVyBC8oqg3XrC2pR6cfGesJHF4WJ7OGAUQ nqFw== X-Gm-Message-State: AOAM5315ZC89G1RC1Ja5nJ/PnnYnXKhchXHxcAvk06aS34PGKHfGBUsb styxv/JKvjJGLaNWmjWvTTO/PIePq5MkTQj4CGI= X-Google-Smtp-Source: ABdhPJzmurtr3oyglMTENPrKW8r0mffRX4PhrXb7x+XaU0w2Mo+SV1HZhsENG8gSpho7J1mcj905vDhShlwb+xWkxHg= X-Received: by 2002:ab0:53cc:: with SMTP id l12mr9312272uaa.24.1595617241314; Fri, 24 Jul 2020 12:00:41 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::931; envelope-from=yurivkhan@gmail.com; helo=mail-ua1-x931.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:253201 Archived-At: On Fri, 24 Jul 2020 at 22:05, Stefan Monnier wro= te: > > and (2) if maybe tabulated-list-mode would benefit from a generic > > implementation of multiple marking, unmarking, marking-for-deletion, > > and command application. > > Maybe "for deletion" is too application-specific (some uses of > `tabulated-list-mode` can't "delete" or at least not conveniently enough > that it's a common use case), but a definite +1 for the rest. My point is that there are many instances of a generic scenario: Display a list of items; enable the user to perform operations on a single item at point or to mark multiple items and operate on them as a subset. Currently, each mode derived from =E2=80=98tabulated-list-mode=E2= =80=99 has to reimplement marking, unmarking, mark preservation over refresh, iterating over marked items, and fallback to the item at point when no marks are set. One high-visible derived mode hijacks the =E2=80=9Cunmark al= l=E2=80=9D key for =E2=80=9Cmark upgradable packages=E2=80=9D. I think they would bene= fit from a common implementation and the unification of the UI stemming from that. One possibility would be for a derived mode to set some buffer-local variables to inform =E2=80=98tabulated-list-mode=E2=80=99 which marks it su= pports. E.g.: * Set =E2=80=98tabulated-list-delete-function=E2=80=99 to a non-nil functio= n that will delete the item at point or signal an error. Then the command bound to =E2=80=98D=E2=80=99 will invoke that function and remove its visual represe= ntation from the buffer; =E2=80=98d=E2=80=99 will mark the item at point for deleti= on; =E2=80=98x=E2=80=99 will go through all the items marked for deletion and actually delete and remove them; =E2=80=98u=E2=80=99 will unmark the item at point; and =E2= =80=98U=E2=80=99 will unmark all items. * Set =E2=80=98tabulated-list-marks=E2=80=99 to a string of characters. If = that string contains =E2=80=98>=E2=80=99, =E2=80=98m=E2=80=99 will mark the item at poi= nt with =E2=80=98>=E2=80=99. Other marks listed in the string can be set by the derived mode binding a key to a function that will call (tabulated-list-set-mark CHAR). =E2=80=98u=E2=80=99= and =E2=80=98U=E2=80=99 will unmark the item at point or all items, respectively. A helper function, (tabulated-list-map CHAR FUNC), will execute FUNC on each item marked CHAR or on the item at point if no items are marked, optionally removing the item or unmarking it depending on FUNC=E2=80=99s return value; this can be invoked in any commands bound in the derived mode keymap. I might implement something if this general direction is deemed desirable. Details can be discussed.