Compare commits

...

30 Commits
0.3.0 ... main

Author SHA1 Message Date
tastytea c15ea92b09
Remove obsolete variable/function aliases.
continuous-integration/drone/push Build is passing Details
2020-05-24 22:06:57 +02:00
tastytea 06afa1efc4
Clean up .gitignore.
continuous-integration/drone/push Build is passing Details
2020-03-25 17:22:12 +01:00
tastytea e30883a708
Don't check tags in CI.
continuous-integration/drone/push Build is passing Details
2020-03-25 17:14:16 +01:00
tastytea 0301a3a1ee
Version bump 0.4.3.
continuous-integration/drone/push Build is passing Details
2020-03-25 17:12:57 +01:00
tastytea 6995a7f988
Require Emacs 25.3.
continuous-integration/drone/push Build was killed Details
Emacs 24.5 doesn't like docstrings on lambdas.
2020-03-25 17:09:05 +01:00
tastytea 695d28b24c
Merge branch 'ci' into main 2020-03-25 17:08:50 +01:00
tastytea 31b913666c
Change docker image for CI to flycheck/emacs-cask.
continuous-integration/drone/push Build is passing Details
2020-03-25 17:08:37 +01:00
tastytea d4c664fed9
Add CI with drone + makem.sh.
continuous-integration/drone/push Build is passing Details
2020-03-25 15:58:27 +01:00
tastytea c73f35ef9e
Enhance documentation for …-clear-current-register. 2020-03-21 20:25:10 +01:00
tastytea e1b620cdde
Give feedback when register(s) is/are cleared. 2020-03-21 19:34:07 +01:00
tastytea e42245aa65
Update …--last-register after storing a register. 2020-03-21 19:32:55 +01:00
tastytea 1c13793033
Ignore error if nth on register-alist item fails.
Text registers are alists, nth > 0 fails on alists.
2020-03-21 12:21:22 +01:00
tastytea ff58dadc4c
Add …-clear-unused-registers-range(). 2020-03-19 16:45:38 +01:00
tastytea 24a23cbcee
Announce the unused register the position is stored in. 2020-03-19 16:17:34 +01:00
tastytea 892b368b23
Define …--last-register-v as global variable.
It doesn't seem to make a difference but makes more sense to me.
2020-03-15 22:27:56 +01:00
tastytea 3883cbf298
Version bump 0.4.0. 2020-03-15 22:21:26 +01:00
tastytea e925e595d5
Change suggested keybindings. 2020-03-15 22:08:16 +01:00
tastytea 47471f561f
Add section “Differences to similar packages”. 2020-03-15 21:53:41 +01:00
tastytea fa7d5fe4fe
Add documentaion for …-point-to-unused-register. 2020-03-15 21:50:02 +01:00
tastytea 9c5e0dde16
Add MELPA link and remove quelpa instructions. 2020-03-15 21:10:15 +01:00
tastytea d50c5d122f
Simplify check if index is nil in …--jump-to-register. 2020-03-15 20:55:14 +01:00
tastytea fa6153bfc4
Add …-point-to-unused-register and associated variables. 2020-03-15 20:54:08 +01:00
tastytea 78ec3fe3de
Add note that …-buffer-only is safe as file-local variable. 2020-03-12 17:31:36 +01:00
tastytea e6e20855a8
Correct comment. 2020-03-08 17:09:43 +01:00
tastytea 8de7717881
Mark register-quicknav-buffer-only as save with booleans,
and autoload it.
2020-03-08 12:29:52 +01:00
tastytea f2640264cd
Extend description. 2020-03-08 12:17:05 +01:00
tastytea bab92365cd
Refactor register-quicknav--jump-to-register.
Shorten validity-check and index correction, update/add comments.
2020-03-08 12:05:49 +01:00
tastytea c90d005c54
Shorten validity-check. 2020-03-08 05:48:48 +01:00
tastytea 046b1e897e
Update comment. 2020-03-08 05:48:35 +01:00
tastytea 0a433edb0d
Shorten register-quicknav--register-file-name,
to register-quicknav--file-name.
2020-03-08 05:45:03 +01:00
5 changed files with 1304 additions and 74 deletions

