From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail
From: Thierry Volpiatto <thievol@posteo.net>
Newsgroups: gmane.emacs.bugs
Subject: bug#66394: 29.1; Make register-read-with-preview more useful
Date: Wed, 25 Oct 2023 06:38:16 +0000
Message-ID: <877cnb2n63.fsf@posteo.net>
References: <87il7ib6cu.fsf@posteo.net> <87sf67qqmp.fsf@web.de>
 <875y3386ep.fsf@posteo.net> <87a5sddh14.fsf@web.de>
 <8734y5vnj7.fsf@posteo.net> <87bkcslr18.fsf@web.de>
 <87y1fwtyrl.fsf@posteo.net> <87y1fut1wp.fsf@web.de>
 <87ttqgpjiz.fsf@posteo.net> <87wmvbibpr.fsf@web.de>
Mime-Version: 1.0
Content-Type: multipart/signed; boundary="=-=-=";
 micalg=pgp-sha512; protocol="application/pgp-signature"
Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214";
	logging-data="16622"; mail-complaints-to="usenet@ciao.gmane.io"
Cc: 66394@debbugs.gnu.org
To: Michael Heerdegen <michael_heerdegen@web.de>
Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Oct 25 09:10:49 2023
Return-path: <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org>
Envelope-to: geb-bug-gnu-emacs@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 <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org>)
	id 1qvY2S-00047z-RO
	for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 25 Oct 2023 09:10:49 +0200
Original-Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <bug-gnu-emacs-bounces@gnu.org>)
	id 1qvY2H-0007Ta-RZ; Wed, 25 Oct 2023 03:10:37 -0400
Original-Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1qvY2E-0007SN-7Z
 for bug-gnu-emacs@gnu.org; Wed, 25 Oct 2023 03:10:34 -0400
Original-Received: from debbugs.gnu.org ([2001:470:142:5::43])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1qvY2C-0001Zd-Kx
 for bug-gnu-emacs@gnu.org; Wed, 25 Oct 2023 03:10:33 -0400
Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
 (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1qvY2f-0000vI-NK
 for bug-gnu-emacs@gnu.org; Wed, 25 Oct 2023 03:11:01 -0400
X-Loop: help-debbugs@gnu.org
Resent-From: Thierry Volpiatto <thievol@posteo.net>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@gnu.org
Resent-Date: Wed, 25 Oct 2023 07:11:01 +0000
Resent-Message-ID: <handler.66394.B66394.16982178323511@debbugs.gnu.org>
Resent-Sender: help-debbugs@gnu.org
X-GNU-PR-Message: followup 66394
X-GNU-PR-Package: emacs
Original-Received: via spool by 66394-submit@debbugs.gnu.org id=B66394.16982178323511
 (code B ref 66394); Wed, 25 Oct 2023 07:11:01 +0000
Original-Received: (at 66394) by debbugs.gnu.org; 25 Oct 2023 07:10:32 +0000
Original-Received: from localhost ([127.0.0.1]:57184 helo=debbugs.gnu.org)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
 id 1qvY2B-0000uW-Lm
 for submit@debbugs.gnu.org; Wed, 25 Oct 2023 03:10:32 -0400
Original-Received: from mout02.posteo.de ([185.67.36.66]:58417)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <thievol@posteo.net>) id 1qvY25-0000uD-Cu
 for 66394@debbugs.gnu.org; Wed, 25 Oct 2023 03:10:30 -0400
Original-Received: from submission (posteo.de [185.67.36.169]) 
 by mout02.posteo.de (Postfix) with ESMTPS id 3B533240103
 for <66394@debbugs.gnu.org>; Wed, 25 Oct 2023 09:09:48 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1698217789; bh=22P/6tOF++DOUEG0DRVNEAPwffBiCT17r1JiiDBcEY8=;
 h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From;
 b=Mw7Jm8y38DX0jW3HOUnFLJCioYSwB6y70DPsaoZM8dLfDJyZnWLES4NnhJnsdjUMA
 w7C1RE9MOEEYxmKrCEg5+S8Fu1bwigLEEYfr3fDm5/ppP3lcB85wsxLlF5fbt5XoOm
 lb9zHqVFFULCFyyrN3Dv9WcRpiMXrvhpAO37KC+BKCJsZLMGe0fjxbft67X9f4Zqq/
 35Uw4sh0u4ArBF94Cxgq3ioPvjEkQy+WWGX7Q+e1BYtQAXiw9lGFi1S2kGHK84fXya
 QAV0GAgDU4LpYIIuOPVbW83kR2MaduxtvrsiumLG+tv7c36N4qU1c6Uqz2vTFKUVVR
 UBUAILOUV/ilA==
Original-Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4SFg6N0sWrz9rxN;
 Wed, 25 Oct 2023 09:09:47 +0200 (CEST)
