[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#8415: 23.3.50; Extensible Emacs Registers

From: Stefan Monnier
Subject: bug#8415: 23.3.50; Extensible Emacs Registers
Date: Mon, 04 Apr 2011 10:29:11 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

> I would like to propose the following patch that makes the register
> system easier to hook into. With this change, for example, if one wants
> to make a command to save a keyboard macro to a register. There is no
> need to change register.el. 3rd party libraries such as undo-tree.el can
> add registers of undo state that one can jump to with C-x r j.

Sounds good.

> -(defvar register-alist nil
> -  "Alist of elements (NAME . CONTENTS), one for each Emacs register.
> -NAME is a character (a number).  CONTENTS is a string, number, marker or 
> list.
> +;;; in-memeory persistency

Please capitalize your comments and add a closing ".".
Why "memeory"?  ;-)

> +(defvar register-hash-table (make-hash-table))

Why change it to a hash-table?

> +;;; immutable register object
> +(defstruct
> +  (register (:constructor nil)
> +         (:constructor register--make (name &optional value print-func
> +                                            jump-func insert-func extra))
> +         (:copier nil)
> +         (:type list)
> +         :named)
> +  (name             nil :read-only t)
> +  (value       nil :read-only t)
> +  (print-func  nil :read-only t)
> +  (jump-func   nil :read-only t)
> +  (insert-func nil :read-only t)
> +  (extra       nil :read-only t))

Remove `extra': it's unused, undocumented, and doesn't seem to be any
use (there's already `value').

> +VALUE may be a string, number, marker or list.

IIUC this is not true any more, it can be any value.

> +(define-obsolete-function-alias 'set-register 'register-make "24.1")
> +(make-obsolete 'get-register "use `register-find' and `register-value'." 
> "24.1")

A more backward-compatible change would be to not use register-structs
for pre-existing cases (i.e. markers, strings, lists of string, and
win-confs).  I.e. only add register structs as a new accepted kind
of value (and move `name' out of the struct).

The patch would most likely be a lot smaller.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]