* Use regex in ~/.emacs.d/init.el to match no_proxy.
@ 2021-04-06 8:22 Hongyi Zhao
2021-04-06 11:32 ` Leo Butler
0 siblings, 1 reply; 18+ messages in thread
From: Hongyi Zhao @ 2021-04-06 8:22 UTC (permalink / raw)
To: help-gnu-emacs
On Ubuntu 20.04, I set the following proxy settings in ~/.emacs.d/init.el,
;;; begin
(setq url-proxy-services '(
("no_proxy" .
"^\\(.*\\.cn\\|localhost\\|10\\..*\\|127\\..*\\|172\\.16\\..*\\|172\\.17\\..*\\|192\\.168\\..*\\)")
; "http://127.0.0.1:8080" doesn't work
("http" . "127.0.0.1:8080")
("https" . "127.0.0.1:8080")
))
;;; end
As you can see, the "no_proxy" string is rather cumbersome, and I want
to express the following, but I still don't know what to do:
"*.cn,localhost,10.0.0.0/8,127.0.0.0/8,172.16.0.0/12,192.168.0.0/16"
Any hints will be highly appreciated.
Regards
--
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Polytechnic University of Science and Technology engineering
NO. 552 North Gangtie Road, Xingtai, China
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Use regex in ~/.emacs.d/init.el to match no_proxy.
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
0 siblings, 1 reply; 18+ messages in thread
From: Leo Butler @ 2021-04-06 11:32 UTC (permalink / raw)
To: Hongyi Zhao; +Cc: help-gnu-emacs
Hongyi Zhao <hongyi.zhao@gmail.com> writes:
> On Ubuntu 20.04, I set the following proxy settings in ~/.emacs.d/init.el,
>
> ;;; begin
> (setq url-proxy-services '(
> ("no_proxy" .
> "^\\(.*\\.cn\\|localhost\\|10\\..*\\|127\\..*\\|172\\.16\\..*\\|172\\.17\\..*\\|192\\.168\\..*\\)")
> ; "http://127.0.0.1:8080" doesn't work
> ("http" . "127.0.0.1:8080")
> ("https" . "127.0.0.1:8080")
> ))
> ;;; end
>
> As you can see, the "no_proxy" string is rather cumbersome, and I want
> to express the following, but I still don't know what to do:
>
> "*.cn,localhost,10.0.0.0/8,127.0.0.0/8,172.16.0.0/12,192.168.0.0/16"
>
> Any hints will be highly appreciated.
C-h i f regexp-opt RET
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Use regex in ~/.emacs.d/init.el to match no_proxy.
2021-04-06 11:32 ` Leo Butler
@ 2021-04-06 16:26 ` Hongyi Zhao
2021-04-06 16:56 ` Gregory Heytings
0 siblings, 1 reply; 18+ messages in thread
From: Hongyi Zhao @ 2021-04-06 16:26 UTC (permalink / raw)
To: Leo Butler; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1193 bytes --]
On Tue, Apr 6, 2021 at 7:32 PM Leo Butler <leo.butler@umanitoba.ca> wrote:
>
> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>
> > On Ubuntu 20.04, I set the following proxy settings in
~/.emacs.d/init.el,
> >
> > ;;; begin
> > (setq url-proxy-services '(
> > ("no_proxy" .
> >
"^\\(.*\\.cn\\|localhost\\|10\\..*\\|127\\..*\\|172\\.16\\..*\\|172\\.17\\..*\\|192\\.168\\..*\\)")
> > ; "http://127.0.0.1:8080" doesn't work
> > ("http" . "127.0.0.1:8080")
> > ("https" . "127.0.0.1:8080")
> > ))
> > ;;; end
> >
> > As you can see, the "no_proxy" string is rather cumbersome, and I want
> > to express the following, but I still don't know what to do:
> >
> > "*.cn,localhost,10.0.0.0/8,127.0.0.0/8,172.16.0.0/12,192.168.0.0/16"
> >
> > Any hints will be highly appreciated.
>
>
> C-h i f regexp-opt RET
See the following screenshot:
[image: Screenshot from 2021-04-07 00-24-08.png]
What's wrong with my operation?
Regards
--
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Polytechnic University of Science and Technology engineering
NO. 552 North Gangtie Road, Xingtai, China
[-- Attachment #2: Screenshot from 2021-04-07 00-24-08.png --]
[-- Type: image/png, Size: 170937 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Use regex in ~/.emacs.d/init.el to match no_proxy.
2021-04-06 16:26 ` Hongyi Zhao
@ 2021-04-06 16:56 ` Gregory Heytings
2021-04-07 1:26 ` Hongyi Zhao
0 siblings, 1 reply; 18+ messages in thread
From: Gregory Heytings @ 2021-04-06 16:56 UTC (permalink / raw)
To: Hongyi Zhao; +Cc: help-gnu-emacs, Leo Butler
>>> As you can see, the "no_proxy" string is rather cumbersome, and I want
>>> to express the following, but I still don't know what to do:
>>>
>>> "*.cn,localhost,10.0.0.0/8,127.0.0.0/8,172.16.0.0/12,192.168.0.0/16"
>>>
>>> Any hints will be highly appreciated.
>>
>> C-h i f regexp-opt RET
>
That should have been C-h S regexp-opt RET.
(regexp-opt '("*.cn" "localhost" "10.0.0.0/8" "127.0.0.0/8" "172.16.0.0/12" "192.168.0.0/16"))
will return
"\\(?:\\*\\.cn\\|1\\(?:0\\.0\\.0\\.0/8\\|27\\.0\\.0\\.0/8\\|72\\.16\\.0\\.0/12\\|92\\.168\\.0\\.0/16\\)\\|localhost\\)"
but I suspect this is not what you want, because:
1. you probably want to add a ^ at the beginning and a $ at the end of the
regexp
2. you probably want to replace \\* by .+
3. regexp-opt does not understand that the IP address notation is a kind
of wildcard, IOW, you probably do not want to match "10.0.0.0/8" but
instead "10.0.0.1", "10.0.0.2", ..., "10.255.255.254", "10.255.255.255".
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Use regex in ~/.emacs.d/init.el to match no_proxy.
2021-04-06 16:56 ` Gregory Heytings
@ 2021-04-07 1:26 ` Hongyi Zhao
2021-04-07 7:19 ` tomas
2021-04-08 7:00 ` Robert Thorpe
0 siblings, 2 replies; 18+ messages in thread
From: Hongyi Zhao @ 2021-04-07 1:26 UTC (permalink / raw)
To: Gregory Heytings; +Cc: help-gnu-emacs, Leo Butler
On Wed, Apr 7, 2021 at 12:56 AM Gregory Heytings <gregory@heytings.org> wrote:
>
>
> >>> As you can see, the "no_proxy" string is rather cumbersome, and I want
> >>> to express the following, but I still don't know what to do:
> >>>
> >>> "*.cn,localhost,10.0.0.0/8,127.0.0.0/8,172.16.0.0/12,192.168.0.0/16"
> >>>
> >>> Any hints will be highly appreciated.
> >>
> >> C-h i f regexp-opt RET
> >
>
> That should have been C-h S regexp-opt RET.
I still failed to use the above key sequence to call the regexp-opt
elisp function.
>
> (regexp-opt '("*.cn" "localhost" "10.0.0.0/8" "127.0.0.0/8" "172.16.0.0/12" "192.168.0.0/16"))
>
> will return
>
> "\\(?:\\*\\.cn\\|1\\(?:0\\.0\\.0\\.0/8\\|27\\.0\\.0\\.0/8\\|72\\.16\\.0\\.0/12\\|92\\.168\\.0\\.0/16\\)\\|localhost\\)"
I obtained the above result by the following way:
M-S-: RET
Then paste the following into a small buffer at the bottom:
(regexp-opt '("*.cn" "localhost" "10.0.0.0/8" "127.0.0.0/8"
"172.16.0.0/12" "192.168.0.0/16"))
Hit RET and Emacs will give me the exactly same result as shown by you:
"\\(?:\\*\\.cn\\|1\\(?:0\\.0\\.0\\.0/8\\|27\\.0\\.0\\.0/8\\|72\\.16\\.0\\.0/12\\|92\\.168\\.0\\.0/16\\)\\|localhost\\)"
Additional Comment: I also tried to use the eshell method to call this
function, but failed as shown below:
M-x eshell RET
~ $ 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 type argument: list-or-vector-p, "Invalid function: \"*.cn\""
> but I suspect this is not what you want, because:
>
> 1. you probably want to add a ^ at the beginning and a $ at the end of the
> regexp
>
> 2. you probably want to replace \\* by .+
>
> 3. regexp-opt does not understand that the IP address notation is a kind
> of wildcard, IOW, you probably do not want to match "10.0.0.0/8" but
> instead "10.0.0.1", "10.0.0.2", ..., "10.255.255.254", "10.255.255.255".
Thanks for your notes.
Regards,
HY
--
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Polytechnic University of Science and Technology engineering
NO. 552 North Gangtie Road, Xingtai, China
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Use regex in ~/.emacs.d/init.el to match no_proxy.
2021-04-07 1:26 ` Hongyi Zhao
@ 2021-04-07 7:19 ` tomas
2021-04-08 1:17 ` Hongyi Zhao
2021-04-08 7:00 ` Robert Thorpe
1 sibling, 1 reply; 18+ messages in thread
From: tomas @ 2021-04-07 7:19 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1189 bytes --]
On Wed, Apr 07, 2021 at 09:26:42AM +0800, Hongyi Zhao wrote:
[...]
> Additional Comment: I also tried to use the eshell method to call this
> function, but failed as shown below:
>
> M-x eshell RET
>
> ~ $ regexp-opt ("*.cn" "localhost" "10.0.0.0/8" "127.0.0.0/8"
> "172.16.0.0/12" "192.168.0.0/16")
I don't know about your other points, but can give a hint on this
one. The `eshell' takes expressions in Lisp syntax, that means
you have to write `(function arg1 arg2 ...)' instead of the more
customary `function (arg1 arg2 ...)'. In your case:
[1] (regexp-opt "*.cn" "localhost" "10.0.0.0/8" "127.0.0.0/8" "172.16.0.0/12" "192.168.0.0/16")
will lead to the desired result. That's why:
> Wrong type argument: list-or-vector-p, "Invalid function: \"*.cn\""
eshell complains here: it is trying to apply a function `".cn"' to the
rest of the arguments. But there is no function with such a funny
name (quotes and all).
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"
as a convenience.
Cheers
- t
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Use regex in ~/.emacs.d/init.el to match no_proxy.
2021-04-07 7:19 ` tomas
@ 2021-04-08 1:17 ` Hongyi Zhao
2021-04-08 6:24 ` Joost Kremers
0 siblings, 1 reply; 18+ messages in thread
From: Hongyi Zhao @ 2021-04-08 1:17 UTC (permalink / raw)
To: tomas; +Cc: help-gnu-emacs
On Wed, Apr 7, 2021 at 3:19 PM <tomas@tuxteam.de> wrote:
>
> On Wed, Apr 07, 2021 at 09:26:42AM +0800, Hongyi Zhao wrote:
>
> [...]
>
> > Additional Comment: I also tried to use the eshell method to call this
> > function, but failed as shown below:
> >
> > M-x eshell RET
> >
> > ~ $ regexp-opt ("*.cn" "localhost" "10.0.0.0/8" "127.0.0.0/8"
> > "172.16.0.0/12" "192.168.0.0/16")
>
> I don't know about your other points, but can give a hint on this
> one. The `eshell' takes expressions in Lisp syntax, that means
> you have to write `(function arg1 arg2 ...)' instead of the more
> customary `function (arg1 arg2 ...)'. In your case:
>
> [1] (regexp-opt "*.cn" "localhost" "10.0.0.0/8" "127.0.0.0/8" "172.16.0.0/12" "192.168.0.0/16")
>
> will lead to the desired result. That's why:
>
> > Wrong type argument: list-or-vector-p, "Invalid function: \"*.cn\""
>
> eshell complains here: it is trying to apply a function `".cn"' to the
> rest of the arguments. But there is no function with such a funny
> name (quotes and all).
>
> 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
>
> as a convenience.
>
> Cheers
> - t
--
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Polytechnic University of Science and Technology engineering
NO. 552 North Gangtie Road, Xingtai, China
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Use regex in ~/.emacs.d/init.el to match no_proxy.
2021-04-08 1:17 ` Hongyi Zhao
@ 2021-04-08 6:24 ` Joost Kremers
2021-04-10 13:49 ` Hongyi Zhao
0 siblings, 1 reply; 18+ messages in thread
From: Joost Kremers @ 2021-04-08 6:24 UTC (permalink / raw)
To: Hongyi Zhao; +Cc: help-gnu-emacs
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"))
For Lisp interaction, I'd recommend `M-x ielm`, though.
HTH
--
Joost Kremers
Life has its moments
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Use regex in ~/.emacs.d/init.el to match no_proxy.
2021-04-08 6:24 ` Joost Kremers
@ 2021-04-10 13:49 ` Hongyi Zhao
2021-04-10 14:05 ` Joost Kremers
0 siblings, 1 reply; 18+ messages in thread
From: Hongyi Zhao @ 2021-04-10 13:49 UTC (permalink / raw)
To: Joost Kremers; +Cc: help-gnu-emacs
On Thu, Apr 8, 2021 at 2:29 PM Joost Kremers <joostkremers@fastmail.fm> 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 <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Polytechnic University of Science and Technology engineering
NO. 552 North Gangtie Road, Xingtai, China
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Use regex in ~/.emacs.d/init.el to match no_proxy.
2021-04-10 13:49 ` Hongyi Zhao
@ 2021-04-10 14:05 ` Joost Kremers
2021-04-11 0:04 ` Hongyi Zhao
0 siblings, 1 reply; 18+ messages in thread
From: Joost Kremers @ 2021-04-10 14:05 UTC (permalink / raw)
To: Hongyi Zhao; +Cc: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Use regex in ~/.emacs.d/init.el to match no_proxy.
2021-04-10 14:05 ` Joost Kremers
@ 2021-04-11 0:04 ` Hongyi Zhao
2021-04-11 11:12 ` Joost Kremers
0 siblings, 1 reply; 18+ messages in thread
From: Hongyi Zhao @ 2021-04-11 0:04 UTC (permalink / raw)
To: Joost Kremers; +Cc: help-gnu-emacs
On Sat, Apr 10, 2021 at 10:08 PM Joost Kremers <joostkremers@fastmail.fm> wrote:
>
>
> 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.
This is just what I wonder. Why can't we let Emacs use the
human-readable regexp string representation in its init file?
Regards
--
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Polytechnic University of Science and Technology engineering
NO. 552 North Gangtie Road, Xingtai, China
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Use regex in ~/.emacs.d/init.el to match no_proxy.
2021-04-11 0:04 ` Hongyi Zhao
@ 2021-04-11 11:12 ` Joost Kremers
2021-04-11 12:33 ` Tim Landscheidt
0 siblings, 1 reply; 18+ messages in thread
From: Joost Kremers @ 2021-04-11 11:12 UTC (permalink / raw)
To: Hongyi Zhao; +Cc: help-gnu-emacs
On Sun, Apr 11 2021, Hongyi Zhao wrote:
> This is just what I wonder. Why can't we let Emacs use the
> human-readable regexp string representation in its init file?
I guess the reason is "because it hasn't been implemented". There was a
suggestion recently on the emacs-devel mailing list to add a raw syntax or
regexp syntax to the Elisp reader, but nothing came of it.
In your use case, however, what I would do would be to put the call to
`regexp-opt` into my init file, not its return value. That makes it much more
readable and easier to modify if you ever need to.
--
Joost Kremers
Life has its moments
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Use regex in ~/.emacs.d/init.el to match no_proxy.
2021-04-11 11:12 ` Joost Kremers
@ 2021-04-11 12:33 ` Tim Landscheidt
2021-04-11 13:17 ` Hongyi Zhao
2021-04-11 21:47 ` [External] : " Drew Adams
0 siblings, 2 replies; 18+ messages in thread
From: Tim Landscheidt @ 2021-04-11 12:33 UTC (permalink / raw)
To: help-gnu-emacs
Joost Kremers <joostkremers@fastmail.fm> wrote:
>> This is just what I wonder. Why can't we let Emacs use the
>> human-readable regexp string representation in its init file?
> I guess the reason is "because it hasn't been implemented". There was a
> suggestion recently on the emacs-devel mailing list to add a raw syntax or
> regexp syntax to the Elisp reader, but nothing came of it.
> In your use case, however, what I would do would be to put the call to
> `regexp-opt` into my init file, not its return value. That makes it much more
> readable and easier to modify if you ever need to.
… and that is also the huge advantage of not having only hu-
man-readable strings in Emacs's init file, but being able to
program in Emacs Lisp whatever is needed. For "simple" cus-
tomizations, I recommend the Customization interface: It al-
lows to enter complex data structures in a guided way and
does The Right Thing™.
Tim
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Use regex in ~/.emacs.d/init.el to match no_proxy.
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
1 sibling, 1 reply; 18+ messages in thread
From: Hongyi Zhao @ 2021-04-11 13:17 UTC (permalink / raw)
To: Tim Landscheidt; +Cc: help-gnu-emacs
On Sun, Apr 11, 2021 at 8:42 PM Tim Landscheidt <tim@tim-landscheidt.de> wrote:
>
> Joost Kremers <joostkremers@fastmail.fm> wrote:
>
> >> This is just what I wonder. Why can't we let Emacs use the
> >> human-readable regexp string representation in its init file?
>
> > I guess the reason is "because it hasn't been implemented". There was a
> > suggestion recently on the emacs-devel mailing list to add a raw syntax or
> > regexp syntax to the Elisp reader, but nothing came of it.
>
> > In your use case, however, what I would do would be to put the call to
> > `regexp-opt` into my init file, not its return value. That makes it much more
> > readable and easier to modify if you ever need to.
>
> … and that is also the huge advantage of not having only hu-
> man-readable strings in Emacs's init file, but being able to
> program in Emacs Lisp whatever is needed. For "simple" cus-
> tomizations, I recommend the Customization interface: It al-
> lows to enter complex data structures in a guided way and
> does The Right Thing™.
Why do you use superscript `TM' here?
> Tim
>
>
--
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Polytechnic University of Science and Technology engineering
NO. 552 North Gangtie Road, Xingtai, China
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Use regex in ~/.emacs.d/init.el to match no_proxy.
2021-04-11 13:17 ` Hongyi Zhao
@ 2021-04-11 13:47 ` tomas
0 siblings, 0 replies; 18+ messages in thread
From: tomas @ 2021-04-11 13:47 UTC (permalink / raw)
To: Hongyi Zhao; +Cc: help-gnu-emacs, Tim Landscheidt
[-- Attachment #1: Type: text/plain, Size: 616 bytes --]
On Sun, Apr 11, 2021 at 09:17:15PM +0800, Hongyi Zhao wrote:
> On Sun, Apr 11, 2021 at 8:42 PM Tim Landscheidt <tim@tim-landscheidt.de> wrote:
[...]
> > lows to enter complex data structures in a guided way and
> > does The Right Thing™.
>
> Why do you use superscript `TM' here?
I'm not Tim, so I might be wrong. But I think it is not meant
literally, but as a somewhat ironical way of saying "this phrase
is used very often, perhaps too often" or sometimes "whatever
that means" or even perhaps "take with a grain of salt".
Making "The Right Thing" perhaps a bit less heavy.
Cheers
- t
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* RE: [External] : Re: Use regex in ~/.emacs.d/init.el to match no_proxy.
2021-04-11 12:33 ` Tim Landscheidt
2021-04-11 13:17 ` Hongyi Zhao
@ 2021-04-11 21:47 ` Drew Adams
2021-04-12 7:46 ` tomas
1 sibling, 1 reply; 18+ messages in thread
From: Drew Adams @ 2021-04-11 21:47 UTC (permalink / raw)
To: Tim Landscheidt, help-gnu-emacs@gnu.org
> … and that is also the huge advantage of not having only hu-
> man-readable strings in Emacs's init file, but being able to
> program in Emacs Lisp whatever is needed. For "simple" cus-
> tomizations, I recommend the Customization interface: It al-
> lows to enter complex data structures in a guided way and
> does The Right Thing™.
+1. Like many (most?), I find the Customize UI
somewhat ugly and clunky. And it's hard to ask
it what functions are involved underneath etc.
(hard to "ask Emacs" there).
But it is relatively straightforward. And it
do things correctly (setting, saving, backing
up, etc.; I don't mean that the UI is great).
And this is true not only for setting "simple"
option values etc. If the person writing the
defcustom (option definition) makes the effort,
the type-checking can be quite refined.
Unfortunately, too often, I think, defcustom
:type definitions are made too hastily or too
lazily. Partly it's a case of there being a
lack of predefined types for some things,
coupled with lack of knowledge (or inherent
difficulty) of defining new types.
But pretty much any Lisp values can be nailed
down relatively tightly, using `restricted-sexp'.
See (elisp) `Composite Types':
https://www.gnu.org/software/emacs/manual/html_node/elisp/Composite-Types.html
But Customize (and its underlying functions)
doesn't really help with some kinds of Emacs
customization - fiddling with the mode-line,
font-lock, menus, etc. For that, we could use
not only better UI for users to change things
but even better/handier Elisp knobs.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [External] : Re: Use regex in ~/.emacs.d/init.el to match no_proxy.
2021-04-11 21:47 ` [External] : " Drew Adams
@ 2021-04-12 7:46 ` tomas
0 siblings, 0 replies; 18+ messages in thread
From: tomas @ 2021-04-12 7:46 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 910 bytes --]
On Sun, Apr 11, 2021 at 09:47:51PM +0000, Drew Adams wrote:
> > … and that is also the huge advantage of not having only hu-
> > man-readable strings in Emacs's init file, but being able to
> > program in Emacs Lisp whatever is needed. For "simple" cus-
> > tomizations, I recommend the Customization interface: It al-
> > lows to enter complex data structures in a guided way and
> > does The Right Thing™.
>
> +1. Like many (most?), I find the Customize UI
> somewhat ugly and clunky. And it's hard to ask
> it what functions are involved underneath etc.
> (hard to "ask Emacs" there).
What I do there is to read whatever Customize has
written to custom.el.
Something to to for someone with spare cycles
(I know, I know) would be a link to a narrowed,
perhaps read-only view of that buffer (or even
more sneaky: a before-and-after view à la ediff
or similar).
Cheers
- t
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Use regex in ~/.emacs.d/init.el to match no_proxy.
2021-04-07 1:26 ` Hongyi Zhao
2021-04-07 7:19 ` tomas
@ 2021-04-08 7:00 ` Robert Thorpe
1 sibling, 0 replies; 18+ messages in thread
From: Robert Thorpe @ 2021-04-08 7:00 UTC (permalink / raw)
To: Hongyi Zhao, gregory; +Cc: help-gnu-emacs
Hongyi Zhao <hongyi.zhao@gmail.com> writes:
...
>> >> C-h i f regexp-opt RET
>> >
>>
>> That should have been C-h S regexp-opt RET.
>
> I still failed to use the above key sequence to call the regexp-opt
> elisp function.
Both of these also fail for me and I'm using Emacs 27.2.
However, doing "s regexp-opt RET" in the Elisp manual provides some
useful information.
BR,
Robert Thorpe
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2021-04-12 7:46 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).