GNU bug report logs -
#73293
[PATCH] Add buffer-local register commands to doc-view
Previous Next
Reported by: Visuwesh <visuweshm <at> gmail.com>
Date: Mon, 16 Sep 2024 12:14:02 UTC
Severity: normal
Tags: patch
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 73293 in the body.
You can then email your comments to 73293 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73293
; Package
emacs
.
(Mon, 16 Sep 2024 12:14:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Visuwesh <visuweshm <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Mon, 16 Sep 2024 12:14:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Attached patch adds buffer-local registers to doc-view-mode. I have
opted to make the registers buffer-local since I personally use the same
mnemonic to save pages to the register in multiple buffers. It is
something like folding a page or placing a pen in between to quickly go
to-and-fro between those pages.
In GNU Emacs 31.0.50 (build 7, x86_64-pc-linux-gnu, X toolkit, cairo
version 1.18.0, Xaw scroll bars) of 2024-09-09 built on astatine
Repository revision: 7d7aa65f63db78c5732f1580213fc3767b767a4a
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101011
System Description: Debian GNU/Linux trixie/sid
Configured using:
'configure --with-sound=alsa --with-x-toolkit=lucid --without-xaw3d
--without-gconf --without-libsystemd --with-cairo'
[0001-Add-buffer-local-register-commands-to-doc-view.patch (text/patch, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73293
; Package
emacs
.
(Sat, 21 Sep 2024 10:30:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 73293 <at> debbugs.gnu.org (full text, mbox):
> From: Visuwesh <visuweshm <at> gmail.com>
> Date: Mon, 16 Sep 2024 17:40:18 +0530
>
> Attached patch adds buffer-local registers to doc-view-mode. I have
> opted to make the registers buffer-local since I personally use the same
> mnemonic to save pages to the register in multiple buffers. It is
> something like folding a page or placing a pen in between to quickly go
> to-and-fro between those pages.
Thanks.
Tassilo, any comments or suggestions?
> In GNU Emacs 31.0.50 (build 7, x86_64-pc-linux-gnu, X toolkit, cairo
> version 1.18.0, Xaw scroll bars) of 2024-09-09 built on astatine
> Repository revision: 7d7aa65f63db78c5732f1580213fc3767b767a4a
> Repository branch: master
> Windowing system distributor 'The X.Org Foundation', version 11.0.12101011
> System Description: Debian GNU/Linux trixie/sid
>
> Configured using:
> 'configure --with-sound=alsa --with-x-toolkit=lucid --without-xaw3d
> --without-gconf --without-libsystemd --with-cairo'
>
>
> >From 415f3ba0ad07f113858eaa45b60b9bd66b09c7da Mon Sep 17 00:00:00 2001
> From: Visuwesh <visuweshm <at> gmail.com>
> Date: Sun, 15 Sep 2024 13:56:21 +0530
> Subject: [PATCH] Add buffer-local register commands to doc-view
>
> * lisp/doc-view.el (doc-view-register-alist): New defvar to keep
> track of buffer-local register-alist.
> (doc-view-page-to-register, doc-view-jump-to-register): Add new
> commands to set and jump to buffer-local registers.
> (register-val-insert, register-val-describe)
> (register-val-jump-to): Register defmethod to save and restore
> doc-view registers.
> (doc-view-mode-map): Bind the new commands.
> * doc/emacs/misc.texi (DocView Navigation): Document the new
> commands.
> * etc/NEWS: Announce the change.
> ---
> doc/emacs/misc.texi | 10 +++++++++
> etc/NEWS | 6 +++++
> lisp/doc-view.el | 54 ++++++++++++++++++++++++++++++++++++++++++++-
> 3 files changed, 69 insertions(+), 1 deletion(-)
>
> diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi
> index eb157c146e7..e19e554fb26 100644
> --- a/doc/emacs/misc.texi
> +++ b/doc/emacs/misc.texi
> @@ -593,6 +593,16 @@ DocView Navigation
> displayed using the variables @code{doc-view-imenu-format} and
> @code{doc-view-imenu-flatten}.
>
> +@findex doc-view-page-to-register
> +@findex doc-view-jump-to-register
> +@kindex m @r{(DocView mode)}
> +@kindex ' @r{(DocView mode)}
> + You can save the current page to a register with @kbd{m}
> +(@code{doc-view-page-to-register}) (@pxref{Registers}). However, these
> +registers are not shared across buffers and stay local to the DocView
> +buffer. You can later jump to the register with @kbd{'}
> +(@code{doc-view-jump-to-register}).
> +
> @node DocView Searching
> @subsection DocView Searching
>
> diff --git a/etc/NEWS b/etc/NEWS
> index c6f8b0062e4..607665a71bb 100644
> --- a/etc/NEWS
> +++ b/etc/NEWS
> @@ -262,6 +262,12 @@ When switching to the plain text contents with 'doc-view-open-text',
> DocView now creates a dedicated buffer to display it. 'C-c C-c' gets you
> back to real DocView buffer if it still exists.
>
> ++++
> +*** New commands to save and restore pages in buffer local registers.
> +Docview can store current page to buffer local registers with the new
> +command 'doc-view-page-to-register' (bound to 'm'), and later can be
> +restored with 'doc-view-jump-to-register' (bound to ''').
> +
> ** Tramp
>
> +++
> diff --git a/lisp/doc-view.el b/lisp/doc-view.el
> index 0d89d63e03e..395993e6263 100644
> --- a/lisp/doc-view.el
> +++ b/lisp/doc-view.el
> @@ -556,7 +556,10 @@ doc-view-mode-map
> "C-c C-c" #'doc-view-toggle-display
> ;; Open a new buffer with doc's text contents
> "C-c C-t" #'doc-view-open-text
> - "r" #'revert-buffer)
> + "r" #'revert-buffer
> + ;; Registers
> + "m" #'doc-view-page-to-register
> + "'" #'doc-view-jump-to-register)
>
> (define-obsolete-function-alias 'doc-view-revert-buffer #'revert-buffer "27.1")
> (defvar revert-buffer-preserve-modes)
> @@ -2468,6 +2471,55 @@ doc-view-bookmark-jump
>
> (put 'doc-view-bookmark-jump 'bookmark-handler-type "DocView")
>
> +;;; Register integration
> +
> +(defvar-local doc-view-register-alist nil
> + "Register alist containing only doc-view registers for current buffer.
> +Each doc-view register entry is of the form (doc-view . ALIST) where
> +ALIST has the keys `buffer', `file', and `page'. `buffer' is the buffer
> +the `file' is visiting. `page' is the page number to be show.")
> +
> +(defun doc-view-page-to-register (register)
> + "Store the current page to the register REGISTER."
> + (interactive
> + (let ((register-alist doc-view-register-alist))
> + (list (register-read-with-preview "Page to register: "))))
> + (let ((register-alist doc-view-register-alist))
> + (set-register register
> + `(doc-view
> + (buffer . ,(current-buffer))
> + (file . ,(buffer-file-name))
> + (page . ,(doc-view-current-page))))
> + (setq doc-view-register-alist register-alist)))
> +
> +(defun doc-view-jump-to-register (register)
> + "Jump to the register REGISTER."
> + (interactive
> + (let ((register-alist doc-view-register-alist))
> + (list (register-read-with-preview "Jump to register: "))))
> + (let ((register-alist doc-view-register-alist))
> + (jump-to-register register)))
> +
> +(cl-defmethod register-val-insert ((val (head doc-view)))
> + (prin1 val))
> +
> +(cl-defmethod register-val-describe ((val (head doc-view)) _verbose)
> + (let* ((alist (cdr val))
> + (name (or (file-name-nondirectory (alist-get 'file alist))
> + (buffer-name (alist-get 'buffer alist)))))
> + (princ name)
> + (princ " p. ")
> + (princ (alist-get 'page alist))))
> +
> +(cl-defmethod register-val-jump-to ((val (head doc-view)) _arg)
> + (let* ((alist (cdr val))
> + (buffer (or (alist-get 'buffer alist)
> + (find-buffer-visiting (alist-get 'file alist)))))
> + (unless buffer
> + (user-error "Cannot find the doc-view buffer to jump to"))
> + (switch-to-buffer buffer)
> + (doc-view-goto-page (alist-get 'page alist))))
> +
> ;; Obsolete.
>
> (defun doc-view-intersection (l1 l2)
> --
> 2.45.2
>
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73293
; Package
emacs
.
(Mon, 23 Sep 2024 16:13:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 73293 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: Visuwesh <visuweshm <at> gmail.com>
>> Date: Mon, 16 Sep 2024 17:40:18 +0530
>>
>> Attached patch adds buffer-local registers to doc-view-mode. I have
>> opted to make the registers buffer-local since I personally use the same
>> mnemonic to save pages to the register in multiple buffers. It is
>> something like folding a page or placing a pen in between to quickly go
>> to-and-fro between those pages.
>
> Thanks.
>
> Tassilo, any comments or suggestions?
No, looks good and useful from my point of view.
Bye,
Tassilo
Reply sent
to
Eli Zaretskii <eliz <at> gnu.org>
:
You have taken responsibility.
(Sat, 28 Sep 2024 09:15:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Visuwesh <visuweshm <at> gmail.com>
:
bug acknowledged by developer.
(Sat, 28 Sep 2024 09:15:02 GMT)
Full text and
rfc822 format available.
Message #16 received at 73293-done <at> debbugs.gnu.org (full text, mbox):
> From: Tassilo Horn <tsdh <at> gnu.org>
> Cc: Visuwesh <visuweshm <at> gmail.com>, 73293 <at> debbugs.gnu.org
> Date: Mon, 23 Sep 2024 18:12:19 +0200
>
> Eli Zaretskii <eliz <at> gnu.org> writes:
>
> >> From: Visuwesh <visuweshm <at> gmail.com>
> >> Date: Mon, 16 Sep 2024 17:40:18 +0530
> >>
> >> Attached patch adds buffer-local registers to doc-view-mode. I have
> >> opted to make the registers buffer-local since I personally use the same
> >> mnemonic to save pages to the register in multiple buffers. It is
> >> something like folding a page or placing a pen in between to quickly go
> >> to-and-fro between those pages.
> >
> > Thanks.
> >
> > Tassilo, any comments or suggestions?
>
> No, looks good and useful from my point of view.
Thanks, installed on master, and closing the bug.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sat, 26 Oct 2024 11:24:15 GMT)
Full text and
rfc822 format available.
This bug report was last modified 230 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.