unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / 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

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 --
     [not found] <mailman.18932.1422563201.1147.help-gnu-emacs@gnu.org>
2015-01-29 22:17 ` beginning-of-buffer computations Barry Margolin
2015-01-29 20:26 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).