Michael Heerdegen writes: > Thierry Volpiatto writes: > >> A possible solution for this is adding two vars, insert-register-types >> and jump-to-register-types and define register-type like this (named >> register--type here): >> >> (defun register--type (register) >> ;; Call register/type against the register value. >> (register/type (if (consp (cdr register)) >> (cadr register) >> (cdr register)))) >> >> (cl-defgeneric register/type (regval)) >> >> (cl-defmethod register/type ((regval string)) 'string) >> (cl-defmethod register/type ((regval number)) 'number) >> (cl-defmethod register/type ((regval marker)) 'marker) >> (cl-defmethod register/type ((regval window-configuration)) 'window) >> (cl-deftype frame-register () '(satisfies frameset-register-p)) >> (cl-defmethod register/type :extra "frame-register" (regval) 'frame) >> >> ;; set a new register and check its type like this: >> (register--type (car register-alist)) > > This looks promising. > > But I'm not sure whether the detour via type names (instead of an > approach using only generics) is the best solution. Why not define just > a new generic (register-eligible-for-command-p REG COMMAND) and use that > as predicate in the interactive specs of the commands (providing > `this-command' as second arg)? Seems simpler to me and still more > extensible and controllable. Not sure to understand what you want to do here. We don't want to modify each command, and anyway I don't see what (register-eligible-for-command-p REG COMMAND) would do in the interactive spec of each command. There is two things we want to make more flexible: 1) The ability to allow adding a new type of register and use this type of register to filter out the register-alist according to the command in use. 2) Allow one to add a new register command and assign its type, message to use and action it provide. Example, if I want to define a new command register-delete: (defun register-delete (register) (interactive (list (register-read-with-preview "Delete register: "))) (setq register-alist (delete register register-alist))) If I run this command I will have a minibuffer message "Overwrite register ", this is not what I expect, I expect "Delete register ". So we need something to customize this. I added a new var and a structure to achieve this, so now one can do in e.g. its .emacs: (with-eval-after-load 'register (require 'register-preview) (add-to-list 'register-commands-data `(register-delete . ,(make-register-preview-commands :types '(all) :msg "Delete register `%s'" :act 'delete))) (defun register-delete (register) (interactive (list (register-read-with-preview "Delete register: "))) (setq register-alist (delete register register-alist)))) But maybe what you propose is simpler to achieve the two tasks above, don't know. -- Thierry