unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#31236: [PATCH] Fix pre- and post-command-hook errors in term.el
@ 2018-04-22  3:41 Karl Otness
  2018-04-22 11:48 ` Phil Sainty
  0 siblings, 1 reply; 4+ messages in thread
From: Karl Otness @ 2018-04-22  3:41 UTC (permalink / raw)
  To: 31236

[-- Attachment #1: Type: text/plain, Size: 1157 bytes --]

As far as I can tell there isn't an existing bug report for this
issue. It is very minor but I have attached a fix. This affects Emacs
26.1-rc1 `term' and `ansi-term'. In char mode term installs functions
in both pre- and post-command-hooks. After the process exits both of
these hooks produce errors and then are removed by Emacs after
printing a message.

Both of these hooks are re-installed when entering char mode and
removing them if they are not present will do nothing. To produce this
change, I took the remove-hook lines used when entering line mode and
placed them in `term-handle-exit'.

To reproduce the issue in 26.1, M-x term, exit the running process and
execute any command (i.e. move point). In *Messages* there should be
the following lines:

Error in pre-command-hook (term-set-goto-process-mark):
(wrong-type-argument processp nil)
Error in post-command-hook (term-goto-process-mark-maybe):
(wrong-type-argument processp nil)

The error seems to come up from `process-mark'. After this change,
these errors no longer appear as the hooks are removed. I have
attached a patch which applies this change to current master.

Thank you,
Karl

[-- Attachment #2: 0001-Fix-pre-and-post-command-hook-errors-in-term.el.patch --]
[-- Type: text/x-patch, Size: 987 bytes --]

From e988914505a694b00eaff60ca226400d998c19aa Mon Sep 17 00:00:00 2001
From: Karl Otness <karl@karlotness.com>
Date: Sat, 21 Apr 2018 23:01:11 -0400
Subject: [PATCH] Fix pre- and post-command-hook errors in term.el

Before this patch, after the terminal process dies the command hooks
added in term-mode's char mode would produce errors. This fix removes
these hooks when the process dies.
---
 lisp/term.el | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lisp/term.el b/lisp/term.el
index cfb39c34e5..017b0221ec 100644
--- a/lisp/term.el
+++ b/lisp/term.el
@@ -1456,6 +1456,9 @@ term-handle-exit
   (let ((buffer-read-only nil)
 	(omax (point-max))
 	(opoint (point)))
+    ;; Remove hooks to avoid errors due to dead process.
+    (remove-hook 'pre-command-hook #'term-set-goto-process-mark t)
+    (remove-hook 'post-command-hook #'term-goto-process-mark-maybe t)
     ;; Record where we put the message, so we can ignore it
     ;; later on.
     (goto-char omax)
-- 
2.17.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#31236: [PATCH] Fix pre- and post-command-hook errors in term.el
  2018-04-22  3:41 bug#31236: [PATCH] Fix pre- and post-command-hook errors in term.el Karl Otness
@ 2018-04-22 11:48 ` Phil Sainty
  2018-04-22 17:09   ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Phil Sainty @ 2018-04-22 11:48 UTC (permalink / raw)
  To: Karl Otness; +Cc: bug-gnu-emacs, 31236

Bug and proposed fix confirmed and tested here.

This was an oversight on my part from #24837.

The suggested patch seems sensible to me.  If others agree, I think
this should be committed to the emacs-26 branch.


-Phil


On 2018-04-22 15:41, Karl Otness wrote:
> As far as I can tell there isn't an existing bug report for this
> issue. It is very minor but I have attached a fix. This affects Emacs
> 26.1-rc1 `term' and `ansi-term'. In char mode term installs functions
> in both pre- and post-command-hooks. After the process exits both of
> these hooks produce errors and then are removed by Emacs after
> printing a message.
> 
> Both of these hooks are re-installed when entering char mode and
> removing them if they are not present will do nothing. To produce this
> change, I took the remove-hook lines used when entering line mode and
> placed them in `term-handle-exit'.
> 
> To reproduce the issue in 26.1, M-x term, exit the running process and
> execute any command (i.e. move point). In *Messages* there should be
> the following lines:
> 
> Error in pre-command-hook (term-set-goto-process-mark):
> (wrong-type-argument processp nil)
> Error in post-command-hook (term-goto-process-mark-maybe):
> (wrong-type-argument processp nil)
> 
> The error seems to come up from `process-mark'. After this change,
> these errors no longer appear as the hooks are removed. I have
> attached a patch which applies this change to current master.
> 
> Thank you,
> Karl






^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#31236: [PATCH] Fix pre- and post-command-hook errors in term.el
  2018-04-22 11:48 ` Phil Sainty
@ 2018-04-22 17:09   ` Eli Zaretskii
  2018-04-22 18:54     ` Karl Otness
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2018-04-22 17:09 UTC (permalink / raw)
  To: Phil Sainty; +Cc: karl, 31236-done

> Date: Sun, 22 Apr 2018 23:48:38 +1200
> From: Phil Sainty <psainty@orcon.net.nz>
> Cc: bug-gnu-emacs <bug-gnu-emacs-bounces+psainty=orcon.net.nz@gnu.org>,
> 	31236@debbugs.gnu.org
> 
> Bug and proposed fix confirmed and tested here.
> 
> This was an oversight on my part from #24837.
> 
> The suggested patch seems sensible to me.  If others agree, I think
> this should be committed to the emacs-26 branch.

Pushed, thanks.

Karl, in the future please include a commit log message according to
the instructions in CONTRIBUTE.  (I fixed that for you this time.)





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#31236: [PATCH] Fix pre- and post-command-hook errors in term.el
  2018-04-22 17:09   ` Eli Zaretskii
@ 2018-04-22 18:54     ` Karl Otness
  0 siblings, 0 replies; 4+ messages in thread
From: Karl Otness @ 2018-04-22 18:54 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Phil Sainty, 31236-done

Will do, my mistake. Thank you for fixing it up.

Karl

On Sun, Apr 22, 2018 at 1:09 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>> Date: Sun, 22 Apr 2018 23:48:38 +1200
>> From: Phil Sainty <psainty@orcon.net.nz>
>> Cc: bug-gnu-emacs <bug-gnu-emacs-bounces+psainty=orcon.net.nz@gnu.org>,
>>       31236@debbugs.gnu.org
>>
>> Bug and proposed fix confirmed and tested here.
>>
>> This was an oversight on my part from #24837.
>>
>> The suggested patch seems sensible to me.  If others agree, I think
>> this should be committed to the emacs-26 branch.
>
> Pushed, thanks.
>
> Karl, in the future please include a commit log message according to
> the instructions in CONTRIBUTE.  (I fixed that for you this time.)





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-04-22 18:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-22  3:41 bug#31236: [PATCH] Fix pre- and post-command-hook errors in term.el Karl Otness
2018-04-22 11:48 ` Phil Sainty
2018-04-22 17:09   ` Eli Zaretskii
2018-04-22 18:54     ` Karl Otness

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).