Add option to only use registers in current buffer.

This commit is contained in:
tastytea 2020-02-20 03:25:36 +01:00
parent 06e217278c
commit e0d90844c1
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
2 changed files with 19 additions and 9 deletions

View File

@ -35,11 +35,10 @@ Or, with use-package:
("C-<f6>" . register-quicknav/next-register)
("M-r" . register-quicknav/clear-current-register)))
## Tips
## Variables
To only cycle through the registers of the current buffer, add
(make-variable-buffer-local 'register-alist)
to your init.el.
* `register-quicknav/buffer-only`: Cycle only through position registers in
current buffer.
---

View File

@ -54,14 +54,22 @@
;; ("C-<f6>" . register-quicknav/next-register)
;; ("M-r" . register-quicknav/clear-current-register)))
;; Tips:
;; Variables:
;;
;; To only cycle through the registers of the current buffer, add
;; (make-variable-buffer-local 'register-alist)
;; to your init.el.
;; * `register-quicknav/buffer-only': Cycle only through position registers in
;; current buffer.
;;; Code:
(defgroup register-quicknav nil
"Variables for register-quicknav."
:group 'editing)
(defcustom register-quicknav/buffer-only nil
"Cycle only through position registers in current buffer."
:type 'boolean
:group 'register-quicknav)
(defvar register-quicknav//current-position-register 0
"An index to the current position register.")
@ -79,7 +87,10 @@
(let (result)
(dolist (item register-alist)
(when (markerp (cdr item))
(setq result (cons item result))))
(if register-quicknav/buffer-only
(when (eq (current-buffer) (marker-buffer (cdr item)))
(setq result (cons item result)))
(setq result (cons item result)))))
(sort result #'register-quicknav//sort-position-register-elements)))
(defun register-quicknav/next-register ()