From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Marcin Borkowski Newsgroups: gmane.emacs.help Subject: beginning-of-buffer computations Date: Thu, 29 Jan 2015 21:26:18 +0100 Message-ID: <87sietcp05.fsf@wmi.amu.edu.pl> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1422563215 6284 80.91.229.3 (29 Jan 2015 20:26:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 29 Jan 2015 20:26:55 +0000 (UTC) To: Help Gnu Emacs mailing list Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jan 29 21:26:55 2015 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 1YGvfw-0002bg-1l for geh-help-gnu-emacs@m.gmane.org; Thu, 29 Jan 2015 21:26:52 +0100 Original-Received: from localhost ([::1]:33495 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGvfv-0001FE-FH for geh-help-gnu-emacs@m.gmane.org; Thu, 29 Jan 2015 15:26:51 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60878) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGvfg-0001F8-15 for help-gnu-emacs@gnu.org; Thu, 29 Jan 2015 15:26:40 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YGvfZ-000740-Qs for help-gnu-emacs@gnu.org; Thu, 29 Jan 2015 15:26:35 -0500 Original-Received: from msg.wmi.amu.edu.pl ([2001:808:114:2::50]:60897) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGvfZ-00073v-JN for help-gnu-emacs@gnu.org; Thu, 29 Jan 2015 15:26:29 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by msg.wmi.amu.edu.pl (Postfix) with ESMTP id 28F154AD6E for ; Thu, 29 Jan 2015 21:26:28 +0100 (CET) Original-Received: from msg.wmi.amu.edu.pl ([127.0.0.1]) by localhost (msg.wmi.amu.edu.pl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id P1OxmZ6elE2l for ; Thu, 29 Jan 2015 21:26:28 +0100 (CET) Original-Received: from localhost (117-116.echostar.pl [213.156.117.116]) by msg.wmi.amu.edu.pl (Postfix) with ESMTPSA id D7D094AD6D for ; Thu, 29 Jan 2015 21:26:27 +0100 (CET) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:808:114:2::50 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:102370 Archived-At: Hello people, I'm continuing my journey through simple.el, and I've just found something strange. Apparently, a PhD in maths is not enough to grok the arithmetic operations in beginning-of-buffer...;-) (goto-char (if (and arg (not (consp arg))) (+ (point-min) (if (> size 10000) ;; Avoid overflow for large buffer sizes! (* (prefix-numeric-value arg) (/ size 10)) (/ (+ 10 (* size (prefix-numeric-value arg))) 10))) (point-min))) Now I pretty much see what is going on for "large buffers". For smaller ones, I'm wondering what is the rationale behind the `+ 10' part? It approximately adds one to the result (of course, the result is truncated to the next-lower-integer, so it's not that, ekhm, simple) - but why? (Not to mention the next line - not shown here - which `forward-line's by 1. Why not just (beginning-of-line) instead?) TIA, -- Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Faculty of Mathematics and Computer Science Adam Mickiewicz University