I have an elisp script that behaves differently between an interactive Emacs session and running Emacs with --batch.

(defun call-fn-in-let (unused)
  (let (xx)
    (let (yy)
      (split-string "foo" "bar" nil))))

  (insert "foofoofoo\nbarbarbar")
  (let ((dd (let (aa)
              (let (bb)
                (let (cc)
                  (progn (call-fn-in-let nil)))))))
    (let (ee)
        (goto-char (point-min))
        (if t
              (move-end-of-line nil)
              (message "point is: %s" (point))))))))

If I run M-x eval-buffer, then *Messages* shows:

point is: 10

However, if I run Emacs from the CLI, end-of-line behaves differently, jumping straight to end the of the file.

$ emacs -batch -l test/pyimport-test.el
point is: 20
$ emacs --version
GNU Emacs 24.5.1

I'm mystified why this is the case.

This is the most minimal example I can find. Even removing things like if t or an unused let binding, changes the -batch behaviour!

  • I've received a helpful bit of advice that (goto-char (point-at-eol)) works around the problem. However, I can't see why end-of-line changes. Jun 26 '16 at 11:45
  • 1
    Maybe it's a bug? I see it with 24.5.1, but not with Emacs 25 pretest (25.0.95) (i.e. Emacs 25 prints 17 and 23 in batch mode too)
    – npostavs
    Jun 26 '16 at 14:17
  • @npostavs I'm coming to the same conclusion. I've just compiled HEAD (commit 8419f0d166cf5107) and I can't replicate there. Jun 26 '16 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.