From 7b3e94b6648ed00c6948c09267894b548b2868e7 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Thu, 24 Sep 2020 17:14:25 +0200 Subject: [PATCH] Make set-process-buffer also update the process mark * src/process.c (Fset_process_buffer): Update the process mark (bug#43573). --- doc/lispref/processes.texi | 3 ++- etc/NEWS | 4 ++++ src/process.c | 20 +++++++++++--------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi index 4556f8aeb54..855df4b9260 100644 --- a/doc/lispref/processes.texi +++ b/doc/lispref/processes.texi @@ -1576,7 +1576,8 @@ from previous output. @defun set-process-buffer process buffer This function sets the buffer associated with @var{process} to @var{buffer}. If @var{buffer} is @code{nil}, the process becomes -associated with no buffer. +associated with no buffer; if non-@code{nil}, the process mark will be +set to point to the end of @var{buffer}. @end defun @defun get-buffer-process buffer-or-name diff --git a/etc/NEWS b/etc/NEWS index fe2f5c37821..5cb31256ff4 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1277,6 +1277,10 @@ directory instead of the default directory. * Incompatible Lisp Changes in Emacs 28.1 + +** 'set-process-buffer' now updates the process mark. +The mark will be set to point to the end of the new buffer. + +++ ** Some properties from completion tables are now preserved. If 'minibuffer-allow-text-properties' is non-nil, doing completion diff --git a/src/process.c b/src/process.c index 948d1336468..ee8dcbbf749 100644 --- a/src/process.c +++ b/src/process.c @@ -1205,6 +1205,16 @@ not the name of the pty that Emacs uses to talk with that terminal. */) return XPROCESS (process)->tty_name; } +static void +update_process_mark (struct Lisp_Process *p) +{ + Lisp_Object buffer = p->buffer; + if (BUFFERP (buffer)) + set_marker_both (p->mark, buffer, + BUF_ZV (XBUFFER (buffer)), + BUF_ZV_BYTE (XBUFFER (buffer))); +} + DEFUN ("set-process-buffer", Fset_process_buffer, Sset_process_buffer, 2, 2, 0, doc: /* Set buffer associated with PROCESS to BUFFER (a buffer, or nil). @@ -1221,6 +1231,7 @@ Return BUFFER. */) if (NETCONN1_P (p) || SERIALCONN1_P (p) || PIPECONN1_P (p)) pset_childp (p, Fplist_put (p->childp, QCbuffer, buffer)); setup_process_coding_systems (process); + update_process_mark (p); return buffer; } @@ -1637,15 +1648,6 @@ DEFUN ("process-list", Fprocess_list, Sprocess_list, 0, 0, 0, return Fmapcar (Qcdr, Vprocess_alist); } -static void -update_process_mark (struct Lisp_Process *p) -{ - Lisp_Object buffer = p->buffer; - if (BUFFERP (buffer)) - set_marker_both (p->mark, buffer, - BUF_ZV (XBUFFER (buffer)), - BUF_ZV_BYTE (XBUFFER (buffer))); -} /* Starting asynchronous inferior processes. */ -- 2.39.2