From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 16 19:43:09 2024 Received: (at submit) by debbugs.gnu.org; 16 Sep 2024 23:43:09 +0000 Received: from localhost ([127.0.0.1]:53614 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sqLN6-0000NB-Uh for submit@debbugs.gnu.org; Mon, 16 Sep 2024 19:43:09 -0400 Received: from lists.gnu.org ([209.51.188.17]:55750) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sqLN5-0000N3-3v for submit@debbugs.gnu.org; Mon, 16 Sep 2024 19:43:08 -0400 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 1sqLMp-0000ko-PS for bug-gnu-emacs@gnu.org; Mon, 16 Sep 2024 19:42:52 -0400 Received: from abi149bb127.cwl1.oracleemaildelivery.com ([129.149.22.127]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sqLMm-0001IF-39 for bug-gnu-emacs@gnu.org; Mon, 16 Sep 2024 19:42:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=ocathain-2023-02-08; d=ocathain.ie; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender:List-Unsubscribe:List-Unsubscribe-Post; bh=SNfOai85pvqkdvDv7dyJQ63bIsS+bRq8EbaiVYSaFh4=; b=PXHLG495fp0zfU0NhtXVHfwI9huWVQVbCV2pT6WFGjQumVR45i54olCuoq194klTPHEr4jVagWTW +Mxx9n8kd0CdjSePEaU6TdxIhFqdYACsRbk9WkSnJA0PKkjP6CXBxO4ywPZSdK6+uDFowYWvH2xw zvu0OzjZ98kiEms34nXQGBouOtmXrAAVSvGZhgIVj3U7kMw49Xv4b8VM0+pM65368ZU5S+7/vpp7 rdNIHrEDoFZCHC/CJ9Gznc/ml/fEPjjI+eC5dzRB2a9qrgaB0BWsd0QLxFoas8kVQb8w56fTQhfT vr7H4QS+jcyEsgbVKEVZ5NxHoxm1xosuEHHWGQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-cwl-20201026; d=cwl1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender:List-Unsubscribe:List-Unsubscribe-Post; bh=SNfOai85pvqkdvDv7dyJQ63bIsS+bRq8EbaiVYSaFh4=; b=gmUEk74J2qUquloYTHzlWBUOrvPhfOJH4p+Qzs4PoBSL0WVOmJihGJc/RTNog3afLWEwwit0GI5K wKKlX3I3Ts/3BDwE+YTyZcv93S5UTiQVwddydAezwL+fj9boKWFjLsr4fDERysgo1dCbvnEcQ4mp /1rtNw91MAZp9mC7opq2RoGJw9LaYalf++icwjXm5OB4oJtJa7zdfBPjNM+XLTlw8d4b6WCofmPW OXTcH3H+5NRNefof/2JziO+w61ZA9NFqgOU4XdGfSiNq2cBwm6j4gtecWyCljXTggGBMoE7ISQv5 7uUVgfRnlt/tZGLx2yHnfxjQQiBbvgTn9wIQVA== Received: by omta-ad1-fd3-401-uk-cardiff-1.omtaad1.vcndpcwl.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20240709 64bit (built Jul 9 2024)) with ESMTPS id <0SJX00KUNIQG8180@omta-ad1-fd3-401-uk-cardiff-1.omtaad1.vcndpcwl.oraclevcn.com> for bug-gnu-emacs@gnu.org; Mon, 16 Sep 2024 23:32:40 +0000 (GMT) List-Unsubscribe-Post: List-Unsubscribe=One-Click From: =?utf-8?Q?Barra_=C3=93_Cath=C3=A1in?= To: bug-gnu-emacs@gnu.org Subject: [PATCH] Add file-to-register and buffer-to-register. Date: Tue, 17 Sep 2024 00:32:40 +0100 Message-id: <877cbbrx7r.fsf@ocathain.ie> MIME-version: 1.0 Content-type: multipart/mixed; boundary="=-=-=" Reporting-Meta: AAEiSvJMsoK/fd4ND1ccLt9JEks7TzRo81AXoZDHvvG4In182p89Ztz5hTRVstfx 6y7aaWk/j3aopGZJv8x6o7ZBwhJX6ZwHPeHUZusjt53uS/LvYPLMMw777XQ82NJe pXkRZa1ZXvftKseTQDTk6w9TyIMg2Y4UEgOu3ANoktTxf98nULjYj+TOGSCgxTjB uEJVBSInkqQFan9iJMFIVO4lc2FFw2zBGT/dvqVG/xD+Kk65SBYJmuruh4Hh7ZfN JSkHW4xzZvD6YC57DzvhGBb4b8igt1ZZIEhbD6hKDGGW7Dn7ZFGXXdOWTDqG97t+ kcduXHoVJgqOsJ79euVRIwgOX/hRDIpvUcVmdw2rffB1qfRu9CTbU/j/Nr09iHSz +qj1Qi0aVfPH4v/wnwtzQSPnvai2vurAfNhK2Ou/72pwc+Q8xRkXRVbsYbrSPlMJ uzpxBtfdw1bbqZC10wY0zeuI4FNUBvQepH6g5TqG/mo9tP0RacmCX76A Received-SPF: pass client-ip=129.149.22.127; envelope-from=bounces+bug-gnu-emacs=gnu.org@cwl1.rp.oracleemaildelivery.com; helo=abi149bb127.cwl1.oracleemaildelivery.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.1 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.1 (--) --=-=-= Content-Type: text/plain Tags: patch Tags: patch 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. In GNU Emacs 29.4 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.43, cairo version 1.18.0) Windowing system distributor 'The X.Org Foundation', version 11.0.12101013 System Description: Arch Linux Configured using: 'configure --sysconfdir=/etc --prefix=/usr --libexecdir=/usr/lib --with-tree-sitter --localstatedir=/var --with-cairo --disable-build-details --with-harfbuzz --with-libsystemd --with-modules --with-x-toolkit=gtk3 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/build/emacs/src=/usr/src/debug/emacs -flto=auto' 'LDFLAGS=-Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-z,pack-relative-relocs -flto=auto'' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Add-file-to-register-and-buffer-to-register.patch >From 29a160f087a0e530e415a9f2676abb390c54f910 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barra=20=C3=93=20Cath=C3=A1in?= Date: Tue, 17 Sep 2024 00:11:11 +0100 Subject: [PATCH] Add file-to-register and buffer-to-register. * 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. * doc/emacs/regs.texi (File and Buffer Registers): Added documentation for the new file-to-register and buffer-to-register commands, replacing the elisp snippet that was used previously. --- doc/emacs/regs.texi | 55 ++++++++++++++++++++++++--------------------- lisp/bindings.el | 4 +++- lisp/register.el | 41 +++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 26 deletions(-) diff --git a/doc/emacs/regs.texi b/doc/emacs/regs.texi index 734d704a272..446b42395ba 100644 --- a/doc/emacs/regs.texi +++ b/doc/emacs/regs.texi @@ -289,41 +289,46 @@ File and Buffer Registers @section Keeping File and Buffer Names in Registers @cindex saving file name in a register @cindex saving buffer name in a register +@kindex C-x r F +@kindex C-x r B If you visit certain file names frequently, you can visit them more -conveniently if you put their names in registers. Here's the Lisp code -used to put a file @var{name} into register @var{r}: +conveniently if you put their names in registers. Here's how you can +put a file into a buffer. -@smallexample -(set-register @var{r} '(file . @var{name})) -@end smallexample - -@need 3000 -@noindent -For example, - -@smallexample -(set-register ?z '(file . "/gd/gnu/emacs/19.0/src/ChangeLog")) -@end smallexample - -@noindent -puts the file name shown in register @samp{z}. +@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}). +@end table To visit the file whose name is in register @var{r}, type @kbd{C-x r j @var{r}}. (This is the same command used to jump to a position or restore a frame configuration.) - Similarly, if there are certain buffers you visit frequently, you -can put their names in registers. For instance, if you visit the -@samp{*Messages*} buffer often, you can use the following snippet to -put that buffer into the @samp{m} register: + 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. -@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 - To switch to the buffer whose name is in register @var{r}, type -@kbd{C-x r j @var{r}}. + To visit the buffer whose name is in register @var{r}, type @kbd{C-x r + j @var{r}}. (This is the same command used to jump to a position or + restore a frame configuration.) @node Keyboard Macro Registers @section Keyboard Macro Registers diff --git a/lisp/bindings.el b/lisp/bindings.el index 6b34c5750c1..06a488fa9fa 100644 --- a/lisp/bindings.el +++ b/lisp/bindings.el @@ -1574,7 +1574,9 @@ ctl-x-r-map "n" #'number-to-register "+" #'increment-register "w" #'window-configuration-to-register - "f" #'frameset-to-register) + "f" #'frameset-to-register + "F" #'file-to-register + "B" #'buffer-to-register) (define-key ctl-x-map "r" ctl-x-r-map) (define-key esc-map "q" 'fill-paragraph) diff --git a/lisp/register.el b/lisp/register.el index 497848ded1e..01be41314c5 100644 --- a/lisp/register.el +++ b/lisp/register.el @@ -300,6 +300,18 @@ register-command-info :act 'set :noconfirm (memq register-use-preview '(nil never)) :smatch t)) +(cl-defmethod register-command-info ((_command (eql file-to-register))) + (make-register-preview-info + :types '(all) + :msg "File to register `%s'" + :act 'set + :noconfirm (memq register-use-preview '(nil never)))) +(cl-defmethod register-command-info ((_command (eql buffer-to-register))) + (make-register-preview-info + :types '(all) + :msg "Buffer to register `%s'" + :act 'set + :noconfirm (memq register-use-preview '(nil never)))) (defun register-preview-forward-line (arg) "Move to next or previous line in register preview buffer. @@ -688,6 +700,35 @@ jump-to-register (let ((val (get-register register))) (register-val-jump-to val delete))) +(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." + (interactive (list (if (eq current-prefix-arg nil) + (if (eq major-mode 'dired-mode) + (dired-current-directory) + (buffer-file-name)) + (read-file-name "File: ")) + (register-read-with-preview "File to register: "))) + (unless (eq file-name nil) + (set-register register (cons 'file file-name)))) + +(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." + (interactive (list (if (eq current-prefix-arg nil) + (current-buffer) + (read-buffer "Buffer: ")) + (register-read-with-preview "Buffer to register: "))) + (set-register register (cons 'buffer buffer))) + (cl-defgeneric register-val-jump-to (_val _arg) "Execute the \"jump\" operation of VAL. VAL is the contents of a register as returned by `get-register'. -- 2.46.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 17 08:21:08 2024 Received: (at 73308) by debbugs.gnu.org; 17 Sep 2024 12:21:08 +0000 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 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 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==; Date: Tue, 17 Sep 2024 15:20:25 +0300 Message-Id: <86msk6bhfa.fsf@gnu.org> From: Eli Zaretskii To: Barra =?iso-8859-1?Q?=D3_Cath=E1in?= , Thierry Volpiatto In-Reply-To: <877cbbrx7r.fsf@ocathain.ie> (bug-gnu-emacs@gnu.org) Subject: Re: bug#73308: [PATCH] Add file-to-register and buffer-to-register. References: <877cbbrx7r.fsf@ocathain.ie> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 73308 Cc: 73308@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > 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. From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 17 10:06:54 2024 Received: (at 73308) by debbugs.gnu.org; 17 Sep 2024 14:06:54 +0000 Received: from localhost ([127.0.0.1]:55700 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sqYr0-0007AS-0a for submit@debbugs.gnu.org; Tue, 17 Sep 2024 10:06:54 -0400 Received: from mout01.posteo.de ([185.67.36.65]:37663) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sqYqy-0007AD-64 for 73308@debbugs.gnu.org; Tue, 17 Sep 2024 10:06:53 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 662A0240027 for <73308@debbugs.gnu.org>; Tue, 17 Sep 2024 16:06:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1726581991; bh=GDCCnSMGElR+UOyOu6aftmUbJhEw4P315jzUMN0mxaw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: Autocrypt:OpenPGP:From; b=iwDKTEIp+YO5EgUT2ABzRketVg3kTm1eA1WhyVctD5hNDZ3Wrg3QPHVEU8gKGAObw nXEBVlULVm0Y71uCjJG/EMwLcKOc7toxP4BmDFIdhxaReEnKlU0akkBdioGys7B5Da /s2SAezijTMV9PWakxzYVH/oQBwqqWe3cF7I5T40CHEy/8w9V0fhL7qP/F18jai142 0U5ZIyeoBqizwMQEnB7K/aB/RKCpw/R4sqtxcrAWBi8L+TeQRRZTQU4+fZgyjDctos OY4rDL8ObEJX7TNqdDiAypJCLOGFQY978DiV6LWHp8S4nEnewkQUtVJ2GwG7aSmFRh eO89CwcwMnUMw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4X7Nqm2plpz6txd; Tue, 17 Sep 2024 16:06:28 +0200 (CEST) From: Thierry Volpiatto To: Eli Zaretskii Subject: Re: bug#73308: [PATCH] Add file-to-register and buffer-to-register. In-Reply-To: <86msk6bhfa.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 17 Sep 2024 15:20:25 +0300") References: <877cbbrx7r.fsf@ocathain.ie> <86msk6bhfa.fsf@gnu.org> Date: Tue, 17 Sep 2024 14:10:41 +0000 Message-ID: <87jzfamkv2.fsf@posteo.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Autocrypt: addr=thievol@posteo.net; prefer-encrypt=mutual; keydata=xsDNBF8ylcIBDADG+hy+zR6L4/vbdDDZuSaMmSrU3A5QZJpeBCvxTr7MpzzruZbhLPW1K3R6N2MA edi8Y+C8o27FVRIjpdbaKMGu9je7JV/TbUQYo3SOwCK1vM4LUn4V6ZLzSYkuiEt4eyMoiDdyvN0p kcK6P9x9DCetcEVszXzQg+yzCVrQ2hXWDXWT4M18EC3wtO7RHPouMqGiwBFhBAYErCqFWFxQHkfb tG/4yGyJ58rglb65O3qijjMWvYwcWZun9/7qm8Z4/4mHopmo2zgU+OrptnLSZfkZGz3Y7Uf452xQ GVq0Fv75NPvQru7y+DYVhuVXXyAmGxt+vf4rIiixMBbhKEPjcxEPAa2LTzex2IsTZR+QVG9uDnqC WcgaOEQ58fzXNvNhtwwF/Rgio2XWAJVdmFWS59/k9W58CIUSNKBMZh2XeGdEmtHvDtCxW3z6FJha 36RzOM3fMNNiAGdFZJA84gcdloJR+sHCDTTPT3784fjr+V8An7sI581NGFzkRQqPvEQCZbUAEQEA Ac0SdGhpZXZvbEBwb3N0ZW8ubmV0wsEOBBMBCgA4AhsDBQsJCAcCBhUKCQgLAgQWAgMBAh4BAheA FiEEI9twfRN7r3nig/xwDsVtFB0W75MFAmL3HCoACgkQDsVtFB0W75OVEAv/f6XxmtIFz08fUb8h Bp/zJP6IC4/rhhh+0GMRIRzLN8DK0jV8JCzYdFHiRJOy2lNIOpmrrCmjRRxferc2G42+ePFIsslx hU46VSz1Z83NwIG3mpdYNV5WUTUdgzxExHTNTFCd7NKv0nlHKQaAtdXm5bYnSHsnL7cx8z7lukA/ EsJocE+GD7QXnsrdlicvdobI0TEN4l73221a72oCvHfYLCVsB6YsNJ5ZGkA1zSjzln5uLAgZ/2r/ aqlao/AlSZkAk6+hvK0RyAZ/YR4YRZxO8Fsd0gWgFkanRfKfufJ1V0OHZg7yszi3q/hRzS+rZtJ0 OuzDlh/dyQkxVkZb9vis/+HnGDJrBE5MsmJLcy2Sy3uUnio0fq8q9CrZbudvd1DajlZxPzTm0csP eUk45QEgbhEU7MfyAX/mkKxjHajz2cMcHKIap1BqEgJl4BKFeLMcBZ4O1p9ivwtf1Ht2JTp5lOi0 ItPfhQ4DP8LZ1ZIkN5Kg9v0cyw9meRzAuuR0V2GtzsDNBF8ylcIBDADnIDHEkmk4lUwTlOhwb2yj UfmGPnpH3MCCHkjM9H/P1gTHxFWtwFVPcNMCwXWvKSBTF2dZXKERD0yzG06zT53ZMN7EIIeuY6m4 R8IcMvpohciisWxbFoB4ZY117tVSeqjo946itgbpdeESKl9a8dpn7ytZMyYxPdojlQAqxeAJ8444 raESh1oTKXb64hlk4l2pSRlrLgjpJBo8asAfZndaxIUKhw68tV8sqeZh9P6cGtHbUELKVJqefNV7 V7jF5wf3xvRG6Ces3kSKXalLfs+vrVaoOjQeWrc0AtwFWHmt9JLfKrqF+Q2Q7jUidboWmazQM56E SJFPpPHmWq8k6DHspsFHOforLouTHJL1556IPne7IV2BGfWc0+xLxalZ8F5F+vnPF/OkrC1CD5iC KTjXKa2iZbcYdYQAiL6P8Ac8CgN6EkhpbxRtzrEgChuNGevdi/G/GHG4Zqrh6YFwIa/NHq2aVaFq 5C1yNTMJd1FRjRzs5JPPlJKpYDnNx+MSp7UAEQEAAcLA9gQYAQoAIAIbDBYhBCPbcH0Te6954oP8 cA7FbRQdFu+TBQJi9x1ZAAoJEA7FbRQdFu+To6QMAIcvUSiFwCIggxkmYy3ZY0QAMLmIPga8DNPM XbfSOBDb2KLGBd+FAA8p2GExpul4r6kOYnGogtojByHmVgrd30/3ZURTM8Vj51wwD05viMZccQHl Wd9J/qZIvhBJlJWYnwVxh+2Kg4/hkx7SGc7JJS5GS37+PFQOJHPGMxc+fe4Ty2FdjIOVf3P1Hov9 K6yBI7Af66qqcL3aKJ4jJidRYN8sMaKOqEu4rcSpTxp8/3Ddbs9HezUgXeUzOLJMcEYFlvCyC8ZS l/QDZmpobKbxZ1JAqZM8lnmcZYSV7OsWnxJIYDV1gH5LTLj7bGswXaB4B+qkckihWkRZixu8q1IK 0c/xwUzyF092uFRM/sQKrSmnwA1+hQiiIuEl4XVz5li0/TmMta3ijUM7GNbl2IjioTRxWWecwad1 mNHvKTcXPsKDAbHFdLvQzurnroBHQV0jSPNLTP5Suo7RnLbehfg5INpGjToCUlrd2qQqgXW7h5qZ TgUq5UmBc7YZ0JYWQgPTbQ== OpenPGP: url=https://posteo.de/keys/thievol@posteo.net.asc; preference=encrypt X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 73308 Cc: Thierry Volpiatto , Barra =?utf-8?B?w5MgQ2F0aMOhaW4=?= , 73308@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Eli Zaretskii writes: >> List-Unsubscribe-Post: List-Unsubscribe=3DOne-Click >> Date: Tue, 17 Sep 2024 00:32:40 +0100 >> From: Barra =C3=93 Cath=C3=A1in via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" >>=20 >> This patch adds two new functions and keybindings for them, >> file-to-register and buffer-to-register. >>=20 >> 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. >>=20 >> (Previously submitted, but I was unfortunately unable to follow it up at >> the time due to life getting busy!) >>=20 >> Questions and comments appreciated, previously assigned copyright. > > Thierry, any comments to these additions? One comment about buffer-to-register: More or less you can have the same with point-to-register, the advantage is that when you kill the buffer, the register-alist entry is turned in a file-query entry (when buffer is representing a file of course), for example from register.el buffer: C-x r RET register-alist entry: (115 . #) Now kill the the buffer, the register-alist entry is turned in: (115 file-query "/home/thierry/work/emacs/lisp/register.el" 27354) This is why I guess such functions where never added to register.el. OTOH they provide an alternative which is easier to find as most users don't know about this feature (buffer =3D> file-qurey). BTW I suggest you use for buffer-to-register an entry something like (buffer-name . marker), this way register-swap-out will be able to transform it like point-to-register does. Need also to add a add-hook call like point-to-register does. >> * 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. >>=20 >> * lisp/register.el (register-command-info): Registers the two >> new functions, file-to-register and buffer-to-register as >> commands. >>=20 >> (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. >>=20 >> (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} (@c= ode{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-regis= ter}). > > 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-registe= r}). >> +@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-r= egister}). >> +@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. =2D-=20 Thierry --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQHHBAEBCgAxFiEEI9twfRN7r3nig/xwDsVtFB0W75MFAmbpjeETHHRoaWV2b2xA cG9zdGVvLm5ldAAKCRAOxW0UHRbvk6DrDADATE0YWMlWeZcXx25xJS8m3eMtT6/4 2hoYaSFIVevgKwDrWq17qtAt9wUbegLv1rsavaAQL2OAhdAwGQncS8yIMSYddwK/ uSItDHe99a6he6S8Xntet+dFVd9ZRJ8srE5fySSHvLrNGgugREYS20sZ0k474D9r hQewkQm6sutxlx4dRjTtGmeN6lfNQmk+WIrrxR+6abT53jaPfl8isUlg42Bpxrb+ TBbIvXChYszci/QOhd7ukYKIe9/QSnEWzI3ra6xjef9p190lF17bBYbdsfrvDhyv u2p8zf4dI6B3DIlecoki4lW9JZW1JJn2Irhf1QA4JNzJrk33JrpvGgkuOkvv2qDL eCKWU5CKzPK2MMflhyprvwn5duFaOw95E8p+0E9S/XoqyTbRDlbQvbySuULcsU34 Cm0GAqUjDWSLCES8sKx14h0XEEDnBBIJSmdVzT8RDnaxKBno54yqyrPpPBwhxJwZ 6T4PaXmH+4EoYRrpubODez9Lwa1GFqaxVAM= =lY60 -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 17 15:18:37 2024 Received: (at 73308) by debbugs.gnu.org; 17 Sep 2024 19:18:37 +0000 Received: from localhost ([127.0.0.1]:55997 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sqdiV-0007hI-9h for submit@debbugs.gnu.org; Tue, 17 Sep 2024 15:18:37 -0400 Received: from mout.web.de ([212.227.15.4]:37615) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sqdiO-0007gt-HE for 73308@debbugs.gnu.org; Tue, 17 Sep 2024 15:18:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1726600677; x=1727205477; i=michael_heerdegen@web.de; bh=uAC/7ai2cteFAu+GxI8ZvNfMSIENk3Bty9HUPtMe4fM=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=MqVvXKf7uzz6sXFOyWyfxdBEPaBtcJe9QdwPggsCD3OZcwbL/k6hV+W32O0WoPMd zRL/52L/1T0Ya/7xRGBsLOUMa6z+flhIPBUbX49/myoOs44il58+2pLRnd2XiXZfc GBRWXxpv2/xHSQnBJP5ACraTy8Kt23t/HSE5foRrxBdh+o+r5H0pVAnuxgePAxVdI ItI4VPH83/rIf1x+sxVn33xBtXtyRO0gecXrQECVfAx1ngX4BDl2DtE8drd/keUmq 7ukpgJ+7lMdYBSEQ1wR5633FLkuEnE3G9+TBso8ef9nRTrLZO0jDaq2BRufgLrYSU dtOixSXnBvvSvfaReg== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from drachen.dragon ([88.66.201.158]) by smtp.web.de (mrweb006 [213.165.67.108]) with ESMTPSA (Nemesis) id 1MVacq-1sRImn11Ua-00QFgN; Tue, 17 Sep 2024 21:17:57 +0200 From: Michael Heerdegen To: Thierry Volpiatto Subject: Re: bug#73308: [PATCH] Add file-to-register and buffer-to-register. In-Reply-To: <87jzfamkv2.fsf@posteo.net> (Thierry Volpiatto's message of "Tue, 17 Sep 2024 14:10:41 +0000") References: <877cbbrx7r.fsf@ocathain.ie> <86msk6bhfa.fsf@gnu.org> <87jzfamkv2.fsf@posteo.net> Date: Tue, 17 Sep 2024 21:18:49 +0200 Message-ID: <877cbagkbq.fsf@web.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:gWrL/7zSD90j62OVbUBbGudlSKpZGwth5q9nf9a4hSeMnSGKyt1 8IQNef57KsFYSCIQqH69EhYtXov8zdJuyC08YOyp6cE30wysu5/FynY4LEYI8ghWlaWL9z3 o88kaYQAu81RJbVY26nmAn5xyiO2SDrTAuQVA1Td9U1HOGOMRv+J/FHnxs3tOBG1rVejqxb VHRYUvS0WMRDw7CCPlxqw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:yBLaTBS3ZpI=;OMiyzDMCN8kBuHzG9U3H2HXFZpP M06WHqBqP7w0+LP9LccgVVRNf86hOm6kxhVJnQIydFO66zm5Lb2bkvNbDVqIjstZySznjsl6P izBY8qTASdNynVf+XXz6fQB8p6U2TL+uBgvU9mcWUiXYxMMA9tBe4HNOF8rtL6ZT+EWYAs7sx aq4kNE8nL5Tt9yrzAEO160Mu+DVn39DvFJ8xVBwHQSQaRaEUie84kzfya9LgdjgEiWySPEOLh hieui4LDT6LEdKE/74X4e/BjzSKYkL/sHY3riIUrWg/0X/daWDJ7OBV+o4/CAbTfEIt6eCZb7 P3CNs+nwtYsUwRrUwAitQermufpztDOc+1Qi0YOJzgfB/wKysMVXfHGQD35Ii9DBnBbNAOivh +xuD86+aJGWWmoiGJamizeyf68w4ohH97aA3v3NlqdN4UqMsiLnrbJnc2mciTfnMDhR8AG5II 0oPZa1nwwKimGGov7hNNqpPN9FZt/XOZDwsRqb2nrua5sWPhdJ23omd9JZ9XbT2hqwhTfFkzc MQsKRsNFsbfKkJz7qoPWE+yXYEI1T83owO8tWAlNBSXAG1Bc8GnrU2cqGDt2+dBrqWqAsNRsS ckccabjcHj5VR00JPKsaxMWu4vE+f+HgtmHjBd9Zxgl3deeGCmp0E08s+9dpBRxpL4k8WXPj7 BNQZUgHs1NkkA+8AVYcli5yucqq+NcfGaohQZJK0CjDyMxKDhhCBpt6vAF/IqXGK5SUihykcg Rr0A/e1HjYMM/Dg4j2PwBI0FwKQbiIUTEJeVdUOUN5N3qwoThsNPtsGSd6S/jSm6QE+hwakKQ YnrdFUjPnLxR0xpybCJpSpsw== X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 73308 Cc: Eli Zaretskii , Barra =?utf-8?B?w5MgQ2F0aMOhaW4=?= , 73308@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Thierry Volpiatto writes: > More or less you can have the same with point-to-register, the advantage > is that when you kill the buffer, the register-alist entry is turned in > a file-query entry (when buffer is representing a file of course), for > example from register.el buffer: > > C-x r RET I'm worrying a bit: with this patch we would have 3 different types of registers that would really be very similar. The user would have to think about which is appropriate when setting the register. Or - if the question doesn't matter - why have 3 different types? Michael. From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 17 22:19:29 2024 Received: (at 73308) by debbugs.gnu.org; 18 Sep 2024 02:19:29 +0000 Received: from localhost ([127.0.0.1]:56772 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sqkHw-0006Eo-Qs for submit@debbugs.gnu.org; Tue, 17 Sep 2024 22:19:29 -0400 Received: from abi149bb127.cwl1.oracleemaildelivery.com ([129.149.22.127]:39799) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sqkHu-0006EU-DC for 73308@debbugs.gnu.org; Tue, 17 Sep 2024 22:19:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=ocathain-2023-02-08; d=ocathain.ie; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender:List-Unsubscribe:List-Unsubscribe-Post; bh=2Awcc5ahacknX8KHD2krTZLCM+y3ULPGt1C9oRO/4+A=; b=YQf+HHQxhYMuVoLoClQYKnbFaZJJoBEKMSqyLwiFUAIhh2rX9TgICWVxtfA2/AI8WwSKfG63rMCh eFPfMfG1acUl4t3xkD/oHIpFed+HVlzccfMTO+1RDPdBhcq/xiCDmFFA3dLOIMLROaNM6LWmFJ8X iWOhdgl5gxob4MmSZ6iWzzQq9Tn2WO0TcyxN9XjoVPqhf+N/iBAyTv4yqqfaxJ8Q6cIob/XEjA9g YBwSJ7d4VMxV6OJ54tqKVZjsc15dQ7ET+9R0rWIQ9MwcRNXj8Bchmof7zSajt+aj6qUcBPbOOZfN Toem2/xumfLc2ruPqfgLD5CE1BzknozslmCLrA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-cwl-20201026; d=cwl1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender:List-Unsubscribe:List-Unsubscribe-Post; bh=2Awcc5ahacknX8KHD2krTZLCM+y3ULPGt1C9oRO/4+A=; b=BZj6Gq+IcePQXivNEHKkCrxU1a8VOYqNxNsmmeBDzoHh22k92/D57EQoh/PxxmcxtM+ftLrdwG5Y fdpbyzyth+aFxv19rE3tj1cqm08FSx6LlPTDhHrmfRI44sE95UYbxFwiX2hShhhsCJzp4KoWoGIU jVkbWoqOEGmssnUKC8eOFTdAM5yD9/Y3qxDxFgL+s8F3Qu5UagXHWfy14OqhvFrmpIcO3knfqpHd SrF3NfAFkvhZeaiic0PYbKWuGwmCvb8NXK3kojJ4QhtieaL9eErWxZLRz3UTin5PXtjz0sI5bo33 EDrqNttgLqVHTZjcf5DHwktvBSn6ERuJpcer9A== Received: by omta-ad1-fd3-401-uk-cardiff-1.omtaad1.vcndpcwl.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20240709 64bit (built Jul 9 2024)) with ESMTPS id <0SJZ00MKFL3RC6C0@omta-ad1-fd3-401-uk-cardiff-1.omtaad1.vcndpcwl.oraclevcn.com> for 73308@debbugs.gnu.org; Wed, 18 Sep 2024 02:19:03 +0000 (GMT) List-Unsubscribe-Post: List-Unsubscribe=One-Click From: =?utf-8?Q?Barra_=C3=93_Cath=C3=A1in?= To: Eli Zaretskii Subject: Re: bug#73308: [PATCH] Add file-to-register and buffer-to-register. In-reply-to: <86msk6bhfa.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 17 Sep 2024 15:20:25 +0300") References: <877cbbrx7r.fsf@ocathain.ie> <86msk6bhfa.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Date: Wed, 18 Sep 2024 03:19:02 +0100 Message-id: <87setxu2jt.fsf@ocathain.ie> MIME-version: 1.0 Content-type: text/plain Reporting-Meta: AAEfxc7rOMSTl9K3Q0OZCXlc6jadVj+vZqVYkncXJjIrKVtMMAbm+N4M/pv9NJXm Wl623HP2AIc+pBkLhN1gw6EVg+DfbRR8NlUa14yiFLb1cyLVdsCAtAIpfR3q/DJI F9/DcqQr965gT0UA+M8HOGOSban1eSf4DReCf1WsOEog3f83epzdJqHUT7EcwLD+ uxQ9Nww+wkisWX+rrPOrQqLhtZaPB682aVHipihtdNbPFQbfQvFGP0IM8irIZLA3 kN2U938Hpz/tsiW4AWoM5a/TZIQYBvYmcz0sFTlGh0q/WiOCyGd8jDD7muDVgYV1 wwylGrQQ2PVSzJYmkFzKadXjCBZ5HNR+njyQD1IEpkfGtazOPuw8xleQJGKogknc Ah4RpUGYjYmK77leHoVKp+8TiBir/9u2GcpJ5eXQDPYCC89Q5x8Fi8vsU/aoOaYK 9aCWch2WmcrryzQh48rqnZP9nO961NtW8bWyqbPRdP+FKIqpCAxv5jyX X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 73308 Cc: 73308@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) Thank you, Eli, will look at this either tommorrow or the day after and clean up the patch. For my own sake: - Clean up the git log entries. - Place index entries before the item, and fix the duplication for kindex (I don't even honestly know how I managed to get it into that state, I remember writing the two commands but clearly I'm misremembering) - Bring descriptions more in line with the style, see position registers - Two spaces, US english - One table, not two. - Verb at start of doc string - News entry. Thanks for your time. ----- Barra From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 17 22:27:25 2024 Received: (at 73308) by debbugs.gnu.org; 18 Sep 2024 02:27:25 +0000 Received: from localhost ([127.0.0.1]:56779 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sqkPc-0006rP-SO for submit@debbugs.gnu.org; Tue, 17 Sep 2024 22:27:25 -0400 Received: from abi149bb126.cwl1.oracleemaildelivery.com ([129.149.22.126]:38835) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sqkPa-0006qw-OP for 73308@debbugs.gnu.org; Tue, 17 Sep 2024 22:27:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=ocathain-2023-02-08; d=ocathain.ie; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender:List-Unsubscribe:List-Unsubscribe-Post; bh=NZVsb+yEGScv/z4c57vi4vOWqh46wZO+wlk4x7xaM+Q=; b=eWGONTZiniDQgMbkKP/3VBzaliZKqZ9GYPt+LT6bQkwgp8PPn58o9XSyV8WooEwfLLk7U+aaoudd SxV+g5qrPX1onyw81QwzoLAuzob4OIed1R2NL5T3obxQcfsOfiydEvwsDMvu+JV37Ehe+e+TNiNA JQZBnMjFjwP3wK6JlcjSiSCO68lIPzTPfCOu72SEgrJ2zfcTtNy24KbpTv5/HIMpSmSRmcjAV0JI ZEA9UpC3LC14F3JGuQSzgpF2OVGlWQv3w8fHzEvZbYtlsz+2jWWFkTlvxBDox1Zt8qs3W56zVbjP 8NrSeDcpdG4OPpTS1hAME9ANOEBE+eVK+3B0pA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-cwl-20201026; d=cwl1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender:List-Unsubscribe:List-Unsubscribe-Post; bh=NZVsb+yEGScv/z4c57vi4vOWqh46wZO+wlk4x7xaM+Q=; b=BPLe7GLgbv+8/COjuut+tLHfMPkUASLurVCsCHSDBuAyQhZh6MqPrusld9kFzIACa/HCSNRUczRR XXku7W0VGJwJu9hoDnFzBqKzTBWw4J674jAyjdrVHhxqrGeZXYDD9CAFMlDkKBTX2keTuJ/9UraT h/1/30WRqcni2/Elt4QsLCTrTmPFGv10n7bObwVBY0r1UHzhopRHOCMdET4iFGA3PwQasdrl1A5E sbkTCLo05QQ4I7H7Yo90R+OZM6lgkhuzfpx3QcS+Q2ew3ajkxMVVvfWOI161ULPWYzz9PaH6E6p/ Gg+Mtim6BRws12cps0AF1oWhNsMJCmJ6LESwSg== Received: by omta-ad1-fd2-401-uk-cardiff-1.omtaad1.vcndpcwl.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20240709 64bit (built Jul 9 2024)) with ESMTPS id <0SJZ0060PLGZI820@omta-ad1-fd2-401-uk-cardiff-1.omtaad1.vcndpcwl.oraclevcn.com> for 73308@debbugs.gnu.org; Wed, 18 Sep 2024 02:26:59 +0000 (GMT) List-Unsubscribe-Post: List-Unsubscribe=One-Click From: =?utf-8?Q?Barra_=C3=93_Cath=C3=A1in?= To: Thierry Volpiatto Subject: Re: bug#73308: [PATCH] Add file-to-register and buffer-to-register. In-reply-to: <87jzfamkv2.fsf@posteo.net> (Thierry Volpiatto's message of "Tue, 17 Sep 2024 14:10:41 +0000") References: <877cbbrx7r.fsf@ocathain.ie> <86msk6bhfa.fsf@gnu.org> <87jzfamkv2.fsf@posteo.net> Date: Wed, 18 Sep 2024 03:26:58 +0100 Message-id: <87ldzpu26l.fsf@ocathain.ie> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-version: 1.0 Content-type: text/plain Reporting-Meta: AAEfxc7rOMSTl9K3Q0OZCXlc6jadVj+vZqVYkncXJjIrKVtMMAbm+N4M/pv9NJXm Wl623HP2AIc+pBkLhN24xaEVg+DfbRR8NlVvdYDRW8L5AZSjItSwFk4v9VR/HH3S DFUfU8ejQGBpvjFtyHshLtHaoyVD/OFiYnwPciaqRssFPomHTYOzECSSTMLHNU9H uVsHOXsz/TcHNj66i9vJ9hHMudM8oAq/lG0WwlcZAVTc+KlwY5iM/UBT3sXgs9WT WaDg6+ngd9FSmpviPTsHgsApwLRxIGDe0q4MiFT/9gt7eV0QA343nbYkqW7lD+UZ Se3bs/JS4vvWAafL3RYoD3HV+chcL2REVh5ZO0oXzBzRsfyskqq7DkeyxJiikpBH 8snOm5m95bVGLPCAloQy2tu8SBLn/yf8v1AENVn/QoiguOkrCkoiIUL7sR7UDpqI M+ue/AYWhB19lfLGlxowKyFZI3WnENwroARBHFNLUnNrZqXbnKuDJuZcfA== X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 73308 Cc: Eli Zaretskii , 73308@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) Thanks, Thierry. I'll look into how point-to-register does things and see if I can improve things alongside. Thanks for your time! ----- Barra Thierry Volpiatto writes: > One comment about buffer-to-register: > > More or less you can have the same with point-to-register, the advantage > is that when you kill the buffer, the register-alist entry is turned in > a file-query entry (when buffer is representing a file of course), for > example from register.el buffer: > > C-x r RET > > register-alist entry: > (115 . #) > > Now kill the the buffer, the register-alist entry is turned in: > (115 file-query "/home/thierry/work/emacs/lisp/register.el" 27354) > > This is why I guess such functions where never added to register.el. > > OTOH they provide an alternative which is easier to find as most users > don't know about this feature (buffer => file-qurey). > > BTW I suggest you use for buffer-to-register an entry something like > (buffer-name . marker), this way register-swap-out will be able > to transform it like point-to-register does. Need also to add a add-hook > call like point-to-register does. From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 17 22:52:15 2024 Received: (at 73308) by debbugs.gnu.org; 18 Sep 2024 02:52:15 +0000 Received: from localhost ([127.0.0.1]:56798 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sqkne-0000FB-L2 for submit@debbugs.gnu.org; Tue, 17 Sep 2024 22:52:15 -0400 Received: from abi149bb126.cwl1.oracleemaildelivery.com ([129.149.22.126]:39399) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sqknc-0000Ek-Hc for 73308@debbugs.gnu.org; Tue, 17 Sep 2024 22:52:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=ocathain-2023-02-08; d=ocathain.ie; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender:List-Unsubscribe:List-Unsubscribe-Post; bh=hqsiVFXlINPmtVeGd3FLvEcUec3FZGdKPYol92Yh7iI=; b=Fj3/6vvFtsPhsCJMTVDJfg2lem4UYQId0TdMl6E20SE4eQGbgiBL7RBqu/i0ILAaHMOUBGPcQfqa P9t28oLaVJab5uhaQpP47qTGw1JwlzqoHzINnblDaLHbgNULHSUMPC3Pa1RQGrHnbQW3JaIdzpg6 as7SDN86/d94f/IJW+57vjkNDZb65ihks4VPlS2uoRle0x6TAB9sFuBbKMooKuRBlFrZSKk/msEz guNPRj+Wx+QWD6eODi+1BWBpNbga7xtRzxMaTLeBm4cUrLZPDsLm/vqYiq13doNYX5X7fsc4KvVK q2dm55RRaS1J4dcBu/M8Q1dvhxUMRKsEl5PPVg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-cwl-20201026; d=cwl1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender:List-Unsubscribe:List-Unsubscribe-Post; bh=hqsiVFXlINPmtVeGd3FLvEcUec3FZGdKPYol92Yh7iI=; b=XFQIGUd3M+BvUeskYKs+9a198dzvlxFAaFI6UL0ubnuK3cORqR96jfWY2jJxzh5VaJJ0m+Rlcxnn e81zEQJtlDYBg8gJN+xOagMXXSm7Qynw0dh2uryJBLyH/5zy2Fk+en+PLHM+k++PqGq8VhrM8h4C 3nXu4BEZRj94UxLDAoATXFv9/cKzn0uapCRiyyzT8uWtFQBLZKADhpEMEHrRjq1kUxUqW8zsqqoC FSdJaPM5MTjRfQ6JiNIyYcoQjTzsya+6i1l1KJkQj+a424vZRVapin3SqbRAcrQ8/eNsqdfZLuFL K0gbAWVldmxZqoWXdf8ZsL9k7wlWKCTnglHOMw== Received: by omta-ad1-fd2-401-uk-cardiff-1.omtaad1.vcndpcwl.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20240709 64bit (built Jul 9 2024)) with ESMTPS id <0SJZ00FM8MMCGP20@omta-ad1-fd2-401-uk-cardiff-1.omtaad1.vcndpcwl.oraclevcn.com> for 73308@debbugs.gnu.org; Wed, 18 Sep 2024 02:51:49 +0000 (GMT) List-Unsubscribe-Post: List-Unsubscribe=One-Click From: =?utf-8?Q?Barra_=C3=93_Cath=C3=A1in?= To: Michael Heerdegen Subject: Re: bug#73308: [PATCH] Add file-to-register and buffer-to-register. In-reply-to: <877cbagkbq.fsf@web.de> (Michael Heerdegen's message of "Tue, 17 Sep 2024 21:18:49 +0200") References: <877cbbrx7r.fsf@ocathain.ie> <86msk6bhfa.fsf@gnu.org> <87jzfamkv2.fsf@posteo.net> <877cbagkbq.fsf@web.de> Date: Wed, 18 Sep 2024 03:51:47 +0100 Message-id: <87h6adu118.fsf@ocathain.ie> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-version: 1.0 Content-type: text/plain Reporting-Meta: AAF5j09jcVJRV5CrI0aaTEnkK3zY4BLnqyUOstoqyB7/pDjK/o0npEYCMTSPezqu WEwRY9Vls+cJyViHfgSALZKQUACb1rzoLJAB1gQJ2Kyjii49nqaJU4BEGWapORmJ eZkbk/M7PPkWWakTykCg9n/vRE4pfITbJf4oOMsQVyXIBbPbviirVpdfTNN5AvVx x3uYxZpUATn14NDXsv58RZf7wZ0+RFB8/aIwPPnjFfJ/Eo+okdzd+aBfwNxmM84F QULOUIerdZ3flekjuUj/dMcsUBdRPjIV9QX9hk9xD3TtD6d724kHveCqVm6hIs8h PasmrCVnhjNqjysMkue9WNAWQt3ESwiWcQWYTLnVjG66eMZWSSt0QrMKs9Hudwy5 v/D2sDKCQ6IjJwXylgaYiygoZsT7OeqCasE3GtaB9luMzKncYXX0l7c9uJWOH2rm zqmXKmy6BzmbsCTqLNtjyNn5fevSWm+Nur+tTeRQcO9ad73Y9BYKBFIXbg== X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 73308 Cc: Thierry Volpiatto , Eli Zaretskii , 73308@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) Perhaps the easiest way to demonstrate the differences I saw in their usage is to explain why I chose to wrote them and not use point-to-register: I use buffer-to-register when I'm working with lots of different buffers but I don't wish to disturb the point when switching back to them. For example, running long commands in a shell window or even just different files that I'm bouncing between, rather than dancing with switching buffers through one of the other means. I use file-to-register to pre-load notes files into registers on startup. It visually makes more sense to read in an init-file. Frankly, in interactive use I haven't found a real use for file-to-register, but I also saw no reason not to bind it. I think the main benefit to this is discoverability. Let me know if I can clarify anything for you further with this. ----- Barra Michael Heerdegen writes: > Thierry Volpiatto writes: > >> More or less you can have the same with point-to-register, the advantage >> is that when you kill the buffer, the register-alist entry is turned in >> a file-query entry (when buffer is representing a file of course), for >> example from register.el buffer: >> >> C-x r RET > > I'm worrying a bit: with this patch we would have 3 different types of > registers that would really be very similar. The user would have to > think about which is appropriate when setting the register. Or - if the > question doesn't matter - why have 3 different types? > > > Michael. From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 24 10:10:07 2024 Received: (at 73308) by debbugs.gnu.org; 24 Sep 2024 14:10:07 +0000 Received: from localhost ([127.0.0.1]:46538 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1st6Ew-0003iH-TU for submit@debbugs.gnu.org; Tue, 24 Sep 2024 10:10:07 -0400 Received: from abi149bb125.cwl1.oracleemaildelivery.com ([129.149.22.125]:40169) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1st6Et-0003hc-Mm for 73308@debbugs.gnu.org; Tue, 24 Sep 2024 10:10:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=ocathain-2023-02-08; d=ocathain.ie; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender:List-Unsubscribe:List-Unsubscribe-Post; bh=OnoZzwfrBaRXfRsX30D5B57bTUA4TQ2ciafj1aGnP70=; b=vpTkoZPzj+P8M8ElVV8bjKZt78L0WCjlI9EhPpvZxmPXWc78lS0Ln2idQgfAxMM3pQ2VDlZa2R/D mnai7eGHLjH36ZxVewQiTl0LMuS7yJsqyZ0/rnPjvfFC90eNty3IgSKGTBvj14wOPnt00P4bgyRI TFUC44vEVBLHNCzpTV0CiqTZRtjzTuTsR6jrLEGr4SjY8MD3mqMJVB4UF7MVT+a+sHzM65johDdT rSKd3AYasKT0kl8bmZb01Xv9O2sdbm0q7jPslznLVubWu5VcJq/uhyJREuUKcF1M9exIhGG5Emjc 8SXNy4f8gtkZezvxvEcnbdyCq0hbF24Gvb+wRg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-cwl-20201026; d=cwl1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender:List-Unsubscribe:List-Unsubscribe-Post; bh=OnoZzwfrBaRXfRsX30D5B57bTUA4TQ2ciafj1aGnP70=; b=V2af5JtmxtMZW580HxhPAfkIQrz6YRy6v3oAIOwo1ocOhlZW6GvxGNdWcaB+xYN5vSjBMxD1u+0w wihwqGRX9dp76TKcbTzP0c/yIgYWXx7kZqQ8SziLji8nyUTwCHVbZ0LrIAdK0nA/dO6QHqCDC9OF USGyWpXNbmcoToi6fET6HLX4OdBrA8v5xsAo/SBPJj9YUo/oJU4fzz5uin0W5kufYTtdpO69yGxA jviyFBTqy8Z13tH3UXGDMsipPTmsnIcbb+sWm3IpPwCtfPQfoy8vnfZweqivIo2ZEfQnaUv+Nt82 cJGa/B1DbW4PLLe+ZM5GDOMOO+X1N4kGkDOFZQ== Received: by omta-ad1-fd1-401-uk-cardiff-1.omtaad1.vcndpcwl.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20240709 64bit (built Jul 9 2024)) with ESMTPS id <0SKB006BQLZWC6A0@omta-ad1-fd1-401-uk-cardiff-1.omtaad1.vcndpcwl.oraclevcn.com> for 73308@debbugs.gnu.org; Tue, 24 Sep 2024 14:09:32 +0000 (GMT) List-Unsubscribe-Post: List-Unsubscribe=One-Click From: =?utf-8?Q?Barra_=C3=93_Cath=C3=A1in?= To: 73308@debbugs.gnu.org Subject: Re: bug#73308: [PATCH] Add file-to-register and buffer-to-register. Date: Tue, 24 Sep 2024 15:09:31 +0100 Message-id: <87plotw3c4.fsf@ocathain.ie> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-version: 1.0 Content-type: multipart/mixed; boundary="=-=-=" Reporting-Meta: AAGchsu9y0xMfWmlvcbAegjF5BA0lRZWIsGU0C5AG/M9dOb1IuD6TuvLPWsr52qQ jx4rQR58RldxeYKrVnJs7+lBRjHMbhKKN/Sg5+8eZbGHZLrc+6s4EmbEjPduBEo0 cUTfhFdGarKI9tyjLa0Y2zc5v0qXElm1fO9A72+m8CIMzLSBaDPuPlPi5+aK7iaF dRUxo9EJuHac+OmNCZRavgKNa29l+FVaapSgUlNHN3PM+zdIP3c/XseL7qL78v67 /5gvluRZMq5C56ulxe2cztRlIHR8QZX2e2apfh9R0uK1sWt/dKYXvCZTyUKVGhOT K2RBMsvhfh42s1wmf78oU7t3pOzJPQ/PVxRvchfXGQmGclWSHn+CByYUcndXvC/0 +zsz9UJ+s2a/6jQH5P9eU8xvSmd/eP0EP0B6ZNvdYsr/OElp2f7LJRudSzhl9Itt kUxasKXDNktuCcyezo5l6tE/GvZpEmhtEWPePIK+GEM6HoGka1mKWweQcw== X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 73308 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) --=-=-= Content-Type: text/plain I've updated the patch to include the feedback given previously; as always, further comments/feedback are appreciated! ----- Barra --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-Add-file-buffer-to-register-Bug-73308.patch Content-Transfer-Encoding: quoted-printable >From e4712ad55d21fea14309316b8437b4a01c98280d Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Barra=3D20=3DC3=3D93=3D20Cath=3DC3=3DA1in?=3D Date: Tue, 24 Sep 2024 14:19:55 +0100 Subject: [PATCH] Add file/buffer-to-register (Bug#73308) * doc/emacs/regs.texi (File and Buffer Registers): Updates documentation to refer to file-to-register and buffer-to-register. * etc/NEWS: Announce the new commands. * lisp/bindings.el (ctl-x-r-map): Map new commands into the register keymap. * lisp/register.el (register-command-info): Register new commands. (jump-to-register): Remove docstring line referring to using set-register instead of new commands. (file-to-register): Add function for storing files in registers. (buffer-to-register): Add function for storing buffers in registers. (register-buffer-to-file-query): Add function for converting buffer registers to file-query registers on killing a buffer. --- doc/emacs/regs.texi | 65 ++++++++++++++++++++++----------------------- etc/NEWS | 7 +++++ lisp/bindings.el | 4 ++- lisp/register.el | 55 +++++++++++++++++++++++++++++++++++++- 4 files changed, 96 insertions(+), 35 deletions(-) diff --git a/doc/emacs/regs.texi b/doc/emacs/regs.texi index 734d704a272..df3c22742b6 100644 --- a/doc/emacs/regs.texi +++ b/doc/emacs/regs.texi @@ -290,40 +290,39 @@ File and Buffer Registers @cindex saving file name in a register @cindex saving buffer name in a register =20 - If you visit certain file names frequently, you can visit them more -conveniently if you put their names in registers. Here's the Lisp code -used to put a file @var{name} into register @var{r}: - -@smallexample -(set-register @var{r} '(file . @var{name})) -@end smallexample - -@need 3000 -@noindent -For example, - -@smallexample -(set-register ?z '(file . "/gd/gnu/emacs/19.0/src/ChangeLog")) -@end smallexample - -@noindent -puts the file name shown in register @samp{z}. - - To visit the file whose name is in register @var{r}, type @kbd{C-x r j -@var{r}}. (This is the same command used to jump to a position or -restore a frame configuration.) - - Similarly, if there are certain buffers you visit frequently, you -can put their names in registers. For instance, if you visit the -@samp{*Messages*} buffer often, you can use the following snippet to -put that buffer into the @samp{m} register: - -@smallexample -(set-register ?m '(buffer . "*Messages*")) -@end smallexample +@table @kbd +@item C-x r F @var{r} +Store the currently visited file or directory in register +@var{r} (@code{file-to-register}). +@item C-x r B @var{r} +Store the currently visited buffer in register +@var{r} (@code{buffer-to-register}). +@end table =20 - To switch to the buffer whose name is in register @var{r}, type -@kbd{C-x r j @var{r}}. +If you visit certain files or buffers frequently, you can visit them +more conveniently if you put their names in registers. + +@kindex C-x r F +@findex file-to-register + Typing @kbd{C-x r F} (@code{file-to-register}), followed by a +character @kbd{@var{r}}, saves a reference to the currently visited file +in register @var{r}. You can then visit the file using +@code{jump-to-register} by typing @kbd{C-x r j} @var{r}. With a prefix +argument, @code{file-to-register} prompts for a file name to store in +the register. + +@kindex C-x r B +@findex buffer-to-register + Typing @kbd{C-x r B} (@code{buffer-to-register}), followed by a +character @kbd{@var{r}}, saves a reference to the currently visited buffer +in register @var{r}. You can then revisit the buffer using +@code{jump-to-register}. With a prefix argument, @code{buffer-to-register} +prompts for a buffer name to store in the register. + + If you store a buffer name which is visiting a file in a +register, and the buffer is then closed, the register is automatically +converted to a file reference, allowing you to quickly re-open the +closed file. =20 @node Keyboard Macro Registers @section Keyboard Macro Registers diff --git a/etc/NEWS b/etc/NEWS index b52ad001a2e..cae5452ec85 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -114,6 +114,13 @@ This hook allows you to control which tab-bar tabs are= auto-resized. *** New command 'project-root-find-file'. It is equivalent to running =E2=80=98project-any-command=E2=80=99 with =E2= =80=98find-file=E2=80=99. =20 +** Registers + +*** New functions 'buffer-to-register' and 'file-to-register'. +These allow users to interactively store file and buffers in registers. +Killed buffers stored in a register using buffer-to-register are +automatically converted to a file-query value if the buffer was visiting +a file. * Editing Changes in Emacs 31.1 =20 diff --git a/lisp/bindings.el b/lisp/bindings.el index 6b34c5750c1..06a488fa9fa 100644 --- a/lisp/bindings.el +++ b/lisp/bindings.el @@ -1574,7 +1574,9 @@ ctl-x-r-map "n" #'number-to-register "+" #'increment-register "w" #'window-configuration-to-register - "f" #'frameset-to-register) + "f" #'frameset-to-register + "F" #'file-to-register + "B" #'buffer-to-register) (define-key ctl-x-map "r" ctl-x-r-map) =20 (define-key esc-map "q" 'fill-paragraph) diff --git a/lisp/register.el b/lisp/register.el index 497848ded1e..ed7b4402a3f 100644 --- a/lisp/register.el +++ b/lisp/register.el @@ -300,6 +300,18 @@ register-command-info :act 'set :noconfirm (memq register-use-preview '(nil never)) :smatch t)) +(cl-defmethod register-command-info ((_command (eql file-to-register))) + (make-register-preview-info + :types '(all) + :msg "File to register `%s'" + :act 'set + :noconfirm (memq register-use-preview '(nil never)))) +(cl-defmethod register-command-info ((_command (eql buffer-to-register))) + (make-register-preview-info + :types '(all) + :msg "Buffer to register `%s'" + :act 'set + :noconfirm (memq register-use-preview '(nil never)))) =20 (defun register-preview-forward-line (arg) "Move to next or previous line in register preview buffer. @@ -672,7 +684,6 @@ jump-to-register Push the mark if going to the location moves point, unless called in succe= ssion. If the register contains a file name, find that file. If the register contains a buffer name, switch to that buffer. -\(To put a file or buffer name in a register, you must use `set-register'.) If the register contains a window configuration (one frame) or a frameset \(all frames), restore the configuration of that frame or of all frames accordingly. @@ -688,6 +699,36 @@ jump-to-register (let ((val (get-register register))) (register-val-jump-to val delete))) =20 +(defun file-to-register (file-name register) + "Insert FILE-NAME into REGISTER. +To visit the file, use \\[jump-to-register]. + +Interactively, prompt for REGISTER using `register-read-with-preview'. +With a prefix-argument, prompt for FILE-NAME using `read-file-name', +With no prefix-argument, use the currently visited file or directory for F= ILE-NAME." + (interactive (list (if (eq current-prefix-arg nil) + (if (eq major-mode 'dired-mode) + (dired-current-directory) + (buffer-file-name)) + (read-file-name "File: ")) + (register-read-with-preview "File to register: "))) + (unless (eq file-name nil) + (set-register register (cons 'file file-name)))) + +(defun buffer-to-register (buffer register) + "Insert BUFFER into REGISTER. +To visit the buffer, use \\[jump-to-register]. + +Interactively, prompt for REGISTER using `register-read-with-preview'. +With a prefix-argument, prompt for BUFFER-NAME using `read-buffer', +With no prefix-argument, use the current buffer for BUFFER." + (interactive (list (if (eq current-prefix-arg nil) + (current-buffer) + (read-buffer "Buffer: ")) + (register-read-with-preview "Buffer to register: "))) + (add-hook 'kill-buffer-hook 'register-buffer-to-file-query nil t) + (set-register register (cons 'buffer buffer))) + (cl-defgeneric register-val-jump-to (_val _arg) "Execute the \"jump\" operation of VAL. VAL is the contents of a register as returned by `get-register'. @@ -739,6 +780,18 @@ register-swap-out buffer-file-name (marker-position (cdr elem)))))))) =20 +(defun register-buffer-to-file-query () + "Turn buffer registers into file-query references when a buffer is kille= d." + (and buffer-file-name + (dolist (elem register-alist) + (and (consp (cdr elem)) + (eq (current-buffer) (cddr elem)) + (setcdr elem + (list 'file-query + buffer-file-name + (point))))))) + + (defun number-to-register (number register) "Store NUMBER in REGISTER. REGISTER is a character, the name of the register. --=20 2.46.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 29 21:38:05 2024 Received: (at control) by debbugs.gnu.org; 30 Sep 2024 01:38:05 +0000 Received: from localhost ([127.0.0.1]:43498 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sv5MS-00084E-PC for submit@debbugs.gnu.org; Sun, 29 Sep 2024 21:38:05 -0400 Received: from mail-ed1-f45.google.com ([209.85.208.45]:42087) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sv5MQ-00082g-L6 for control@debbugs.gnu.org; Sun, 29 Sep 2024 21:38:03 -0400 Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-5c40aea5c40so6938973a12.0 for ; Sun, 29 Sep 2024 18:37:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727660185; x=1728264985; darn=debbugs.gnu.org; h=to:subject:message-id:date:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=AaHUxukW59GV3w+hr2R6x7MsrqgsP6u78tTjAU02lrA=; b=UFw8LHIdravVbZbhUirW/Dk3hDeshPoAldIjC3XK9ZFtpRa1vWxyHGTkG2RAC72VFO pGnF/XcDAMeBC4z0aAJMqXmYUcEmbcMvmXoG5g/pctyZUcswGG8WBxFjWKEh7aOhdPMc VsQpDAC7ZluM6aPDI6qr7zkD/uLvXB0Ja9L5MVWl5apXn/WeV3rT1ndu6p2lKt+JpA6G Sr91+GQcBv5aQaAk91BYrXQCN41PxTHRoa9praIriByT6FXFZMvBpgc3IhjQtBatf736 sXiPVlFxc3k5c/EBYtqlDkl9dX441yCigjzTcdO7+xCJKs8YHXxBu37c+vxIXQoFoiTl tRDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727660185; x=1728264985; h=to:subject:message-id:date:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=AaHUxukW59GV3w+hr2R6x7MsrqgsP6u78tTjAU02lrA=; b=KGxVNvGABZW5W0x2cyzPc0bZ128dAD6KNvHdXOYg9hmQnHWJ/W+k7DmFDHdURjMAJj nBet9C3RNahQmhBefZ252NZ4kSFnQybyNLwyLTX134g/BGyXsAU4C4BKK85AFe+BiaVL yhhstnPlHD869BFcvntpihoMwXUVW/VkPI7NdvIpkQXEbrHBodwLcYxvj7fii1wdlfLg hb+714cQwPYQd6446wJZ418SbD3bluLFYWQr+5EXqbLr3vBd5V8XILhY7uiYODoujfBz vsUaccvIyMddBMw5FMVFwcko2zXtcgii6DO25wzvNAkko2U+njAwQzaqL/3fth55vvwC VeSQ== X-Gm-Message-State: AOJu0YxavMFSdKzrv6Q9KlFJpnBxolTaq9BBNpQUB+N9py50C4ZnTlQ5 PqdCCPoYXn/0Y+czzKoSYi56JrfXOsL0Q8357MfzfgNQG8n6B4cbJMbm6KXZC6I1biArHQfgPXf 2SIWUR2N5olA+di+7WKvnc8OpyEVPRQ== X-Google-Smtp-Source: AGHT+IHv2+FY1VuyidgKYXZ5Mb6FRM0Fg4n6tA04c/0xFENCkJ4OfMVwdxT0xJ821fPNEimp5Jj/xAprMLtYubzs12k= X-Received: by 2002:a05:6402:4406:b0:5c8:8d61:9bb6 with SMTP id 4fb4d7f45d1cf-5c88d619c25mr6159429a12.6.1727660184815; Sun, 29 Sep 2024 18:36:24 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sun, 29 Sep 2024 18:36:24 -0700 From: Stefan Kangas MIME-Version: 1.0 Date: Sun, 29 Sep 2024 18:36:24 -0700 Message-ID: Subject: control message for bug #73308 To: control@debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: -0.9 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.9 (-) severity 73308 wishlist quit From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 05 06:08:27 2024 Received: (at 73308-done) by debbugs.gnu.org; 5 Oct 2024 10:08:27 +0000 Received: from localhost ([127.0.0.1]:37306 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sx1i7-0004iA-J5 for submit@debbugs.gnu.org; Sat, 05 Oct 2024 06:08:27 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46360) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sx1i5-0004hw-MP for 73308-done@debbugs.gnu.org; Sat, 05 Oct 2024 06:08:26 -0400 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 1sx1hv-0000QW-J9; Sat, 05 Oct 2024 06:08:15 -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=wVncDLhV0fiVqbxBYpLM/kDaY+Uwa1Gt8UkUE18rxWA=; b=Tf688YNafz3SRXb79YkZ lO+SLWlD3xPKGQ26cRKuSziwyjnYSwsoD4mSYhTxUqukn5yUvaDKzu9EwPfE7YdRxtqJk9vSJiikv AEuj0sR/dfXk4WlOOPVt86DRT0ZeGTJJ7dI6oxlf02vZ6gJ0P4uZB+aXt34uPq0jSanD8Z5N1GUcJ flbrU1DsnJdfy9zfPQr0dDomp8x+pJefP+kKJgrExZkE2pXk9z4eaFew5AL9cXfF7SQb/9NkchI6k viqs6Ciu8g7i28ulSOCsarvvojppS/oU16jg3NEY6spCZWlDjgpDXCYgrsxiWnkmNHwN6CpsVDJOC 1m4Xb51yFwAG8g==; Date: Sat, 05 Oct 2024 13:08:13 +0300 Message-Id: <86setax3oy.fsf@gnu.org> From: Eli Zaretskii To: Barra =?utf-8?B?w5MgQ2F0aMOhaW4=?= In-Reply-To: <87plotw3c4.fsf@ocathain.ie> (bug-gnu-emacs@gnu.org) Subject: Re: bug#73308: [PATCH] Add file-to-register and buffer-to-register. References: <877cbbrx7r.fsf@ocathain.ie> <87plotw3c4.fsf@ocathain.ie> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 73308-done Cc: 73308-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > List-Unsubscribe-Post: List-Unsubscribe=One-Click > Date: Tue, 24 Sep 2024 15:09:31 +0100 > From: Barra Ă“ CathĂ¡in via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > I've updated the patch to include the feedback given previously; as > always, further comments/feedback are appreciated! Thanks, installed on the master branch, and closing the bug. From unknown Fri Aug 08 22:23:50 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 02 Nov 2024 11:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator