This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-02-16
Channels
- # aws (6)
- # beginners (129)
- # calva (9)
- # cider (4)
- # cljs-dev (2)
- # clojure (41)
- # clojure-beijing (2)
- # clojure-dev (3)
- # clojure-spec (23)
- # clojure-uk (46)
- # clojurescript (38)
- # community-development (20)
- # core-async (4)
- # cursive (12)
- # data-science (7)
- # datascript (13)
- # datomic (15)
- # duct (11)
- # emacs (18)
- # figwheel-main (5)
- # fulcro (26)
- # off-topic (4)
- # pathom (28)
- # pedestal (3)
- # reagent (8)
- # reitit (6)
- # shadow-cljs (32)
- # specter (3)
trying to insert contents into another buffer and move point to the end of the buffer. not having luck. Create a buffer named random
, and then
(with-current-buffer "random"
(goto-char (point-max))
(insert "\nbob\n")
(goto-char (point-max))
)
and no luck. point stays where it was as if there was an unwind-protect somewhere. anyone know how to do this?Are you possibly inside a save-excursion
?
FWIW: (with-current-buffer "*scratch*" (goto-char (point-max)) (insert "foo\n"))
works for me
i think that's because you're currently there. do it with a buffer that is separate from your current view
https://stackoverflow.com/questions/13530025/emacs-scroll-automatically-when-inserting-text also see this
You’re right, if the buffer isn’t visible it won’t move the point
Seems like we do this in a couple of places:
(with-selected-window (or (get-buffer-window ...buffer-name...)
(selected-window))
...)
I guess if the buffer isn’t in any live window we have to leave the point where it is
ok. there's a problem if the buffer isn't visible in a window. can't use with-selected-window
. how about something like this:
(defun cider-insert-in-repl (form eval)
"Insert FORM in the REPL buffer and switch to it.
If EVAL is non-nil the form will also be evaluated."
(while (string-match "\\`[ \t\n\r]+\\|[ \t\n\r]+\\'" form)
(setq form (replace-match "" t t form)))
(let ((repl (cider-current-repl)))
(if-let* ((window (get-buffer-window repl)))
(with-selected-window window
(cider--insert-in-repl form eval))
(with-current-buffer repl
(cider--insert-in-repl form eval))))
(when cider-switch-to-repl-after-insert-p
(cider-switch-to-repl-buffer)))
ie, if there's a window, use with-selected-window
else fall back to with-current-buffer and it won't scroll, but its not visible so whatever