77
.drone.yml Normal file
View File

@ -0,0 +1,77 @@
kind: pipeline
name: Lint package
volumes:
- name: debian-package-cache
host:
path: /var/cache/debian-package-cache
trigger:
event:
exclude:
- tag
steps:
- name: Emacs 26.3
image: flycheck/emacs-cask:26.3
pull: always
environment:
DEBIAN_FRONTEND: noninteractive
LANG: en_US.UTF-8
commands:
- rm /etc/apt/apt.conf.d/docker-clean
- alias apt-get='rm -f /var/cache/apt/archives/lock && apt-get'
- apt-get update -q
- apt-get install -qq language-pack-en git aspell-en
- ./makem.sh --verbose --sandbox --install-deps --install-linters lint
volumes:
- name: debian-package-cache
path: /var/cache/apt/archives
- name: Emacs master-branch
image: flycheck/emacs-cask:master
pull: always
environment:
DEBIAN_FRONTEND: noninteractive
LANG: en_US.UTF-8
commands:
- rm /etc/apt/apt.conf.d/docker-clean
- alias apt-get='rm -f /var/cache/apt/archives/lock && apt-get'
- apt-get update -q
- apt-get install -qq language-pack-en git aspell-en
- emacs --version
- ./makem.sh --verbose --sandbox --install-deps --install-linters lint
volumes:
- name: debian-package-cache
path: /var/cache/apt/archives
- name: Emacs 25.3
image: flycheck/emacs-cask:25.3
pull: always
environment:
DEBIAN_FRONTEND: noninteractive
LANG: C
commands:
- rm /etc/apt/apt.conf.d/docker-clean
- alias apt-get='rm -f /var/cache/apt/archives/lock && apt-get'
- apt-get update -q
- apt-get install -qq git
# Some package or its dependency requires Emacs 26.1,
# so we just check if it compiles.
- ./makem.sh --verbose --sandbox compile
volumes:
- name: debian-package-cache
path: /var/cache/apt/archives
- name: notify
image: drillster/drone-email
pull: always
settings:
host: cryptoparty-celle.de
from: drone@tzend.de
username:
from_secret: email_username
password:
from_secret: email_password
when:
status: [ changed, failure ]

2
.gitignore vendored
View File

@ -1,2 +1,2 @@
/flycheck*.el*
*~
*.elc

View File

