So I'm reading through the Emacs Lisp intro, and I come across this function used as an example for save-excursion:
(message "We are %d characters into this buffer."
(- (point)
(save-excursion
(goto-char (point-min)) (point))))
This doesn't seem to make any sense in terms of why the save-excursion is there, what's the difference between that and this variation?
(message "We are %d characters into this buffer."
(point))
To me, it seems like all that
(save-excursion
(goto-char (point-min)) (point))
does is go to the beginning of the buffer and then call the point function...which will return zero. so then what we're effectively doing is subtracting the point called outside the save-excursion by 0. Is there some hidden functionality that I'm not catching or was that just put there for the sake of showing how save-excursion works?
(save-excursion (goto-char (point-min)) (point))could just be(point-min)-- which makes this a pretty weird example, given that the more verbose code uses(point-min). I'd say it's a contrived example for demonstration purposes, but that a better example would probably be sensible.M-x report-emacs-bug. Surely a better example could be used to illustrate whatsave-excursionis for.