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

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

Re: creating a function that works for active region or whole buffer


From: Stefan Monnier
Subject: Re: creating a function that works for active region or whole buffer
Date: Fri, 01 Feb 2013 08:55:25 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

>> goto-line and line-number-at-pos are expensive operations that count
>> (and re-count and re-re-count every time) the number of LF chars from
>> the beginning of the buffer.
> I'm using them only at the beginning of the function, and therefore
> once per function call, that does not sound very expensive to me.
> What do you suggest instead?

Use buffer positions.  I.e. (point) and (goto-char POS).
After (goto-char POS) you may call (beginning-of-line) or (end-of-line)
if you want to make sure you're at a line boundary.


        Stefan



reply via email to

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