Commit 386f506d authored by Sévère Durand's avatar Sévère Durand
Browse files

Partially applied patch from Protesilaos

* rlist.el (rlist-list-registers):
(rlist-verbose): Verbosity of the display of register contents.

(rlist-buffer-name): Customization option for the name of the buffer.

(rlist-register-regexp): Temporary change.

(rlist-delete-from-alist): Fix the previous bug of modifying the list
against the intention.
parent dd93d2a6
......@@ -32,9 +32,13 @@ add them at a later point.
Some great patches from [[https://gitlab.com/protesilaos][Protesilaos Stavrou]] are adapted. Thanks a lot!
The changes are as follows.
- Address common compiler warnings about packaging
- Declare rlist defgroup
- Implement face as a defface
- Expand defface definition and rename accordingly
- Address common compiler warnings about packaging.
- Declare rlist defgroup.
- Implement face as a defface.
- Expand defface definition and rename accordingly.
- Add the customization option which controls the verbosity of the
display of register contents.
- Add the customization option of the name of the buffer.
- Remove unnecessary autoloads.
And ideas and suggestions are always welcomed. :D
......@@ -25,7 +25,8 @@
;; interface.
;; It is recommended to bind the function `rlist-list-registers' to
;; the key originally bound to `list-registers', if any.
;; the key originally bound to `list-registers', if any. Personally I
;; bind it to "C-x v L".
;;; Code:
......@@ -35,13 +36,22 @@
"Interactively remove registers from the list."
:group 'register)
;;;###autoload
(defcustom rlist-expert nil
"Whether deleting registers requires confirmation."
:risky t
:group 'rlist
:type 'bool)
(defcustom rlist-verbose nil
"Whether registers should display their full value."
:group 'rlist
:type 'bool)
(defcustom rlist-buffer-name "*rlist*"
"Name of buffer showing the list of registers."
:group 'rlist
:type 'string)
(defface rlist-mark-delete
'((((class color) (min-colors 88) (background light))
:background "#ffccbb" :foreground "#840040")
......@@ -62,13 +72,13 @@ used as a `revert-buffer-function'."
(interactive)
(let ((list (copy-sequence register-alist)))
(setq list (sort list (lambda (a b) (< (car a) (car b)))))
(with-output-to-temp-buffer "*Output*"
(with-output-to-temp-buffer rlist-buffer-name
(dolist (elt list)
(when (get-register (car elt))
(describe-register-1 (car elt))
(describe-register-1 (car elt) rlist-verbose)
(terpri))))
;; Only the following two lines differ from `list-registers'.
(select-window (get-buffer-window "*Output*"))
(select-window (get-buffer-window rlist-buffer-name))
(rlist-mode)))
;;;###autoload
......@@ -99,11 +109,9 @@ Press \\[rlist-unmark-all] to unmark all registers.
(cons ?n #'rlist-forward-register)
(cons ?p #'rlist-backward-register)))
;;;###autoload
(defvar rlist-register-regexp (rx-to-string `(seq "Register " (group not-newline)))
(defvar rlist-register-regexp (rx-to-string `(seq "Register " (group (1+ (not space))) space))
"The regular expression to match a register line.")
;;;###autoload
(defun rlist-internal-delete-registers (registers)
"The internal function to delete REGISTERS.
This is not inteded to be used interactively, but rather as the
......@@ -150,7 +158,6 @@ not active."
(rlist-read-register-for-mark arg))))
(rlist-internal-delete-registers list-of-registers-to-delete)))
;;;###autoload
(defun rlist-delete-from-alist (ls elements)
"Remove ELEMENTS from LS.
Elements of LS whose `car' equal an element of ELEMENTS are
......@@ -167,7 +174,7 @@ with ELEMENTS removed."
;; In our case, since both LS and ELEMENTS are sorted, we might have
;; a faster implementation which employs the sorted-ness of the
;; arguments, but I think it is pre-mature optimisation anyway.
(let* ((temp ls)
(let* ((temp (copy-tree ls))
(counter 0)
indices-list head)
(while (consp temp)
......@@ -190,13 +197,15 @@ with ELEMENTS removed."
(lambda (index)
(cond
((> index 0)
;; Using `setcdr' is more efficient but destructively
;; modifies the list. So we used `copy-tree' to prevent the
;; destructions.
(setcdr (nthcdr (1- index) temp)
(nthcdr (1+ index) temp)))
((setq temp (cdr temp)))))
indices-list)
temp))
;;;###autoload
(defun rlist-get-marked-registers ()
"Return the list of marked registers."
(save-excursion
......@@ -349,7 +358,6 @@ The return value is a list of registers."
(rlist-register-at-point 200))))
(t (list (register-read-with-preview "Register: ")))))
;;;###autoload
(defun rlist-register-at-point (arg)
"Return the next/previous ARG register at point, if any."
(cond
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment