From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Vasilij Schneidermann Newsgroups: gmane.emacs.bugs Subject: bug#24514: 24.5; [WIP][PATCH] Lispy backtraces Date: Fri, 30 Sep 2016 12:29:56 +0200 Message-ID: <20160930102956.GA666@odonien.localdomain> References: <20160922231447.GA3833@odonien.localdomain> <20160927191603.GA610@odonien.localdomain> <8337kkoxhb.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="IS0zKkzwUGydFO0o" X-Trace: blaine.gmane.org 1475231594 13408 195.159.176.226 (30 Sep 2016 10:33:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 30 Sep 2016 10:33:14 +0000 (UTC) User-Agent: Mutt/1.7.0 (2016-08-17) Cc: 24514@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Sep 30 12:33:10 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpv7p-0002IC-3A for geb-bug-gnu-emacs@m.gmane.org; Fri, 30 Sep 2016 12:33:05 +0200 Original-Received: from localhost ([::1]:43054 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpv7n-0006r0-IC for geb-bug-gnu-emacs@m.gmane.org; Fri, 30 Sep 2016 06:33:03 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48610) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpv5u-00057d-Ez for bug-gnu-emacs@gnu.org; Fri, 30 Sep 2016 06:31:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bpv5q-0000sn-D9 for bug-gnu-emacs@gnu.org; Fri, 30 Sep 2016 06:31:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33111) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpv5q-0000sj-9d for bug-gnu-emacs@gnu.org; Fri, 30 Sep 2016 06:31:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bpv5q-0002JZ-51 for bug-gnu-emacs@gnu.org; Fri, 30 Sep 2016 06:31:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Vasilij Schneidermann Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 30 Sep 2016 10:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24514 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 24514-submit@debbugs.gnu.org id=B24514.14752314218850 (code B ref 24514); Fri, 30 Sep 2016 10:31:02 +0000 Original-Received: (at 24514) by debbugs.gnu.org; 30 Sep 2016 10:30:21 +0000 Original-Received: from localhost ([127.0.0.1]:39301 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpv5A-0002Ig-Rm for submit@debbugs.gnu.org; Fri, 30 Sep 2016 06:30:21 -0400 Original-Received: from mail-wm0-f66.google.com ([74.125.82.66]:33916) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpv58-0002IT-CP for 24514@debbugs.gnu.org; Fri, 30 Sep 2016 06:30:18 -0400 Original-Received: by mail-wm0-f66.google.com with SMTP id p197so1317490wmg.1 for <24514@debbugs.gnu.org>; Fri, 30 Sep 2016 03:30:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=j4wAH0aFRxeMDQgObUjFBCYZNxt1On249kXXdgV++YQ=; b=P4rdu/mDNe7BsFV8k0EXCnFxczD+pSDCSm/QSm31BodcA4Xbpfnm/ImOCOzEJvjxBg 2guO+jSHJlLpJQ60z9EmSvV9BKVyZJ2GItY+kjuML1rSYKApox9kdyfEEqkWYytItqW6 6h6toCo/gO4Yuw3Qk0aYwXFC1vWd16qI8ZMWLDeIgMlIDYXQAa1xKlBpg4XXhJ5/V+FJ RSMlEejji/J2y0/RYwgmGZW8T/HY2Rx+eph1X3/Z0Ru/nv73HCvarwdfkQNW/7KlXW1x d73avbIwTuvHB3UFJy63pSyBCguml3mxQefw7tMpghQFMLPAc3TbG40XYBQza7sNjV7P H0xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=j4wAH0aFRxeMDQgObUjFBCYZNxt1On249kXXdgV++YQ=; b=QxsbRRo0zTCChUcujAjHMMS/oBu/ymfYl8mPJ1vSOCZIUwrxoJXvJUyxl3/MGh2CP8 lHaee2T9YRTRTgb+swb58BFu4+zhZJVG1uRzqp8RxgP5S2ny89HbIICj1nb7kLvTlPf5 tlZXck6YKLBod5NhjPxQSYfAU01pnEOFTDJyBIzS7/zJvBwuAHra9Vcbki5J+pHgLRf9 KSiEbjyWY91TUx8z6hrqabyYwNoVWOJlO2W0EPd5QH2lHx0DZ7hgdSsym2ZW8FvYowJC RbvSyi96ybRCdbyG7yw+rHtUamhSIsKInYajeDRrOt4XVRSO6jI2avS2/L9LLo/MzrK2 YZHA== X-Gm-Message-State: AA6/9RnpmwtukcjQBnC781pq9hGcYdNPQ6f/o8wYEP2EeBzwLSVRZX8JejVAzHedeyESqw== X-Received: by 10.28.196.200 with SMTP id u191mr2951172wmf.67.1475231412630; Fri, 30 Sep 2016 03:30:12 -0700 (PDT) Original-Received: from localhost ([2.160.70.242]) by smtp.gmail.com with ESMTPSA id 193sm3421361wmo.14.2016.09.30.03.30.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Sep 2016 03:30:11 -0700 (PDT) Content-Disposition: inline In-Reply-To: <8337kkoxhb.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:123786 Archived-At: --IS0zKkzwUGydFO0o Content-Type: text/plain; charset=utf-8 Content-Disposition: inline > How about debugger-stack-frame-as-list? Thanks, sounds good to me. > Two minor nits to make this patch perfect: > > . Add the variable to cus-start.el, so that it will be a defcustom > . Add a NEWS entry and mention the variable in the ELisp manual I've done these and changed the commit message to comply better with the changelog style. Let me know if there's still something off. --IS0zKkzwUGydFO0o Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0001-Add-new-debugger-stack-frame-as-list-option.patch" >From 62d47f75adc8d319b6fc35bb79bcf316d16bec00 Mon Sep 17 00:00:00 2001 From: Vasilij Schneidermann Date: Thu, 22 Sep 2016 23:01:21 +0200 Subject: [PATCH] Add new 'debugger-stack-frame-as-list' option Allow displaying all lines in `backtrace' as lists. * doc/lispref/debugging.texi: Document the new variable * src/eval.c: New variable * lisp/emacs-lisp/debug.el: Adjust backtrace processing for new variable * lisp/emacs-lisp/edebug.el: Adjust backtrace processing for new variable --- doc/lispref/debugging.texi | 29 +++++++++++++++++++++++++++++ etc/NEWS | 5 +++++ lisp/cus-start.el | 1 + lisp/emacs-lisp/debug.el | 4 +++- lisp/emacs-lisp/edebug.el | 4 +++- src/eval.c | 12 ++++++++++-- 6 files changed, 51 insertions(+), 4 deletions(-) diff --git a/doc/lispref/debugging.texi b/doc/lispref/debugging.texi index 98c4705..15eea8a 100644 --- a/doc/lispref/debugging.texi +++ b/doc/lispref/debugging.texi @@ -623,6 +623,35 @@ forms are elided. @end smallexample @end deffn +@defvar debugger-stack-frame-as-list +If this variable is non-@code{nil}, every line of the backtrace is +displayed as a list. This aims to improve backtrace readability at +the cost of special forms no longer being visually different from +regular function calls. + +The above example would look as follows: +@smallexample +@group +----------- Buffer: backtrace-output ------------ + (backtrace) + (list ...computing arguments...) +@end group + (progn ...) + (eval (progn (1+ var) (list (quote testing) (backtrace)))) + (setq ...) + (save-excursion ...) + (let ...) + (with-output-to-temp-buffer ...) + (eval (with-output-to-temp-buffer ...)) + (eval-last-sexp-1 nil) +@group + (eval-last-sexp nil) + (call-interactively eval-last-sexp) +----------- Buffer: backtrace-output ------------ +@end group +@end smallexample +@end defvar + @defvar debug-on-next-call @cindex @code{eval}, and debugging @cindex @code{apply}, and debugging diff --git a/etc/NEWS b/etc/NEWS index a72be53..a88d9ec 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -179,6 +179,11 @@ questions, with a handy way to display help texts. +++ ** 'switch-to-buffer-preserve-window-point' now defaults to t. ++++ +** The new variable 'debugger-stack-frame-as-list' allows displaying +all call stack frames in 'backtrace' as lists. Both debug.el and +edebug.el have been updated accordingly. + * Editing Changes in Emacs 25.2 diff --git a/lisp/cus-start.el b/lisp/cus-start.el index c830ed8..c6d0ae4 100644 --- a/lisp/cus-start.el +++ b/lisp/cus-start.el @@ -246,6 +246,7 @@ Leaving \"Default\" unchecked is equivalent with specifying a default of (debug-ignored-errors debug (repeat (choice symbol regexp))) (debug-on-quit debug boolean) (debug-on-signal debug boolean) + (debugger-stack-frame-as-list debugger boolean) ;; fileio.c (delete-by-moving-to-trash auto-save boolean "23.1") (auto-save-visited-file-name auto-save boolean) diff --git a/lisp/emacs-lisp/debug.el b/lisp/emacs-lisp/debug.el index 22a3f39..7d27380 100644 --- a/lisp/emacs-lisp/debug.el +++ b/lisp/emacs-lisp/debug.el @@ -279,7 +279,9 @@ That buffer should be current already." (goto-char (point-min)) (delete-region (point) (progn - (search-forward "\n debug(") + (search-forward (if debugger-stack-frame-as-list + "\n (debug " + "\n debug(")) (forward-line (if (eq (car args) 'debug) ;; Remove debug--implement-debug-on-entry ;; and the advice's `apply' frame. diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el index c283c16..0c2a8ad 100644 --- a/lisp/emacs-lisp/edebug.el +++ b/lisp/emacs-lisp/edebug.el @@ -3797,7 +3797,9 @@ Otherwise call `debug' normally." (forward-line 1) (delete-region last-ok-point (point))) - ((looking-at "^ edebug") + ((looking-at (if debugger-stack-frame-as-list + "^ (edebug" + "^ edebug")) (forward-line 1) (delete-region last-ok-point (point)) ))) diff --git a/src/eval.c b/src/eval.c index 72facd5..f07cc83 100644 --- a/src/eval.c +++ b/src/eval.c @@ -3409,13 +3409,17 @@ Output stream used is value of `standard-output'. */) else { tem = backtrace_function (pdl); + if (debugger_stack_frame_as_list) + write_string ("("); Fprin1 (tem, Qnil); /* This can QUIT. */ - write_string ("("); + if (!debugger_stack_frame_as_list) + write_string ("("); { ptrdiff_t i; for (i = 0; i < backtrace_nargs (pdl); i++) { - if (i) write_string (" "); + if (i || debugger_stack_frame_as_list) + write_string(" "); Fprin1 (backtrace_args (pdl)[i], Qnil); } } @@ -3838,6 +3842,10 @@ This is nil when the debugger is called under circumstances where it might not be safe to continue. */); debugger_may_continue = 1; + DEFVAR_BOOL ("debugger-stack-frame-as-list", debugger_stack_frame_as_list, + doc: /* Non-nil means display call stack frames as lists. */); + debugger_stack_frame_as_list = 0; + DEFVAR_LISP ("debugger", Vdebugger, doc: /* Function to call to invoke debugger. If due to frame exit, args are `exit' and the value being returned; -- 2.10.0 --IS0zKkzwUGydFO0o--