all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* beginning-of-buffer computations
@ 2015-01-29 20:26 Marcin Borkowski
  2015-02-01 14:18 ` Michael Heerdegen
  2015-02-01 14:42 ` Robert Thorpe
  0 siblings, 2 replies; 7+ messages in thread
From: Marcin Borkowski @ 2015-01-29 20:26 UTC (permalink / raw)
  To: Help Gnu Emacs mailing list

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



^ permalink raw reply	[flat|nested] 7+ messages in thread
[parent not found: <mailman.18932.1422563201.1147.help-gnu-emacs@gnu.org>]

end of thread, other threads:[~2015-02-01 15:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-29 20:26 beginning-of-buffer computations Marcin Borkowski
2015-02-01 14:18 ` Michael Heerdegen
2015-02-01 14:42 ` Robert Thorpe
2015-02-01 14:47   ` Robert Thorpe
2015-02-01 14:52     ` Stefan Monnier
2015-02-01 15:55       ` Michael Heerdegen
     [not found] <mailman.18932.1422563201.1147.help-gnu-emacs@gnu.org>
2015-01-29 22:17 ` Barry Margolin

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.