In-reply-to: <87wmvbibpr.fsf@web.de>
X-BeenThere: debbugs-submit@debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
X-BeenThere: bug-gnu-emacs@gnu.org
List-Id: "Bug reports for GNU Emacs,
 the Swiss army knife of text editors" <bug-gnu-emacs.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-gnu-emacs>,
 <mailto:bug-gnu-emacs-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/bug-gnu-emacs>
List-Post: <mailto:bug-gnu-emacs@gnu.org>
List-Help: <mailto:bug-gnu-emacs-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-gnu-emacs>,
 <mailto:bug-gnu-emacs-request@gnu.org?subject=subscribe>
Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org
Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org
Xref: news.gmane.io gmane.emacs.bugs:273148
Archived-At: <http://permalink.gmane.org/gmane.emacs.bugs/273148>

--=-=-=
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable


Michael Heerdegen <michael_heerdegen@web.de> writes:

> Thierry Volpiatto <thievol@posteo.net> writes:
>
>> A possible solution for this is adding two vars, insert-register-types
>> and jump-to-register-types and define register-type like this (named
>> register--type here):
>>
>> (defun register--type (register)
>>   ;; Call register/type against the register value.
>>   (register/type (if (consp (cdr register))
>>                      (cadr register)
>>                    (cdr register))))
>>
>> (cl-defgeneric register/type (regval))
>>
>> (cl-defmethod register/type ((regval string)) 'string)
>> (cl-defmethod register/type ((regval number)) 'number)
>> (cl-defmethod register/type ((regval marker)) 'marker)
>> (cl-defmethod register/type ((regval window-configuration)) 'window)
>> (cl-deftype frame-register () '(satisfies frameset-register-p))
>> (cl-defmethod register/type :extra "frame-register" (regval) 'frame)
>>
>> ;; set a new register and check its type like this:
>> (register--type (car register-alist))
>
> This looks promising.
>
> But I'm not sure whether the detour via type names (instead of an
> approach using only generics) is the best solution.  Why not define just
> a new generic (register-eligible-for-command-p REG COMMAND) and use that
> as predicate in the interactive specs of the commands (providing
> `this-command' as second arg)?  Seems simpler to me and still more
> extensible and controllable.

Not sure to understand what you want to do here.

We don't want to modify each command, and anyway I don't see what
(register-eligible-for-command-p REG COMMAND) would do in the
interactive spec of each command.

There is two things we want to make more flexible:

1) The ability to allow adding a new type of register and
use this type of register to filter out the register-alist according to
the command in use.

2) Allow one to add a new register command
and assign its type, message to use and action it
provide.

Example, if I want to define a new command register-delete:

    (defun register-delete (register)
      (interactive (list (register-read-with-preview "Delete register: ")))
      (setq register-alist (delete register register-alist)))

If I run this command I will have a minibuffer message "Overwrite
register <n>", this is not what I expect, I expect "Delete register
<n>".

So we need something to customize this.
I added a new var and a structure to achieve this, so now one can do in
e.g. its .emacs:

    (with-eval-after-load 'register
      (require 'register-preview)
      (add-to-list 'register-commands-data
                   `(register-delete
                     .
                     ,(make-register-preview-commands
                       :types '(all)
                       :msg "Delete register `%s'"
                       :act 'delete)))
      (defun register-delete (register)
        (interactive (list (register-read-with-preview "Delete register: ")=
))
        (setq register-alist (delete register register-alist))))


But maybe what you propose is simpler to achieve the two tasks above,
don't know.

=2D-=20
Thierry

--=-=-=
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQHHBAEBCgAxFiEEI9twfRN7r3nig/xwDsVtFB0W75MFAmU4vzUTHHRoaWV2b2xA
cG9zdGVvLm5ldAAKCRAOxW0UHRbvk0tYDAC6CwhEYMwOXn4e2oQAoEqUB72xC4MH
Em5OShCq1WvwbOLh4tg+zfTO5exdmgbWabhVfNXp3DyBKfTOBWqrRwxyeQPu+YRd
NAyqbOp01E88i+NyRH4HTUW4dyY4npg27SRJBy6cQ4poLKYLkCAb4sCrFf3gza9X
sZP5XTHJK8LOT92jPL37y+rFs8gtBapF1HmPCOwzD5tLIqQ/DgRNcgttnx6r4zCA
p3EC8NsK6GPabLeYl5BlQ5Js+NGqUpEg8p90QwOSFcKoUBFo129cLXpoWLNHC/KC
uZSxCAUb2XDu67F0vOKqK2tr9sZZvALV+UCRY3epcKG5PGHgvyeeTHieuxvoUfEN
GLXUeiqS9hZfcikZCnGCcutDGGYV/yrAIKc8xguiMNMWoXo9iFQHwQ1059sRknuy
gCsgbG132OauoKvPgcYP4guLpE+7Moyt8n5WYLzXXqtXTY+BhJ90XdjFCasxG0aW
vYLcEdSUokHmZ0G1mMsdwhfx1HtebuQw7Ks=
=NLgf
-----END PGP SIGNATURE-----
--=-=-=--