* bug#24618: 26.0.50; `condition-case' doesn't allow catching all signals @ 2016-10-04 16:42 Philipp Stephani 2018-08-14 2:38 ` Noam Postavsky 2018-09-04 23:06 ` Noam Postavsky 0 siblings, 2 replies; 3+ messages in thread From: Philipp Stephani @ 2016-10-04 16:42 UTC (permalink / raw) To: 24618 Consider the following code: (condition-case err (signal 'does-not-exist '(1 2)) (error (print err))) The signal is not caught by condition-case because it has no error conditions. This makes it impossible to reliably catch all signals (without abusing the debugger). I propose that an error condition of 't' in `condition-case' should be interpreted as 'all conditions'. In GNU Emacs 26.0.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.10.8) of 2016-10-04 built on unknown Repository revision: e2913dc880b9843bf69cf885270551bafeb46120 Windowing system distributor 'The X.Org Foundation', version 11.0.11501000 System Description: Ubuntu 14.04 LTS Recent messages: mwheel-scroll: Beginning of buffer [7 times] Mark set Sending... Mark set [2 times] Sending via mail... Setting ‘smtpmail-smtp-server’ temporarily since "emacs -q" would overwrite customizations Setting ‘smtpmail-smtp-service’ temporarily since "emacs -q" would overwrite customizations Sending email Sending email done Sending...done Configured using: 'configure --with-modules --enable-checking --enable-check-lisp-object-type' Configured features: XPM JPEG TIFF GIF PNG SOUND GSETTINGS NOTIFY GNUTLS FREETYPE XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 MODULES Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: Lisp Interaction Minor modes in effect: tooltip-mode: t global-eldoc-mode: t electric-indent-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 Load-path shadows: None found. Features: (network-stream nsm starttls tls gnutls mailalias smtpmail auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs qp cus-edit cus-start cus-load wid-edit pp shadow sort mail-extr emacsbug message subr-x puny seq byte-opt gv bytecomp byte-compile cl-extra help-mode cconv cl-loaddefs pcase cl-lib dired dired-loaddefs format-spec rfc822 mml easymenu mml-sec password-cache epa derived epg epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese charscript case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer cl-preloaded 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 inotify dynamic-setting system-font-setting font-render-setting move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 126071 14602) (symbols 48 22713 6) (miscs 40 341 241) (strings 32 23705 8690) (string-bytes 1 748309) (vectors 16 22599) (vector-slots 8 1236864 203799) (floats 8 222 372) (intervals 56 534 27) (buffers 976 15) (heap 1024 59649 5444)) -- Google Germany GmbH Erika-Mann-Straße 33 80636 München Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle Diese E-Mail ist vertraulich. Wenn Sie nicht der richtige Adressat sind, leiten Sie diese bitte nicht weiter, informieren Sie den Absender und löschen Sie die E-Mail und alle Anhänge. Vielen Dank. This e-mail is confidential. If you are not the right addressee please do not forward it, please inform the sender, and please erase this e-mail including any attachments. Thanks. ^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#24618: 26.0.50; `condition-case' doesn't allow catching all signals 2016-10-04 16:42 bug#24618: 26.0.50; `condition-case' doesn't allow catching all signals Philipp Stephani @ 2018-08-14 2:38 ` Noam Postavsky 2018-09-04 23:06 ` Noam Postavsky 1 sibling, 0 replies; 3+ messages in thread From: Noam Postavsky @ 2018-08-14 2:38 UTC (permalink / raw) To: Philipp Stephani; +Cc: 24618 [-- Attachment #1: Type: text/plain, Size: 623 bytes --] tags 24618 + patch quit Philipp Stephani <p.stephani2@gmail.com> writes: > Consider the following code: > > (condition-case err > (signal 'does-not-exist '(1 2)) > (error (print err))) > > The signal is not caught by condition-case because it has no error > conditions. This makes it impossible to reliably catch all signals > (without abusing the debugger). Yeah, I noticed this when I started looking at fixing ert to stop abusing the debugger like this (Bug#30745 and Bug#11218). > I propose that an error condition of 't' in `condition-case' should be > interpreted as 'all conditions'. Seems easy enough: [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: patch --] [-- Type: text/x-diff, Size: 3127 bytes --] From a18b70875fbcf22009e64bc9d809d1575fba3429 Mon Sep 17 00:00:00 2001 From: Noam Postavsky <npostavs@gmail.com> Date: Thu, 9 Aug 2018 21:26:30 -0400 Subject: [PATCH] Allow t as a catch-all condition-case handler (Bug#24618) * src/eval.c (find_handler_clause): Accept a handler of t as always matching. (Fcondition_case): * doc/lispref/control.texi (Handling Errors): Document this. * etc/NEWS: Announce it. --- doc/lispref/control.texi | 7 ++++--- etc/NEWS | 3 +++ src/eval.c | 10 ++++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/doc/lispref/control.texi b/doc/lispref/control.texi index 975ab3d075..8a6cf73af5 100644 --- a/doc/lispref/control.texi +++ b/doc/lispref/control.texi @@ -1878,9 +1878,10 @@ Handling Errors Each of the @var{handlers} is a list of the form @code{(@var{conditions} @var{body}@dots{})}. Here @var{conditions} is an error condition name to be handled, or a list of condition names (which can include @code{debug} -to allow the debugger to run before the handler); @var{body} is one or more -Lisp expressions to be executed when this handler handles an error. -Here are examples of handlers: +to allow the debugger to run before the handler). A condition name of +@code{t} matches any condition. @var{body} is one or more Lisp +expressions to be executed when this handler handles an error. Here +are examples of handlers: @example @group diff --git a/etc/NEWS b/etc/NEWS index 8abbd74e05..f7de6c7295 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -836,6 +836,9 @@ specially; they are now allocated like any other pseudovector. * Lisp Changes in Emacs 27.1 +++ +** 'condition-case' now accepts 't' to match any error symbol. + ++++ ** New function 'proper-list-p'. Given a proper list as argument, this predicate returns its length; otherwise, it returns nil. 'format-proper-list-p' is now an obsolete diff --git a/src/eval.c b/src/eval.c index 8745ba9ef9..8700f0e202 100644 --- a/src/eval.c +++ b/src/eval.c @@ -1215,9 +1215,9 @@ DEFUN ("condition-case", Fcondition_case, Scondition_case, 2, UNEVALLED, 0, Each element of HANDLERS looks like (CONDITION-NAME BODY...) where the BODY is made of Lisp expressions. -A handler is applicable to an error -if CONDITION-NAME is one of the error's condition names. -If an error happens, the first applicable handler is run. +A handler is applicable to an error if CONDITION-NAME is one of the +error's condition names. A CONDITION-NAME of t applies to any error +symbol. If an error happens, the first applicable handler is run. The car of a handler may be a list of condition names instead of a single condition name; then it handles all of them. If the special @@ -1854,7 +1854,9 @@ find_handler_clause (Lisp_Object handlers, Lisp_Object conditions) for (h = handlers; CONSP (h); h = XCDR (h)) { Lisp_Object handler = XCAR (h); - if (!NILP (Fmemq (handler, conditions))) + if (!NILP (Fmemq (handler, conditions)) + /* t is also used as a catch-all by Lisp code. */ + || EQ (handler, Qt)) return handlers; } -- 2.11.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* bug#24618: 26.0.50; `condition-case' doesn't allow catching all signals 2016-10-04 16:42 bug#24618: 26.0.50; `condition-case' doesn't allow catching all signals Philipp Stephani 2018-08-14 2:38 ` Noam Postavsky @ 2018-09-04 23:06 ` Noam Postavsky 1 sibling, 0 replies; 3+ messages in thread From: Noam Postavsky @ 2018-09-04 23:06 UTC (permalink / raw) To: Philipp Stephani; +Cc: 24618 tags 24618 fixed close 24618 27.1 quit Philipp Stephani <p.stephani2@gmail.com> writes: > Consider the following code: > > (condition-case err > (signal 'does-not-exist '(1 2)) > (error (print err))) > > The signal is not caught by condition-case because it has no error > conditions. This makes it impossible to reliably catch all signals > (without abusing the debugger). I propose that an error condition of > 't' in `condition-case' should be interpreted as 'all conditions'. Done in master. [1: 425c281164]: 2018-09-04 18:50:15 -0400 Allow t as a catch-all condition-case handler (Bug#24618) https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=425c2811641a6b8ec4549cad5f6bd15a46bc95d5 ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-09-04 23:06 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-10-04 16:42 bug#24618: 26.0.50; `condition-case' doesn't allow catching all signals Philipp Stephani 2018-08-14 2:38 ` Noam Postavsky 2018-09-04 23:06 ` 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.