I'm trying to implement «effective append» for log buffer, e.g. if a
point is at
point-max position then insert text and move
point to new
point-max, otherwise append text and preserve
I though this will be very trivial code:
(with-current-buffer (get-buffer-create "*scratch*") (if (eq (point) (point-max)) (insert "\n;; ===\n") (save-excursion (goto-char (point-max)) (insert "\n;; ===\n"))))
However, this works as expected only if invoked in
- having point somewhere in the middle => text appended, point not moved
- having point at the end of buffer => text appended, point at the end
Now if I change buffer and invoke this command again, point never goes to new point-max and always stays where it was.
Simple tests showed that
if statement gives correct results always, thus it is correct branch selected. I also tried explicitly move point or do scroll in
true-branch, but nothing helped:
(if (eq (point) (point-max)) (progn (insert "\n;; ===\n") (View-scroll-to-buffer-end) ;; not works (goto-char (point-max))) ;; so does it too (…))
Am I missing something?