From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#73308: [PATCH] Add file-to-register and buffer-to-register. Date: Tue, 17 Sep 2024 15:20:25 +0300 Message-ID: <86msk6bhfa.fsf@gnu.org> References: <877cbbrx7r.fsf@ocathain.ie> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32189"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 73308@debbugs.gnu.org To: Barra =?UTF-8?Q?=C3=93_?= =?UTF-8?Q?Cath=C3=A1in?= , Thierry Volpiatto Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Sep 17 14:22:09 2024 Return-path: 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 ) id 1sqXDc-0008B4-Iz for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 17 Sep 2024 14:22:09 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sqXDL-0002Pu-Uh; Tue, 17 Sep 2024 08:21:51 -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 ) id 1sqXDJ-0002PV-F6 for bug-gnu-emacs@gnu.org; Tue, 17 Sep 2024 08:21:50 -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 ) id 1sqXDJ-0007qH-5Z for bug-gnu-emacs@gnu.org; Tue, 17 Sep 2024 08:21:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-version:References:In-Reply-To:From:Date:To:Subject; bh=CSW1BVr3MIHFnsgt8pxfwbmFBsf9hhzA86ALWBwblvk=; b=nCOm+MTWtTFsCz8kYwUzaFnxRssuxUcIbJWkueBzqyO54AJ0SVPvqqwALVmVOkSpZADSEc8s7EvGciRAHesdUxwRilmVqooQFnJUJKsqSYayA9AdXe8fq70P6lSfgyNHemB1d9VhH8HwD2pfDAKB9DaMFIWObjWF1mib8aQ0rYiBGIKlm3jBXyGhydOKq7NPDeFM6NWtpdK75+FmaA1eX0dK9FKYrWhLV8N6iEorr14iYexSZGYl7PJOJL18HTMIgWGeE1vcISftvnqUHk4Q5aCGKofiFxaKIG6E+7X54mmRLtUEVS6+5OFH4vQcx2j3KimkJkT94MBu3xzZ9+zG4g==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sqXDW-0000u8-N7 for bug-gnu-emacs@gnu.org; Tue, 17 Sep 2024 08:22:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 17 Sep 2024 12:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73308 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 73308-submit@debbugs.gnu.org id=B73308.17265756683368 (code B ref 73308); Tue, 17 Sep 2024 12:22:02 +0000 Original-Received: (at 73308) by debbugs.gnu.org; 17 Sep 2024 12:21:08 +0000 Original-Received: from localhost ([127.0.0.1]:54156 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sqXCe-0000sF-9X for submit@debbugs.gnu.org; Tue, 17 Sep 2024 08:21:08 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:43928) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sqXCc-0000rn-SQ for 73308@debbugs.gnu.org; Tue, 17 Sep 2024 08:21:07 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sqXCG-0007fU-W9; Tue, 17 Sep 2024 08:20:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=CSW1BVr3MIHFnsgt8pxfwbmFBsf9hhzA86ALWBwblvk=; b=orq1hBWFFcRMtnucI6Uw vb3S3RxhUO8SvhWheV60w+bjOl9MSUMRn0yOQrrV+XmvhJMiyui6Y9mChAviMW2ae1TD1kNRBpjdN JAeCAc2KjG/819LFL1LlPGEEE2F+aHcAYYqOenphCtIkE2MYCPg1JqQTLboVtWYnNaMEwN3QWw8z9 vC/VxcSZDjGBP6k9lb/uW2DMjO1i/h6m9bkjNNTr/K+rtQCNoQhTFNISigSkNKfKVavqIYsZGmkA4 mtDuwNpf1MI/OLzH1465rq0lc9EPw17S/r5OEUd8wi/Kz1OrBoW+PvdXLVE/C6sD6j8CLE4DblqCq zB6T275yk36SVw==; In-Reply-To: <877cbbrx7r.fsf@ocathain.ie> (bug-gnu-emacs@gnu.org) 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" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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:291935 Archived-At: > List-Unsubscribe-Post: List-Unsubscribe=One-Click > Date: Tue, 17 Sep 2024 00:32:40 +0100 > From: Barra Ó Catháin via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > This patch adds two new functions and keybindings for them, > file-to-register and buffer-to-register. > > These functions make it simpler to put a file/buffer into a register, > which I have personally found to be useful when working with projects > where I don't wish to disturb the point or to pull up notes files. > > (Previously submitted, but I was unfortunately unable to follow it up at > the time due to life getting busy!) > > Questions and comments appreciated, previously assigned copyright. Thierry, any comments to these additions? > * lisp/bindings.el (ctl-x-r-map): > Add bindings to the register keymap for the two new > functions. 'F' for file-to-register and 'B' for > buffer-to-register. > > * lisp/register.el (register-command-info): Registers the two > new functions, file-to-register and buffer-to-register as > commands. > > (file-to-register): > New function, stores a file into a register. Used interactively, > prompts for REGISTER using `register-read-with-preview'. With a > prefix-argument, prompts for FILE-NAME using `read-file-name', > otherwise, uses the currently visited file or directory for > FILE-NAME. > > (buffer-to-register): > New function, stores a buffer into a register. Used > interactively, prompts for REGISTER using > `register-read-with-preview'. With a prefix-argument, prompts > for BUFFER-NAME using `read-buffer', otherwise, uses the current > buffer. This is not exactly the format of log entries which we prefer. See "git log" for examples and CONTRIBUTE for explanations. > +@table @kbd > +@item C-x r F @var{r} > +@kindex C-x r F > +@findex file-to-register > +Store the currently visited file or directory into register @var{r} (@code{file-to-register}). > +@item C-u C-x r F @var{r} > +@kindex C-x r F > +@findex file-to-register > +Prompt for a file, and store into register @var{r} (@code{file-to-register}). First, @*index index entries should appear _before_ the @item lines, so that Info-index places you on the line created from @item, not after it. And second, the above defines two identical @kindex entries "C-x r F" that both point to the same page, and that is not useful. We should keep only one of them. The same about the 2 identical @findex entries. (Actually, you have 3 identical @kindex entries.) More importantly, we usually index the detailed descriptions of the commands in the body of the section, not the abstract at its beginning. E.g., look at how this is done in a node "Position Registers". > + Similarly, if there are certain buffers you visit frequently, you can > +put their names in registers. You can use the following command to put a > +buffer into a register. ^^ Our conventions are to leave two spaces between sentences, per US English. > -@smallexample > -(set-register ?m '(buffer . "*Messages*")) > -@end smallexample > +@table @kbd > +@item C-x r B @var{r} > +@kindex C-x r B > +@findex buffer-to-register > +Store the current buffer into register @var{r} (@code{buffer-to-register}). > +@item C-u C-x r B @var{r} > +@kindex C-x r B > +@findex buffer-to-register > +Prompt for a buffer, and store into register @var{r} (@code{buffer-to-register}). > +@end table It is best to have at the beginning of a node a single @table with the abstract of all the commands described by the node. So please make one @table out of these two. > +(defun file-to-register (file-name register) > + "Inserts FILE-NAME in REGISTER. > +To visit the file, use \\[jump-to-register]. > + > +Interactively, prompts for REGISTER using `register-read-with-preview'. > +With a prefix-argument, prompts for FILE-NAME using `read-file-name', > +otherwise, uses the currently visited file or directory for FILE-NAME." Our style in doc string is to use "Insert", "prompt", "use", etc., at least in the first sentence of the doc string, which gives the summary of what the function does. > +(defun buffer-to-register (buffer register) > + "Inserts BUFFER in REGISTER. > +To visit the buffer, use \\[jump-to-register]. > + > +Interactively, prompts for REGISTER using `register-read-with-preview'. > +With a prefix-argument, prompts for BUFFER-NAME using `read-buffer', > +otherwise, uses the current buffer." Likewise here. Finally, this warrants a NEWS entry to announce the new commands. Thanks.