help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: about register


From: Daniel Jensen
Subject: Re: about register
Date: Sun, 22 Apr 2007 12:42:43 +0200
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.98 (gnu/linux)

Le TeXnicien de Surface <texnicien.de.surface@chezmoi.eur> writes:

> Daniel Jensen écrivait/wrote :
>
>> You are using strings as register names, this is why it does not work.
>> The problem lies in how registers are implemented; they are compared
>> behind the scenes with the eq predicate. However, strings are not eq.
>> Use characters instead (e.g., ?A), 
>
> Thank you, it works.
> BTW where could I find such a piece of information about character?
> Is it lisp or emacs-specific?

You can start with reading the function documentation; `C-h f
number-to-register RET' and so on. That has always the most useful
information on how to use functions. In this case, it mentions that
characters are used to name registers.

To find answers to the more general questions, like "But, what is a
character anyway?", consult the Emacs Lisp manual. Chapter 2 describes
the data types and how you can use them in your programs. Here you will
find that characters can be entered with the question mark syntax in
Lisp code. The Lisp manual also holds information such as how registers
are implemented, but you don't need to know that just to use them.

>> or perhaps better do away with the register and use a variable.
>
> I will try to remember that next time I need such a command ;-) But won't
> there be some catch to write the value of the variable in the buffer?

It will require extra work to insert a number from a variable -- you
have to convert it to a string. But I think your code will be clearer if
you use a variable. You can do it like this:

(let ((counter 1))
  (while ...
    (insert (number-to-string counter))
    (setq counter (+ counter 1))))


reply via email to

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