all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Joost Kremers <joostkremers@fastmail.fm>
To: Hongyi Zhao <hongyi.zhao@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Use regex in ~/.emacs.d/init.el to match no_proxy.
Date: Sat, 10 Apr 2021 16:05:36 +0200	[thread overview]
Message-ID: <87h7kemdu8.fsf@fastmail.fm> (raw)
In-Reply-To: <CAGP6POLAXNXX1hc8nNJJZZZ-Xh9hkU20M2wpEbMjXkAFuTN8rg@mail.gmail.com>


On Sat, Apr 10 2021, Hongyi Zhao wrote:
> On Thu, Apr 8, 2021 at 2:29 PM Joost Kremers <joostkremers@fastmail.fm> wrote:
> 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?

They are different representations of the same thing. In IELM, the return value
is a string, as indicated by the double quotes surrounding the regexp. This is
what you would use in your init file (or in a Lisp program). Eshell prints the
string, i.e., shows you the string in a form that's meant for humans to look at.

-- 
Joost Kremers
Life has its moments



  reply	other threads:[~2021-04-10 14:05 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-06  8:22 Use regex in ~/.emacs.d/init.el to match no_proxy Hongyi Zhao
2021-04-06 11:32 ` Leo Butler
2021-04-06 16:26   ` Hongyi Zhao
2021-04-06 16:56     ` Gregory Heytings
2021-04-07  1:26       ` Hongyi Zhao
2021-04-07  7:19         ` tomas
2021-04-08  1:17           ` Hongyi Zhao
2021-04-08  6:24             ` Joost Kremers
2021-04-10 13:49               ` Hongyi Zhao
2021-04-10 14:05                 ` Joost Kremers [this message]
2021-04-11  0:04                   ` Hongyi Zhao
2021-04-11 11:12                     ` Joost Kremers
2021-04-11 12:33                       ` Tim Landscheidt
2021-04-11 13:17                         ` Hongyi Zhao
2021-04-11 13:47                           ` tomas
2021-04-11 21:47                         ` [External] : " Drew Adams
2021-04-12  7:46                           ` tomas
2021-04-08  7:00         ` Robert Thorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h7kemdu8.fsf@fastmail.fm \
    --to=joostkremers@fastmail.fm \
    --cc=help-gnu-emacs@gnu.org \
    --cc=hongyi.zhao@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.