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

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

Re: about register


From: Le TeXnicien de Surface
Subject: Re: about register
Date: Sun, 22 Apr 2007 21:57:01 +0200
User-agent: KNode/0.10.1

Daniel Jensen écrivait/wrote :

> 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.
I did that but never thought there would be a difference between a char and
a string of one char (bad perl habit I guess :)
> 
> 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.
I read it some years ago but with big troubles in my private life and a year
without any linux box, I may have forgotten more than I ever learned.
 
>>> 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))))

May thanks again. I thought to remember something on the line of
`num-to-str' but I had not begun my investigations so far. It will save me
some hours.

-- 
Le TeXnicien de Surface


reply via email to

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