From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Barra =?UTF-8?Q?=C3=93_?= =?UTF-8?Q?Cath=C3=A1in?= via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#68921: File and Buffer register functions. Date: Tue, 06 Feb 2024 22:42:26 +0000 Message-ID: <87h6ilqkod.fsf@ocathain.ie> References: <875xz5gtlm.fsf@ocathain.ie> Reply-To: Barra =?UTF-8?Q?=C3=93_?= =?UTF-8?Q?Cath=C3=A1in?= Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8213"; mail-complaints-to="usenet@ciao.gmane.io" To: 68921@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Feb 07 02:57:07 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 1rXXBR-0001u5-HM for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 07 Feb 2024 02:57:06 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rXXBD-00007n-6C; Tue, 06 Feb 2024 20:56:51 -0500 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 1rXXBB-0008TV-HW for bug-gnu-emacs@gnu.org; Tue, 06 Feb 2024 20:56:50 -0500 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 1rXXBB-0006TV-A4 for bug-gnu-emacs@gnu.org; Tue, 06 Feb 2024 20:56:49 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rXXBO-0006RL-Gg for bug-gnu-emacs@gnu.org; Tue, 06 Feb 2024 20:57:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Barra =?UTF-8?Q?=C3=93_?= =?UTF-8?Q?Cath=C3=A1in?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 07 Feb 2024 01:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68921 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.170727100924719 (code B ref -1); Wed, 07 Feb 2024 01:57:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 7 Feb 2024 01:56:49 +0000 Original-Received: from localhost ([127.0.0.1]:55454 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rXXBA-0006Qa-Bq for submit@debbugs.gnu.org; Tue, 06 Feb 2024 20:56:49 -0500 Original-Received: from lists.gnu.org ([2001:470:142::17]:47238) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rXUIh-0006uU-Ml for submit@debbugs.gnu.org; Tue, 06 Feb 2024 17:52:24 -0500 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 1rXUIO-0000rE-AL for bug-gnu-emacs@gnu.org; Tue, 06 Feb 2024 17:52:04 -0500 Original-Received: from abi149bb125.cwl1.oracleemaildelivery.com ([129.149.22.125]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rXUIM-00010H-4l for bug-gnu-emacs@gnu.org; Tue, 06 Feb 2024 17:52:04 -0500 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; bh=e89FRIq0JrFWw4iz1SNnSe69o0l+eF7cmUw3wIHKBjM=; b=QgJJdP+5ER9tJYShd4D5YqQY5BslSSnUuY9iPUVb+xpW9Wpve1+s5QCokNEK7RpcPejF7iT4XX4B 4NIcsBjGB2D4vPdeoDR0fL2NeBVPtCjz50CgXXbB++iGIJQIUKwsNB9gZz1wNqw0IegqAJ/EJjUs ExEqlBtHUGnKt8zyLS01P0Ff8M3pEPwx+8HqxaToibfbLG1DCB+NHsjY3baMDCbvwmnuzF3Ew5vE iO2D17d3fNMzGplRc+IpCI3u5MvMP7jzsv3eJnmIi4BZFS+XnQSjbq2D6hVfF0tj/SSBmjN9i6k3 nz35T1+TtIWpeoXxzlfrrbjCRkCrKfCMi9aF2Q== 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; bh=e89FRIq0JrFWw4iz1SNnSe69o0l+eF7cmUw3wIHKBjM=; b=Em8un+3H42sNrUB0KdvFAU/hMZrjPO1JUN4dzJem/sYpxPgcOhQ+jvYqr0OR4YB1lQ7JDDKIHI1S +vo/+C7wBLvvl6Y8qPE3InMehmQcDPdRpqxoiAM14ep7N3inWhNdQlsF/fDRvweNcZk7CM3hOzv9 B+3JTPwIbs007SkcAqitnSRMPtaJ5dpo2OwRVeXs3QBqZ2OiDnxqfT86sFq7ekIo/Wc4qdQFYvCh krx0OX670NTjk8DA90xFK6y9D8y8nZX+JxgfcZ/zLA0pYRmZJ8WYxCyRXcpuh5/lC04UARLBgqD0 DUkudwtLwLs9M9xFLxFn34WJk8RIXXD3EbEovg== Original-Received: by omta-ad1-fd1-101-uk-cardiff-1.omtaad1.vcndpcwl.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20240110 64bit (built Jan 10 2024)) with ESMTPS id <0S8G003A8HPV1O60@omta-ad1-fd1-101-uk-cardiff-1.omtaad1.vcndpcwl.oraclevcn.com> for bug-gnu-emacs@gnu.org; Tue, 06 Feb 2024 22:41:55 +0000 (GMT) In-reply-to: 875xz5gtlm.fsf@ocathain.ie Reporting-Meta: AAHxyrz0kbwpj6o8ojXeiSHsjaMFBeGegY4+4aF2FEOU3pLZ5oqReObGA3IzSFS3 AVLtdaeOdDym9gAjDEXkscsEnfMQcoOS73RxJ/rdzsL+J1dbaYcznF+oZXfJrYF2 XRQon13QXZ+RRtyf5m/UpH5r8CuY1UWJ/JARieoU2+enUNFiyS71aue/tY66Fuwk P9V49/M8kRDHWnh7x0L3BalgIFtOq1SdpiI5VeLgJQbqFrdw8eMdBcUdNU6ldQ7n 2BD1S72QOs1xlneFsmlqI41jbv9j8CEs5OQQB8IEV28JYRJGryCAZyhCPAO4vyY2 xUM4CZckhNQH609S05OB0OpeoWgA+rB/7Km3+x3P6Z3edMGP8XHE1y24vCBXTDL9 L+J+iRYCAYv2cqLQFFXKhSEPKMtPEDzqOxAyiZm1YyX0tfo7+Pjdns++SkCiYy6n 6A7A2pXwzw3V5UW6O7TKNs4zflAtsUZMHPKCDbj9o/KFAs3HzaOYrWP5 Received-SPF: pass client-ip=129.149.22.125; envelope-from=bounces+bug-gnu-emacs=gnu.org@cwl1.rp.oracleemaildelivery.com; helo=abi149bb125.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.25, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 06 Feb 2024 20:56:47 -0500 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:279529 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Here follows (hopefully) much improved versions of the patches. I have to admit, a lot of the "decisions" of the last one were just plain sillyness, but I hope I've correctly formatted the documentation. I rendered it and it looked correct to my eyes, but that's my own eyes. Both commands now take a prefix argument to pick a specific file or buffer, and otherwise default to the currently visited one. Further comments would be appreciated! Thanks, Barra =C3=93 Cath=C3=A1in. --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=0001-Added-buffer-and-file-to-register-functions.patch >From d7d6878664ae22c622f60608e9304fbffe29676c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barra=20=C3=93=20Cath=C3=A1in?= Date: Tue, 6 Feb 2024 22:33:32 +0000 Subject: [PATCH] Added buffer and file to register functions. * lisp/register.el (register-command-info): Register two new functions. (file-to-register): New function. (buffer-to-register): New function. --- lisp/register.el | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/lisp/register.el b/lisp/register.el index 822467a0d72..645bbc4b0ec 100644 --- a/lisp/register.el +++ b/lisp/register.el @@ -297,6 +297,18 @@ If NOCONFIRM is non-nil, request confirmation of register name by RET." :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. @@ -685,6 +697,35 @@ Interactively, prompt for REGISTER using `register-read-with-preview'." (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.43.0 --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=0002-lisp-bindings.el-ctl-x-r-map.patch >From c38e70ad2a93269e46343ea2b1a366ea064cdf84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barra=20=C3=93=20Cath=C3=A1in?= Date: Tue, 6 Feb 2024 14:18:47 +0000 Subject: [PATCH 2/3] * lisp/bindings.el (ctl-x-r-map): Added file-to-register and buffer-to-register in to keymap, under "F", and "B" --- lisp/bindings.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/bindings.el b/lisp/bindings.el index 4690897fed4..64f83efbb0a 100644 --- a/lisp/bindings.el +++ b/lisp/bindings.el @@ -1570,7 +1570,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) -- 2.43.0 --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=0003-Wrote-documentation-for-new-to-register-functions.patch >From 6c6524f70f93b88378c54be5bf4a7c21f422a8fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barra=20=C3=93=20Cath=C3=A1in?= Date: Tue, 6 Feb 2024 22:01:14 +0000 Subject: [PATCH 3/3] Wrote documentation for new to register functions. * doc/emacs/regs.texi (File and Buffer Registers): Revised documentation to explain the new commands, rather than the set-register elisp. --- doc/emacs/regs.texi | 55 ++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/doc/emacs/regs.texi b/doc/emacs/regs.texi index cac5b32c566..9dce7557de2 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 -- 2.43.0 --=-=-=--