* bug#23749: 24.3.50; can't make the cursor to the end of a buffer when that buffer is visible
@ 2016-06-12 2:01 Samuel Lê
2016-06-12 2:24 ` John Mastro
2016-06-12 2:25 ` Noam Postavsky
0 siblings, 2 replies; 5+ messages in thread
From: Samuel Lê @ 2016-06-12 2:01 UTC (permalink / raw)
To: 23749
- 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.
Thanks!
In GNU Emacs 24.3.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.10)
of 2013-08-17 on debianSam
Windowing system distributor `The X.Org Foundation', version 11.0.11604000
System Description: Debian GNU/Linux 8.4 (jessie)
Configured using:
`configure --prefix=/opt/emacs24'
Important settings:
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix
default enable-multibyte-characters: t
Major mode: Emacs-Lisp
Minor modes in effect:
tooltip-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
transient-mark-mode: t
Recent input:
C-x b <return> C-x 2 C-x C-f t e s t . <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> t e s t . e l <return> ( w i t h - c u
r r e n t - b u f f e r SPC " * s c r a t c h * " SPC
( i n s e r t SPC " t e s t \ n " ) SPC ( g o t o -
c h a t SPC ( p o i n t m <backspace> - m a x ) ) )
C-x C-e C-x k <return> <S-up> <down> C-k <S-up> C-x
o <left> <left> <left> <left> <left> <left> <left>
<left> <left> <left> <left> <left> <left> <left> <backspace>
r C-e C-x C-e <help-echo> M-x r e p o r t M-/ - e m
a c s - b u g <return>
Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
(New file)
Entering debugger...
Mark set [2 times]
198
Auto-saving...
Scanning for dabbrevs...done
user-error: No dynamic expansion for `report' found
Load-path shadows:
None found.
Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util
mail-prsvr mail-utils dabbrev help-mode easymenu debug time-date tooltip
ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd
fontset image regexp-opt fringe tabulated-list newcomment lisp-mode
prog-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
gfilenotify dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty emacs)
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#23749: 24.3.50; can't make the cursor to the end of a buffer when that buffer is visible
2016-06-12 2:01 bug#23749: 24.3.50; can't make the cursor to the end of a buffer when that buffer is visible Samuel Lê
@ 2016-06-12 2:24 ` John Mastro
2016-06-12 2:25 ` Noam Postavsky
1 sibling, 0 replies; 5+ messages in thread
From: John Mastro @ 2016-06-12 2:24 UTC (permalink / raw)
To: 23749; +Cc: Samuel Lê
Samuel Lê <samuel.le@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
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#23749: 24.3.50; can't make the cursor to the end of a buffer when that buffer is visible
2016-06-12 2:01 bug#23749: 24.3.50; can't make the cursor to the end of a buffer when that buffer is visible Samuel Lê
2016-06-12 2:24 ` John Mastro
@ 2016-06-12 2:25 ` Noam Postavsky
2016-06-12 15:44 ` Samuel Lê
1 sibling, 1 reply; 5+ messages in thread
From: Noam Postavsky @ 2016-06-12 2:25 UTC (permalink / raw)
To: Samuel Lê; +Cc: 23749
tag 23749 + notabug
quit
On Sat, Jun 11, 2016 at 10:01 PM, Samuel Lê <samuel.le@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.
>
> Thanks!
>
> In GNU Emacs 24.3.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.10)
I see the same with 25.0.95. I think it's not a bug, it's simply that
the window point is stored separately. You can use
(with-current-buffer "*scratch*"
(insert "test\n")
(set-window-point (get-buffer-window) (point-max)))
to set it. Or if there are multiple windows and you want to set the
point in all of them:
(with-current-buffer "*scratch*"
(insert "test\n")
(dolist (w (get-buffer-window-list))
(set-window-point w (point-max))))
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#23749: 24.3.50; can't make the cursor to the end of a buffer when that buffer is visible
2016-06-12 2:25 ` Noam Postavsky
@ 2016-06-12 15:44 ` Samuel Lê
2016-06-12 15:51 ` Noam Postavsky
0 siblings, 1 reply; 5+ messages in thread
From: Samuel Lê @ 2016-06-12 15:44 UTC (permalink / raw)
To: Noam Postavsky; +Cc: 23749
I managed to do what I wanted with:
(defun insert-into-buffer (buffer text)
(let ((buffer-window (get-buffer-window buffer)))
(if (not buffer-window)
(with-current-buffer buffer
(beginning-of-line)
(insert text)
(goto-char (point-max)))
(with-current-buffer buffer
(beginning-of-line)
(insert text)
(set-window-point (get-buffer-window) (point-max))))))
Thanks!
On 6/12/16, Noam Postavsky <npostavs@users.sourceforge.net> wrote:
> tag 23749 + notabug
> quit
>
> On Sat, Jun 11, 2016 at 10:01 PM, Samuel Lê <samuel.le@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.
>>
>> Thanks!
>>
>> In GNU Emacs 24.3.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.10)
>
> I see the same with 25.0.95. I think it's not a bug, it's simply that
> the window point is stored separately. You can use
>
> (with-current-buffer "*scratch*"
> (insert "test\n")
> (set-window-point (get-buffer-window) (point-max)))
>
> to set it. Or if there are multiple windows and you want to set the
> point in all of them:
>
> (with-current-buffer "*scratch*"
> (insert "test\n")
> (dolist (w (get-buffer-window-list))
> (set-window-point w (point-max))))
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#23749: 24.3.50; can't make the cursor to the end of a buffer when that buffer is visible
2016-06-12 15:44 ` Samuel Lê
@ 2016-06-12 15:51 ` Noam Postavsky
0 siblings, 0 replies; 5+ messages in thread
From: Noam Postavsky @ 2016-06-12 15:51 UTC (permalink / raw)
To: Samuel Lê; +Cc: 23749-done
Cool, could be compacted a little:
(defun insert-into-buffer (buffer text)
(with-current-buffer buffer
(beginning-of-line)
(insert text)
(let ((buffer-window (get-buffer-window)))
(if buffer-window
(set-window-point buffer-window (point-max))
(goto-char (point-max))))))
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-06-12 15:51 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-12 2:01 bug#23749: 24.3.50; can't make the cursor to the end of a buffer when that buffer is visible Samuel Lê
2016-06-12 2:24 ` John Mastro
2016-06-12 2:25 ` Noam Postavsky
2016-06-12 15:44 ` Samuel Lê
2016-06-12 15:51 ` Noam Postavsky
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.