From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Hongyi Zhao Newsgroups: gmane.emacs.help Subject: Re: Use regex in ~/.emacs.d/init.el to match no_proxy. Date: Sat, 10 Apr 2021 21:49:28 +0800 Message-ID: References: <8635w3d4wr.fsf@x201.butler.org> <20210407071939.GA13640@tuxteam.de> <87tuohthld.fsf@fastmail.fm> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19972"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs To: Joost Kremers Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 10 15:50:29 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lVE0K-00056y-J8 for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 10 Apr 2021 15:50:28 +0200 Original-Received: from localhost ([::1]:53002 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lVE0J-0000tF-Iu for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 10 Apr 2021 09:50:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lVDzb-0000qj-M1 for help-gnu-emacs@gnu.org; Sat, 10 Apr 2021 09:49:43 -0400 Original-Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]:43824) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lVDzZ-000803-Tc for help-gnu-emacs@gnu.org; Sat, 10 Apr 2021 09:49:43 -0400 Original-Received: by mail-lj1-x233.google.com with SMTP id y1so9737558ljm.10 for ; Sat, 10 Apr 2021 06:49:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nzBTKc8Vv4k7C29IPYZ18dDfGSAW4KJzMOIKMsZRC2E=; b=kMOvrCR+ZsPro/hzbPO+dmBWS/YLGOSTkFCKM3s2ym6cAlMF7YbXmalT04okf2rte+ uQ98AqA+pbRLo5+ewJQQVzZMt/5FBjOezqaerfcSLuihVai2Yu7JeOwUyhXZKl4jV+U+ 5ZiAKrqIkHZ5vzGcxO8ka61vMZisyGCaxXu5ZYalzGIt13/8aQRg6cxNm4IA2MtqHJKE 9GBbVBGNERU5aGEoW0oO89aoqfeQHf/AErl8RBgtA67mx+7QHW8L2xRPtT1kqlhjV1cG nYWVNsHebrGtTfxXRj8RPgLp9ub8eQLlbEL0bzqGlL2TJbD/wnBK0rEhvNnVR/QNJzCc 3Lcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nzBTKc8Vv4k7C29IPYZ18dDfGSAW4KJzMOIKMsZRC2E=; b=KtGpVBCWiH0HhjEHYALbITp3CV3BPqc1vUly2WHtSqGwcmgjCNOMxhljhPCliZGwnQ 5iFgqCa1n7hrlwu19Mpxn/fEtbbC9k5Xc9Uleg9pihrhQuULy/RP8Uvc0ECg1Ztmiwrq +PHwPVhHG9Iq+8M10mQ3oMmfbXs2dmbxew4RasG/igqJqJ77Y4ABZYKPzhASvYBSFj5I fuBUe64UVBeNLf5e/Q3pxQtJLEhnihN0snAV4UfnU/At4tG06kLnqoKlUAc8mYvPviK1 BYLreaYE9pbT6kXeczoucJVX3vjLVZ/aOVNSsZq3CQ0pgaSJp1bTWK+O+XfqY35i1FLY 9wQQ== X-Gm-Message-State: AOAM5328Gw2VnqdW5LZw9dHaWyHT7iCutqOg0/xlwl0F6lUM+XR655iu pX6/oRq151NUOtvgCRL+McLvKsPeamZldVXcmVw= X-Google-Smtp-Source: ABdhPJz1GPBQ8pOPN0/3TsHK327RC8Udz3/k/kUkz9Ih+KrBolzgp5gaoxJ68p3PLeOzrQ1cCkBpIDuWl1crCqoM+dw= X-Received: by 2002:a2e:9953:: with SMTP id r19mr4661095ljj.413.1618062580107; Sat, 10 Apr 2021 06:49:40 -0700 (PDT) In-Reply-To: <87tuohthld.fsf@fastmail.fm> Received-SPF: pass client-ip=2a00:1450:4864:20::233; envelope-from=hongyi.zhao@gmail.com; helo=mail-lj1-x233.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:128924 Archived-At: On Thu, Apr 8, 2021 at 2:29 PM Joost Kremers wrote: > > > On Thu, Apr 08 2021, Hongyi Zhao wrote: > >> Eshell allows you to leave out the outermost parentheses, so instead > >> of [1] you can also write > >> > >> [2] regexp-opt "*.cn" "localhost" "10.0.0.0/8" "127.0.0.0/8" "172.16.0.0/12" > >> "192.168.0.0/16" > > > > Still failed, as shown below: > > > > ~ $ regexp-opt "*.cn" "localhost" "10.0.0.0/8" "127.0.0.0/8" > > "172.16.0.0/12" "192.168.0.0/16" > > Wrong number of arguments: (1 . 2), 6 > > regexp-opt takes a list of strings, so you'd need: > > regexp-opt ("*.cn" "localhost" "10.0.0.0/8" "127.0.0.0/8" "172.16.0.0/12" "192.168.0.0/16") > > But that doesn't work because the parens are taken as a Lisp expression, so its > first element needs to be a function. Quoting it doen't work either: > > regexp-opt '("*.cn" "localhost" "10.0.0.0/8" "127.0.0.0/8" "172.16.0.0/12" "192.168.0.0/16") > > Because then eshell is waiting for the closing single quote. So just add the > parens around the entire expression: > > (regexp-opt '("*.cn" "localhost" "10.0.0.0/8" "127.0.0.0/8" "172.16.0.0/12" "192.168.0.0/16")) Really, it does the trick: ~ $ (regexp-opt '("*.cn" "localhost" "10.0.0.0/8" "127.0.0.0/8" "172.16.0.0/12" "192.168.0.0/16")) \(?:\*\.cn\|1\(?:0\.0\.0\.0/8\|27\.0\.0\.0/8\|72\.16\.0\.0/12\|92\.168\.0\.0/16\)\|localhost\) > For Lisp interaction, I'd recommend `M-x ielm`, though. This also works like a charm: ELISP> (regexp-opt '("*.cn" "localhost" "10.0.0.0/8" "127.0.0.0/8" "172.16.0.0/12" "192.168.0.0/16")) "\\(?:\\*\\.cn\\|1\\(?:0\\.0\\.0\\.0/8\\|27\\.0\\.0\\.0/8\\|72\\.16\\.0\\.0/12\\|92\\.168\\.0\\.0/16\\)\\|localhost\\)" But why the 2nd method gives the double '\\' escaped sequence for some metacharacters while the the 1st method doesn't? Regards -- Assoc. Prof. Hongyi Zhao Theory and Simulation of Materials Hebei Polytechnic University of Science and Technology engineering NO. 552 North Gangtie Road, Xingtai, China