@ -1,50 +1,65 @@
# register-quicknav - Quickly jump to next/previous register
*Author:* tastytea <tastytea@tastytea.de><br>
*Version:* 0.3.0<br>
*Version:* 0.4.3<br>
*URL:* [https://schlomp.space/tastytea/register-quicknav](https://schlomp.space/tastytea/register-quicknav)<br>
This package is built on top of `register.el` and allows you to quickly jump
to the next/previous position register. If you reach the end, the search
wraps around and continues with the first (or last) register.
wraps around and continues with the first (or last) register. It can be used
across all files or individually for each buffer.
## Features
* Cycle through all position registers in both directions.
* Clear current register.
* Store point in unused register (range configurable).
* Clear all registers in the unused registers range.
## Installation
**Note:** The function and variable names were previously separated by “/”
from the namespace. To conform with MELPA rules the separator has been
changed to “-”.
To use `register-quicknav.el`, put it in your load-path and add the following
to your init.el:
To use `register-quicknav.el`, get it from
[MELPA](https://melpa.org/#/register-quicknav) or put it in your load-path
and add the following to your init.el:
(require 'register-quicknav)
(global-set-key (kbd "<C-f5>") #'register-quicknav-prev-register)
(global-set-key (kbd "<C-f6>") #'register-quicknav-next-register)
(global-set-key (kbd "M-r") #'register-quicknav-clear-current-register)
(global-set-key (kbd "<C-f7>") #'register-quicknav-point-to-unused-register)
(global-set-key (kbd "<C-S-<f7>") #'register-quicknav-clear-current-register)
Or, with use-package:
(use-package register-quicknav
:bind (("C-<f5>" . register-quicknav-prev-register)
("C-<f6>" . register-quicknav-next-register)
("M-r" . register-quicknav-clear-current-register)))
Instead of manually copying `register-quicknav.el` into your load-path, you
can use [quelpa](https://github.com/quelpa/quelpa):
(quelpa '(register-quicknav
:fetcher git
:url "https://schlomp.space/tastytea/register-quicknav.git"))
:bind (("C-<f5>" . register-quicknav-prev-register)
("C-<f6>" . register-quicknav-next-register)
("C-<f7>" . register-quicknav-point-to-unused-register)
("C-S-<f7>" . register-quicknav-clear-current-register)))
## Variables
* `register-quicknav-buffer-only`: Cycle only through position registers in
current buffer.
current buffer. Can be safely set as file- and/or dir-local variable.
* `register-quicknav-unused-registers-begin`: Beginning of the range that is
used to search for unused registers. Defaults to `?A`.
* `register-quicknav-unused-registers-end`: End of the range that is used to
search for unused registers. Defaults to `?Z`.
## Differences to similar packages
[iregister](https://github.com/atykhonov/iregister.el):
* Opens a minibuffer on each jump (thereby requiring an extra keystroke).
* Doesn't work with file-query registers
* Can't be restricted to the current buffer.
* Doesn't look like it's still maintained.
[register-channel](https://github.com/YangZhao11/register-channel):
* Is limited to 5 position registers by default, needs an extra keybinding
for each additional register.
* Can't be restricted to the current buffer.
* Has no ability to jump to the next/previous register.
---

1090
makem.sh Executable file

File diff suppressed because it is too large Load Diff

View File

@ -3,8 +3,8 @@
;; Copyright (C) 2020 tastytea
;; Author: tastytea <tastytea@tastytea.de>
;; Version: 0.3.0
;; Package-Requires: ((emacs "24.3"))
;; Version: 0.4.3
;; Package-Requires: ((emacs "25.3"))
;; Keywords: convenience
;; URL: https://schlomp.space/tastytea/register-quicknav
@ -25,69 +25,87 @@
;; This package is built on top of `register.el' and allows you to quickly jump
;; to the next/previous position register. If you reach the end, the search
;; wraps around and continues with the first (or last) register.
;; wraps around and continues with the first (or last) register. It can be used
;; across all files or individually for each buffer.
;; Features:
;;
;; * Cycle through all position registers in both directions.
;; * Clear current register.
;; * Store point in unused register (range configurable).
;; * Clear all registers in the unused registers range.
;; Installation:
;;
;; **Note:** The function and variable names were previously separated by “/”
;; from the namespace. To conform with MELPA rules the separator has been
;; changed to “-”.
;;
;; To use `register-quicknav.el', put it in your load-path and add the following
;; to your init.el:
;; To use `register-quicknav.el', get it from
;; [MELPA](https://melpa.org/#/register-quicknav) or put it in your load-path
;; and add the following to your init.el:
;;
;; (require 'register-quicknav)
;; (global-set-key (kbd "<C-f5>") #'register-quicknav-prev-register)
;; (global-set-key (kbd "<C-f6>") #'register-quicknav-next-register)
;; (global-set-key (kbd "M-r") #'register-quicknav-clear-current-register)
;; (global-set-key (kbd "<C-f7>") #'register-quicknav-point-to-unused-register)
;; (global-set-key (kbd "<C-S-<f7>") #'register-quicknav-clear-current-register)
;;
;; Or, with use-package:
;;
;; (use-package register-quicknav
;; :bind (("C-<f5>" . register-quicknav-prev-register)
;; ("C-<f6>" . register-quicknav-next-register)
;; ("M-r" . register-quicknav-clear-current-register)))
;;
;; Instead of manually copying `register-quicknav.el' into your load-path, you
;; can use [quelpa](https://github.com/quelpa/quelpa):
;;
;; (quelpa '(register-quicknav
;; :fetcher git
;; :url "https://schlomp.space/tastytea/register-quicknav.git"))
;; :bind (("C-<f5>" . register-quicknav-prev-register)
;; ("C-<f6>" . register-quicknav-next-register)
;; ("C-<f7>" . register-quicknav-point-to-unused-register)
;; ("C-S-<f7>" . register-quicknav-clear-current-register)))
;; Variables:
;;
;; * `register-quicknav-buffer-only': Cycle only through position registers in
;; current buffer.
;; current buffer. Can be safely set as file- and/or dir-local variable.
;; * `register-quicknav-unused-registers-begin': Beginning of the range that is
;; used to search for unused registers. Defaults to `?A'.
;; * `register-quicknav-unused-registers-end': End of the range that is used to
;; search for unused registers. Defaults to `?Z'.
;; Differences to similar packages:
;;
;; [iregister](https://github.com/atykhonov/iregister.el):
;;
;; * Opens a minibuffer on each jump (thereby requiring an extra keystroke).
;; * Doesn't work with file-query registers
;; * Can't be restricted to the current buffer.
;; * Doesn't look like it's still maintained.
;;
;; [register-channel](https://github.com/YangZhao11/register-channel):
;;
;; * Is limited to 5 position registers by default, needs an extra keybinding
;; for each additional register.
;; * Can't be restricted to the current buffer.
;; * Has no ability to jump to the next/previous register.
;;; Code:
(require 'cl-lib)
(define-obsolete-variable-alias 'register-quicknav/buffer-only
'register-quicknav-buffer-only "0.1.1")
(define-obsolete-function-alias 'register-quicknav/next-register
#'register-quicknav-next-register "0.1.1")
(define-obsolete-function-alias 'register-quicknav/prev-register
#'register-quicknav-prev-register "0.1.1")
(define-obsolete-function-alias 'register-quicknav/clear-current-register
#'register-quicknav-clear-current-register "0.1.1")
(defgroup register-quicknav nil
"Variables for register-quicknav."
:group 'editing)
;;;###autoload
(defcustom register-quicknav-buffer-only nil
"Cycle only through position registers in current buffer."
:type 'boolean
:group 'register-quicknav
:safe #'booleanp)
(defcustom register-quicknav-unused-registers-begin ?A
"Begin looking for unused register at this register."
:type 'character
:group 'register-quicknav)
(defvar-local register-quicknav--last-register-v nil
(defcustom register-quicknav-unused-registers-end ?Z
"End looking for unused register at this register."
:type 'character
:group 'register-quicknav)
(defvar register-quicknav--last-register-v nil
"The last jumped-to position register.")
(defun register-quicknav--last-register (&optional val)
@ -102,7 +120,7 @@ the global value otherwise."
register-quicknav--last-register-v
(default-value 'register-quicknav--last-register-v))))
(defun register-quicknav--register-file-name (register)
(defun register-quicknav--file-name (register)
"Return file-name of REGISTER.
Works on markers and file-queries."
(if (markerp (cdr register))
@ -115,7 +133,7 @@ Works on markers and file-queries."
(if (markerp (cdr register))
(eq (current-buffer) (marker-buffer (cdr register)))
(string= (buffer-file-name (current-buffer))
(register-quicknav--register-file-name register))))
(register-quicknav--file-name register))))
(defun register-quicknav--position (register)
"Return position of REGISTER.
@ -132,14 +150,14 @@ current buffer."
(lambda (a b)
"Return t if position of A is < B.
Works on markers and file-queries."
(and (string= (register-quicknav--register-file-name a)
(register-quicknav--register-file-name b))
(and (string= (register-quicknav--file-name a)
(register-quicknav--file-name b))
(< (register-quicknav--position a)
(register-quicknav--position b))))))
(let ((result))
(dolist (register register-alist)
(if (or (markerp (cdr register))
(eq (nth 1 register) 'file-query))
(ignore-errors (eq (nth 1 register) 'file-query)))
(if register-quicknav-buffer-only
(when (register-quicknav--is-current-buffer? register)
(push register result))
@ -151,36 +169,31 @@ Works on markers and file-queries."
(let* ((register-list (register-quicknav--registers))
(index (cl-position (register-quicknav--last-register) register-list))
(stop-searching))
(unless (eq index nil)
(when index
(if next
(cl-incf index)
(cl-decf index)))
;; Try to find the position register closest to point.
(dolist (register register-list)
(when (register-quicknav--is-current-buffer? register)
(let ((register-pos (register-quicknav--position register)))
(if next
(when (and (not stop-searching) (> register-pos (point)))
(when (and (not stop-searching)
(> register-pos (point)))
(setq index (cl-position register register-list)
stop-searching t))
(when (< register-pos (point))
(setq index (cl-position register register-list)))))))
;; If an index was found, set it to the next/previous register. If not, set
;; it to the first/last.
(if index
(progn
(when (or (> index (- (length register-list) 1)) (< index 0))
(setq index nil))
(if next
(progn
(if (or (eq index nil) (eq index (length register-list)))
(setq index 0)))
(if (or (eq index nil))
(setq index (- (length register-list) 1))))
(progn ; If index is invalid, set it to first or last register.
(when (or (>= index (length register-list))
(< index 0))
(if next
(setq index 0)
(setq index (- (length register-list) 1))))
(register-to-point (car (nth index register-list)))
(register-quicknav--last-register (nth index register-list)))
;; No suitable register found, jump to first register.
(register-to-point (car (car register-list)))
(register-quicknav--last-register (car register-list)))))
@ -198,10 +211,45 @@ Works on markers and file-queries."
;;;###autoload
(defun register-quicknav-clear-current-register ()
"Clear last jumped-to position register from `register-alist'."
"Clear last jumped-to position register from `register-alist'.
Deletes the value of `register-quicknav--last-register' from `register-alist'."
(interactive)
(setq register-alist
(delq (register-quicknav--last-register) register-alist)))
(delq (register-quicknav--last-register) register-alist))
(message "Cleared register %c." (car (register-quicknav--last-register))))
;;;###autoload
(defun register-quicknav-point-to-unused-register ()
"Store current location of point in next unused register.
Searches the range between
`register-quicknav-unused-registers-begin' and
`register-quicknav-unused-registers-end'."
(interactive)
(let* ((begin register-quicknav-unused-registers-begin)
(end register-quicknav-unused-registers-end)
(char begin))
(while (and (get-register char)
(not (> char end)))
(cl-incf char))
(if (<= char end)
(progn
(point-to-register char)
(register-quicknav--last-register (assoc char register-alist))
(message "Position stored in register %c." char))
(message "No unused register in the range %c - %c found." begin end))))
;;;###autoload
(defun register-quicknav-clear-unused-registers-range ()
"Clear all registers in the range used by `register-quicknav-point-to-unused-register'."
(interactive)
(let ((begin register-quicknav-unused-registers-begin)
(end register-quicknav-unused-registers-end))
(dolist (register register-alist)
(when (and (>= (car register) begin)
(<= (car register) end))
(setq register-alist
(delq register register-alist))))
(message "Cleared unused registers in the range %c - %c." begin end)))
(provide 'register-quicknav)
;;; register-quicknav.el ends here