From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?Andreas_R=c3=b6hler?= Newsgroups: gmane.emacs.help Subject: Re: pcase and minus-sign Date: Wed, 30 Nov 2016 14:30:11 +0100 Message-ID: References: <87r35tb0se.fsf@fastmail.fm> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1480512210 28216 195.159.176.226 (30 Nov 2016 13:23:30 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 30 Nov 2016 13:23:30 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux i686; rv:45.0) Gecko/20100101 Icedove/45.4.0 Cc: Help Gnu Emacs mailing list To: Joost Kremers Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 30 14:23:26 2016 Return-path: Envelope-to: geh-help-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 1cC4r6-0006gU-HJ for geh-help-gnu-emacs@m.gmane.org; Wed, 30 Nov 2016 14:23:24 +0100 Original-Received: from localhost ([::1]:44113 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cC4rA-00029o-8X for geh-help-gnu-emacs@m.gmane.org; Wed, 30 Nov 2016 08:23:28 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55200) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cC4p8-00018W-V1 for help-gnu-emacs@gnu.org; Wed, 30 Nov 2016 08:21:28 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cC4p4-0005wE-1m for help-gnu-emacs@gnu.org; Wed, 30 Nov 2016 08:21:22 -0500 Original-Received: from mout.kundenserver.de ([217.72.192.73]:60923) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cC4p3-0005tr-P4 for help-gnu-emacs@gnu.org; Wed, 30 Nov 2016 08:21:17 -0500 Original-Received: from [192.168.178.35] ([77.12.119.56]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.183]) with ESMTPSA (Nemesis) id 0MTP9j-1cJTCS12E3-00SSQl; Wed, 30 Nov 2016 14:21:11 +0100 In-Reply-To: <87r35tb0se.fsf@fastmail.fm> X-Provags-ID: V03:K0:tlbgnbFnFbamW3ln6vR0p160B0+9exmbn/400DDCEUB+so24Yko Y4tmE9+5btPy5umEbHRSY6y7yiUjvtlE+l7CaGrwiGqgxJkh4RRbe0tz5oZuEFViRG3+vnL Z+JN6WE+pdSbkmaE9dKTq8iu67BqhL+z0s4sNTxAJdeP8/t2ySV2N+F0qt+3f56lJV+aeDi SDig5m5/yVRE4zww6cSqg== X-UI-Out-Filterresults: notjunk:1;V01:K0:V/ZEZ4aEN58=:H4Eae58JL3Q7fB6cEjOupg 5KY8pJ39RUj850JQyo3t7DxFJpzaDfe6nLAhaN+BGcpJQK5iArI6mEncqhtJoUUCitfySPGQC I6n0Yod4kYZM3FNIz5OaNAUwnbMWHwgISdBikcRsRsoJ/pAEoIxRWuhO3Ww6LaMNPxHIdWotS ctB+DY6BzdBVhbg4R+7XxYPRdbypECBJkM/TIho8MX4RwVYI4Gw2LPZ2uHJRQ3oW78y/HMtiI /cCPWeLRk/mSanDe0MT3aGGq+5hmcBoSu3O4f+Xmfw7zc4oVPd2jP62Pj/dt7k+28qqU9fg7M VLnldemUhWxzIJE0PW779w19oyzpWEzqA5FNHEpvEqkPmRq4kJHcWjhJy1Xfq01IfLMhrlSfI rAXE4e+GuC4esoELTPMWlClFYwVd3MMhHu28oUmDamGF1P3FyYN5KpdWhJMB0GS85KuUdKear WPEJAsW73xbobcQ5dR35nuOfE5TDzM+Ba1KzEY+09D/UerpOB88ZE4f/U1rRsAmgUurrye0on f5NSw1A7GVesxr3DQRdX7B5+CNK15gJDaYvkopmSO9k4RtbzblG4Vvdaya7Q/FXDjLBPqWS4O rVzrPZg+ALPl4gRxUbOwuWz70Hv/6GAqPmRiliswn8RJSvyte1n2udhg6D2J7sPxT7sbnOQpD qYu+Qo/vJNlik6WS/Io+Xvhl4eHpEERSJoWMWZnHfcE6CAls/apcodZXkKWbfEd2ad3Q8fm2p u7TCeV4UB2JFk58z X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 217.72.192.73 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:111831 Archived-At: On 30.11.2016 13:38, Joost Kremers wrote: > > On Wed, Nov 30 2016, Andreas Röhler wrote: >> Hi, >> >> see code below. With numerical argument "1", first pattern is matched >> as expected. >> >> However without arg the minus is matched - the second pattern, not >> the default "_" at last. >> >> Any explanation? >> >> (defun foo (arg) >> (interactive "P") >> (pcase arg >> (1 (message "%s" "ARG was `1'")) >> (- (message "%s" "ARG was minus-sign")) >> (_ (message "%s" "ARG not minus-sign")))) > > Probably because - is a symbol and hence a variable. It works if you > quote it: > > (defun foo (arg) > (interactive "P") > (pcase arg > (1 (message "%s" "ARG was `1'")) > ('- (message "%s" "ARG was minus-sign")) > (_ (message "%s" "ARG not minus-sign")))) > > > Thanks, that helps. Seems it relates to the following in docstring: SYMBOL matches anything and binds it to SYMBOL. Now if I use some arbitrary char, like "a", (defun foo (arg) (interactive "P") (pcase arg (a (message "%s" "ARG was `a'")) (1 (message "%s" "ARG was `1'")) ('- (message "%s" "ARG was minus-sign")) (_ (message "%s" "ARG not minus-sign")))) It picks that a-branch at any case - as documented but strange.