For example, if I have too many registers and would like to get rid of some of them, is there a way to do that?

I realize that quitting the emacs session will clear all registers, but is there a way to do that within a session?

1 Answer 1


Function set-register (C-h f):

set-register is a compiled Lisp function in register.el.

(set-register REGISTER VALUE)

Set contents of Emacs register named REGISTER to VALUE. Returns VALUE.

See the documentation of the variable register-alist for possible VALUEs.

And (elisp) Registers:

 -- Function: set-register reg value
     This function sets the contents of register REG to VALUE.  A
     register can be set to any value, but the other register functions
     expect only certain data types.  The return value is VALUE.

So (set-register ?a nil) resets/clears register a.

You can also reset registers using register-alist. E.g., to reset registers a, b, and c:

(setq register-alist  (append '((?a) (?b) (?c)) register-alist))

BTW. How did I find function set-register and variable register-alist? Apropos (e.g. command apropos) is your friend.

(Actually, I just use Icicles, which provides apropos completion. I typed C-h f register S-TAB.)

  • NB: Both the methods above clear the registers. The second method grows register-alist - so there will be two register as and so on - both the registers will have nil values. Also, in the register preview wiindow, the values are displayed as Garbage. (Thanks for the answer. Just wanted to make a note of the above).
    – user650654
    Aug 23, 2019 at 3:11
  • Yes. It's an alist. If you really want to remove the existing elements from it you can do that instead. But you don't have to. And no, both the ?a registers will not have nil values. The more recent alist entry shadows the older one, which still has the original value. Shadowing the older alist element means that register ?a is empty - its value is nil. Try (get-register ?a), with register-alist = ((?a) (?a . "aaa")). It returns nil, which means that register ?a has no contents.
    – Drew
    Aug 23, 2019 at 3:42
  • Yes, both are not nil - the older a has the older value. In the register preview window, two a registers are shown and both have a Garbage value. I am unable to edit my comment above to make this correction.
    – user650654
    Aug 23, 2019 at 4:10
  • 1
    No, neither has a garbage value. Only the first one exists as a register (it is the only one seen by get-register), and it is empty - has no garbage content - it has no content at all. The problem is in the code for register previewing: It should not show content of Garbage:. I've filed Emacs bug #37155 for this. Try list-registers or view-register and you'll see a correct presentation. The previewing code is faulty.
    – Drew
    Aug 23, 2019 at 6:17
  • 1
    +1 for filing a bug.
    – user650654
    Aug 23, 2019 at 20:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.