From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Leo Liu Newsgroups: gmane.emacs.bugs Subject: bug#16567: 24.3.50; pcase should signal an error if no case matches Date: Fri, 12 Sep 2014 10:35:29 +0800 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1410489391 29565 80.91.229.3 (12 Sep 2014 02:36:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 12 Sep 2014 02:36:31 +0000 (UTC) Cc: 16567@debbugs.gnu.org, Helmut Eller To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Sep 12 04:36:24 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1XSGij-00041Z-Bk for geb-bug-gnu-emacs@m.gmane.org; Fri, 12 Sep 2014 04:36:21 +0200 Original-Received: from localhost ([::1]:42118 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XSGij-0005G7-0O for geb-bug-gnu-emacs@m.gmane.org; Thu, 11 Sep 2014 22:36:21 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60475) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XSGiY-0005Bp-4Y for bug-gnu-emacs@gnu.org; Thu, 11 Sep 2014 22:36:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XSGiQ-0001h7-EF for bug-gnu-emacs@gnu.org; Thu, 11 Sep 2014 22:36:10 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:47155) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XSGiQ-0001h1-Bs for bug-gnu-emacs@gnu.org; Thu, 11 Sep 2014 22:36:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XSGiQ-00067M-2s for bug-gnu-emacs@gnu.org; Thu, 11 Sep 2014 22:36:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Leo Liu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 12 Sep 2014 02:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 16567 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 16567-submit@debbugs.gnu.org id=B16567.141048934123481 (code B ref 16567); Fri, 12 Sep 2014 02:36:02 +0000 Original-Received: (at 16567) by debbugs.gnu.org; 12 Sep 2014 02:35:41 +0000 Original-Received: from localhost ([127.0.0.1]:38719 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XSGi4-00066b-7J for submit@debbugs.gnu.org; Thu, 11 Sep 2014 22:35:40 -0400 Original-Received: from mail-pa0-f49.google.com ([209.85.220.49]:36136) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XSGi1-00066S-F2 for 16567@debbugs.gnu.org; Thu, 11 Sep 2014 22:35:38 -0400 Original-Received: by mail-pa0-f49.google.com with SMTP id lf10so183787pab.8 for <16567@debbugs.gnu.org>; Thu, 11 Sep 2014 19:35:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:face:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=aD9tIjmEmZucFIbc27nl2dS7znLDAN8z1b+oNT6f/H0=; b=CmdcHXa+9A1ni+AXqzrMPnigFlX7DZBpt/0kK6/5mxFfbK9jfWktPxNUOm3XcUgJVn BUeuzlZvQqXUaN9EfD5Q+yf3zuYurDAIx5Bcte2H6TAMYz/0XGjShWSyhCPp4pTeL3Is f765UXf3ys8VUckB6qh3u8QKzaS6SD4s0AGVxru/gaYd43Lvb0e6tqmrlnYhb1uyiJcw vDooqa71LXViGj72eGT2Nbp6E6a6PW4BEztuE8ijL0scmOfPk2AjxHv1OvE+dBaImrg2 wm6WcNp0rXEBCfG51zRQdmTFvRoUK2AyMBfjSmVCsYgmlFUDOhL/4qaOIPvF+tpwI0v/ 51jg== X-Received: by 10.70.50.170 with SMTP id d10mr2852366pdo.33.1410489336476; Thu, 11 Sep 2014 19:35:36 -0700 (PDT) Original-Received: from fortuna ([114.248.254.149]) by mx.google.com with ESMTPSA id jw6sm2238347pbc.79.2014.09.11.19.35.33 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Thu, 11 Sep 2014 19:35:35 -0700 (PDT) Face: iVBORw0KGgoAAAANSUhEUgAAACgAAAAoBAMAAAB+0KVeAAAAGFBMVEUzRVhbQj4eZqO6SjnT eWpxnMetm5b6/PmidmqrAAAAAWJLR0QAiAUdSAAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1F B9cBBwMLBfKABCMAAAFoSURBVCjPtZI9a8MwEIaFoc7aYDdelQMna0Em3tsSr0XUeE2Q6a22a+v+ fk8fSSBkbDUI6dHpfe9OEvRgiD+ApqKPJgJeB6iUUXWESjUe/ig38AJrhqqvaU2nTIXbNvOQ40fe qdry4kyGoVWsfCQalXpHnJGM01wjWdYbMlXNFdsZDO69m9aqNqxEJqTEgbM5OF7wlEfIoll1Ked4 LbM5X2EdILLokEdmI8z7g5cKED0cuTC930TYhy7ZDekkXVGw/L60TguJePPxcJF48lpsSUWEA/Ju jGFNgJOXc4Hz7TmAdBeu5Ve4AEjOi2/2jfd3cAJZ+IbNrvdjgBZY01b+HTuG3cLws6BJZqVOj/pp T0OqVwx3rFq+QmJwx3loK5JSLEhDIt62+mtC2C+SrAUxEbV6C6v2BRbd6pILBKFpepKZJHgGgrKF sptSUUoczpwg2pQ7ZH1tgs0ou/917mzz6Cs2//C978cv5l07L02orIEAAAAASUVORK5CYII= In-Reply-To: (Stefan Monnier's message of "Wed, 10 Sep 2014 13:54:18 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (CentOS 6.5) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:93283 Archived-At: Stefan, Which name would you prefer, `epcase' or 'pcasex'? Do you see any problems with the following patch (assume `pcasex' for now)? Thanks, Leo === modified file 'lisp/emacs-lisp/lisp-mode.el' --- lisp/emacs-lisp/lisp-mode.el 2014-06-19 14:03:45 +0000 +++ lisp/emacs-lisp/lisp-mode.el 2014-09-12 02:28:44 +0000 @@ -197,7 +197,7 @@ (el-vdefs '("defconst" "defcustom" "defvaralias" "defvar-local" "defface")) (el-tdefs '("defgroup" "deftheme")) - (el-kw '("while-no-input" "letrec" "pcase" "pcase-let" + (el-kw '("while-no-input" "letrec" "pcase" "pcasex" "pcase-let" "pcase-let*" "save-restriction" "save-excursion" "save-selected-window" ;; "eval-after-load" "eval-next-after-load" === modified file 'lisp/emacs-lisp/pcase.el' --- lisp/emacs-lisp/pcase.el 2014-09-06 00:59:00 +0000 +++ lisp/emacs-lisp/pcase.el 2014-09-10 10:44:59 +0000 @@ -68,6 +68,8 @@ (defconst pcase--dontcare-upats '(t _ pcase--dontcare)) +(defvar pcase--dontwarn-upats '(pcase--dontcare)) + (def-edebug-spec pcase-UPAT (&or symbolp @@ -148,6 +150,15 @@ ;; (puthash (car cases) `(,exp ,cases ,@expansion) pcase--memoize-2) expansion)))) +;;;###autoload +(defmacro pcasex (exp &rest cases) + "The exhausitive version of `pcase' (which see)." + (declare (indent 1) (debug pcase)) + (let* ((x (make-symbol "x")) + (pcase--dontwarn-upats (cons x pcase--dontwarn-upats))) + (pcase--expand + exp (append cases `((,x (error "No clause matching `%S'" ,x))))))) + (defun pcase--let* (bindings body) (cond ((null bindings) (macroexp-progn body)) @@ -280,7 +291,8 @@ vars)))) cases)))) (dolist (case cases) - (unless (or (memq case used-cases) (eq (car case) 'pcase--dontcare)) + (unless (or (memq case used-cases) + (memq (car case) pcase--dontwarn-upats)) (message "Redundant pcase pattern: %S" (car case)))) (macroexp-let* defs main))))