GNU bug report logs - #23749
24.3.50; can't make the cursor to the end of a buffer when that buffer is visible

Previous Next

Package: emacs;

Reported by: Samuel Lê <samuel.le <at> gmail.com>

Date: Sun, 12 Jun 2016 02:02:01 UTC

Severity: normal

Tags: notabug

Found in version 24.3.50

Done: Noam Postavsky <npostavs <at> users.sourceforge.net>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 23749 <at> debbugs.gnu.org (full text, mbox):

From: John Mastro <john.b.mastro <at> gmail.com>
To: 23749 <at> debbugs.gnu.org
Cc: Samuel Lê <samuel.le <at> gmail.com>
Subject: Re: bug#23749: 24.3.50; can't make the cursor to the end of a buffer
 when that buffer is visible
Date: Sat, 11 Jun 2016 19:24:09 -0700
Samuel Lê <samuel.le <at> gmail.com> wrote:
> - run "emacs -Q" from command line.
> - split emacs screen (C-x 2)
> - on one side open an elisp code (say test.el)
> - on the other side put the *scratch* buffer
> - in test.el, enter (with-current-buffer "*scratch* (insert "test\n")
> (goto-char (point-max)))
> - then press C-x e to evaluate that command
> - it inserts "test" in *scratch* buffer but doesnt go at the end of the
> - buffer.
>
> It works fine when buffer *scratch* is not visible.

I confirmed that the behavior is the same in Emacs 25.0.94, but I
suspect this is not a bug because there's also a concept of "window
point" (see `window-point').

Adding `with-selected-window' will cause point to move as you expected:

(with-current-buffer "*scratch*"
  (with-selected-window (get-buffer-window (current-buffer))
    (insert "test\n")
    (goto-char (point-max))))

However, if the buffer isn't shown in a window, `get-buffer-window' will
return nil and `with-selected-window' will thus signal an error. So the
right fix really depends on the context and ultimate goal.

        John




This bug report was last modified 9 years and 66 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.