From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: creating a function that works for active region or whole buffer Date: Fri, 01 Feb 2013 08:55:25 -0500 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1359726942 24488 80.91.229.3 (1 Feb 2013 13:55:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 1 Feb 2013 13:55:42 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Luca Ferrari Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Feb 01 14:55:59 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1U1H5y-00015m-MG for geh-help-gnu-emacs@m.gmane.org; Fri, 01 Feb 2013 14:55:58 +0100 Original-Received: from localhost ([::1]:39419 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1H5g-0003p4-Fi for geh-help-gnu-emacs@m.gmane.org; Fri, 01 Feb 2013 08:55:40 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:49992) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1H5X-0003iX-GM for help-gnu-emacs@gnu.org; Fri, 01 Feb 2013 08:55:32 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U1H5W-000719-2K for help-gnu-emacs@gnu.org; Fri, 01 Feb 2013 08:55:31 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:42583) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1H5V-00070m-UQ for help-gnu-emacs@gnu.org; Fri, 01 Feb 2013 08:55:29 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4EABK/CFFLd/iW/2dsb2JhbABEvw4Xc4IeAQEEAVYjEAsOJhIUGA0kiB4GwS2RCgOIYZwZgV6DFQ X-IPAS-Result: Av4EABK/CFFLd/iW/2dsb2JhbABEvw4Xc4IeAQEEAVYjEAsOJhIUGA0kiB4GwS2RCgOIYZwZgV6DFQ X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="190944" Original-Received: from 75-119-248-150.dsl.teksavvy.com (HELO pastel.home) ([75.119.248.150]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 01 Feb 2013 08:55:25 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id AA03158F88; Fri, 1 Feb 2013 08:55:25 -0500 (EST) In-Reply-To: (Luca Ferrari's message of "Fri, 1 Feb 2013 11:36:49 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.182 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:88906 Archived-At: >> 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