From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Why post-command-hook so difficult to debug? Date: Tue, 28 Aug 2012 23:33:18 -0400 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1346211214 14505 80.91.229.3 (29 Aug 2012 03:33:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 29 Aug 2012 03:33:34 +0000 (UTC) Cc: emacs-devel@gnu.org To: Leo Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Aug 29 05:33:35 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1T6Z27-0004q7-0B for ged-emacs-devel@m.gmane.org; Wed, 29 Aug 2012 05:33:35 +0200 Original-Received: from localhost ([::1]:48230 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T6Z24-0003kh-Pc for ged-emacs-devel@m.gmane.org; Tue, 28 Aug 2012 23:33:32 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:50136) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T6Z21-0003kO-TP for emacs-devel@gnu.org; Tue, 28 Aug 2012 23:33:30 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T6Z1x-0003lZ-SP for emacs-devel@gnu.org; Tue, 28 Aug 2012 23:33:29 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:45419) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T6Z1x-0003lJ-OC for emacs-devel@gnu.org; Tue, 28 Aug 2012 23:33:25 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EAG6Zu09FxIRd/2dsb2JhbABEtBGBCIIVAQEEAVYjBQsLNBIUGA0kiBwFugmQRAOjM4FYgwWBOho X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="196953901" Original-Received: from 69-196-132-93.dsl.teksavvy.com (HELO pastel.home) ([69.196.132.93]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 28 Aug 2012 23:33:19 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 04D2459401; Tue, 28 Aug 2012 23:33:18 -0400 (EDT) In-Reply-To: (Leo's message of "Sun, 22 Jul 2012 10:40:20 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.182 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:152882 Archived-At: > For example, some days ago I was seeing this error: > Error in post-command-hook (completion-in-region--postch): > (wrong-type-argument characterp 134217855) > and it turned out the error was generated by another function 100 miles > from completion-in-region--postch. debug-on-error is mostly useless in > this case. > Can post-command-hook errors be more informative? Thanks. Well, we could make debug-on-error work in post-command-hook, but that will take some work. If someone's interested, here are the problems to solve: - post-command-hook is run (via safe_run_hooks) in the equivalent of a (condition-case nil ... (t nil)), so debug-on-error is ignored because the errors are caught. Maybe we can change debug-on-error to enter the debugger (rather than stay passive) when an error is caught by a `t' rather than by an `error' handler. - post-command-hook is also run in the debugger, so in order to avoid recursively entering the debugger, we'll need to remove the currently executing function from post-command-hook before entering the debugger. I think the best way to do that is to add a new hook debug-let-bindings-functions whose functions return lists of (VAR . VAL) pairs that should be re-bound during debugging. This way safe_run_hooks can add such a function to cause the current hook to be rebound temporarily with the debugged function removed. -- Stefan