* What is "splicing mode" in el-search.el?
@ 2016-09-06 14:09 Chunyang Xu
2016-09-06 14:45 ` Michael Heerdegen
2016-09-06 14:48 ` tomas
0 siblings, 2 replies; 6+ messages in thread
From: Chunyang Xu @ 2016-09-06 14:09 UTC (permalink / raw)
To: michael_heerdegen, help-gnu-emacs
Hello!
I tried el-search.el from gnu elpa and have one problem with it. The
Commentary of el-search.el mentions "splicing mode", but I can't
figure out what it means, can you give me an example?
;; It is possible to replace a match with multiple expressions using
;; "splicing mode". When it is active, the replacement expression
;; must evaluate to a list, and is spliced instead of inserted into
;; the buffer for any replaced match.
Thanks!
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: What is "splicing mode" in el-search.el?
2016-09-06 14:09 What is "splicing mode" in el-search.el? Chunyang Xu
@ 2016-09-06 14:45 ` Michael Heerdegen
2016-09-06 14:58 ` Michael Heerdegen
2016-09-06 17:55 ` Chunyang Xu
2016-09-06 14:48 ` tomas
1 sibling, 2 replies; 6+ messages in thread
From: Michael Heerdegen @ 2016-09-06 14:45 UTC (permalink / raw)
To: Chunyang Xu; +Cc: help-gnu-emacs
Hello Chunyang!
> I tried el-search.el from gnu elpa and have one problem with it.
Great, this is the first remark I got about it :-) Your comments are
much appreciated, please report every discrepancy you find. Multi-file
support will come soon, btw.
> The Commentary of el-search.el mentions "splicing mode", but I can't
> figure out what it means, can you give me an example?
>
> ;; It is possible to replace a match with multiple expressions using
> ;; "splicing mode". When it is active, the replacement expression
> ;; must evaluate to a list, and is spliced instead of inserted into
> ;; the buffer for any replaced match.
It just means that instead of the list, it's elements are inserted into
the buffer, in the same order as in the list. If you replace e.g. this
`(f . ,args) -> args
and you have in some buffer
(f x y)
then this would normally be replaced with
(x y)
but with splicing mode turned on, you would get
x y
(Do you have a suggestion for a better name?)
But it seems I have broken this submode with one of my latest commits, I
get an error here when I try to enable it. Will try to fix soon.
Thanks,
Michael.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: What is "splicing mode" in el-search.el?
2016-09-06 14:45 ` Michael Heerdegen
@ 2016-09-06 14:58 ` Michael Heerdegen
2016-09-06 17:55 ` Chunyang Xu
1 sibling, 0 replies; 6+ messages in thread
From: Michael Heerdegen @ 2016-09-06 14:58 UTC (permalink / raw)
To: Chunyang Xu; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 220 bytes --]
Michael Heerdegen <michael_heerdegen@web.de> writes:
> But it seems I have broken this submode with one of my latest commits,
> I get an error here when I try to enable it. Will try to fix soon.
Here is a quick fix:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: el-search.patch --]
[-- Type: text/x-diff, Size: 1181 bytes --]
*** /tmp/ediff32294tUJ 2016-09-06 16:55:46.448723416 +0200
--- /home/micha/software/elpa/packages/el-search/el-search.el 2016-09-06 16:54:46.567573946 +0200
***************
*** 647,655 ****
(el-search--ensure-sexp-start)
(end-of-buffer (goto-char (point-max))))))
(goto-char 1)
! (forward-sexp)
(let ((result (buffer-substring 1 (point))))
! (if (equal replacement (read result))
result
(error "Error in `el-search--format-replacement' - please make a bug report"))))
(kill-buffer orig-buffer)))))
--- 647,655 ----
(el-search--ensure-sexp-start)
(end-of-buffer (goto-char (point-max))))))
(goto-char 1)
! (forward-sexp (if splice (length replacement) 1))
(let ((result (buffer-substring 1 (point))))
! (if (equal replacement (read (if splice (format "(%s)" result) result)))
result
(error "Error in `el-search--format-replacement' - please make a bug report"))))
(kill-buffer orig-buffer)))))
[-- Attachment #3: Type: text/plain, Size: 20 bytes --]
Thanks,
Michael.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: What is "splicing mode" in el-search.el?
2016-09-06 14:45 ` Michael Heerdegen
2016-09-06 14:58 ` Michael Heerdegen
@ 2016-09-06 17:55 ` Chunyang Xu
2016-09-06 23:07 ` Michael Heerdegen
1 sibling, 1 reply; 6+ messages in thread
From: Chunyang Xu @ 2016-09-06 17:55 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: help-gnu-emacs
Hi Michael!
On Tue, Sep 6, 2016 at 10:45 PM, Michael Heerdegen
<michael_heerdegen@web.de> wrote:
> Hello Chunyang!
>
>> I tried el-search.el from gnu elpa and have one problem with it.
>
> Great, this is the first remark I got about it :-) Your comments are
> much appreciated, please report every discrepancy you find. Multi-file
> support will come soon, btw.
>
>
>> The Commentary of el-search.el mentions "splicing mode", but I can't
>> figure out what it means, can you give me an example?
>>
>> ;; It is possible to replace a match with multiple expressions using
>> ;; "splicing mode". When it is active, the replacement expression
>> ;; must evaluate to a list, and is spliced instead of inserted into
>> ;; the buffer for any replaced match.
>
> It just means that instead of the list, it's elements are inserted into
> the buffer, in the same order as in the list. If you replace e.g. this
>
> `(f . ,args) -> args
>
> and you have in some buffer
>
> (f x y)
>
> then this would normally be replaced with
>
> (x y)
>
> but with splicing mode turned on, you would get
>
> x y
>
Now I see. After applying your patch, it works like expect.
Thank you very much!
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: What is "splicing mode" in el-search.el?
2016-09-06 14:09 What is "splicing mode" in el-search.el? Chunyang Xu
2016-09-06 14:45 ` Michael Heerdegen
@ 2016-09-06 14:48 ` tomas
1 sibling, 0 replies; 6+ messages in thread
From: tomas @ 2016-09-06 14:48 UTC (permalink / raw)
To: help-gnu-emacs
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Tue, Sep 06, 2016 at 10:09:15PM +0800, Chunyang Xu wrote:
> Hello!
>
> I tried el-search.el from gnu elpa and have one problem with it. The
> Commentary of el-search.el mentions "splicing mode", but I can't
> figure out what it means, can you give me an example?
>
> ;; It is possible to replace a match with multiple expressions using
> ;; "splicing mode". When it is active, the replacement expression
> ;; must evaluate to a list, and is spliced instead of inserted into
> ;; the buffer for any replaced match.
Since it is for Lisp, I guess it does something similar to `,@' in
macros: i.e. "unwrap" one level of the replacement value, which should
be a list, and insert it in place,
I.e. if the search expression is `foo' and the replacement is (bar baz quux),
you'd get
(one foo three) -> (one (bar baz quux) three) in non-splicing,
-> (one bar baz quux three) in splicing mode.
In macros, this is typically used to insert the whole "body" of
something (e.g. an if, a function def and so on), which isn't
an S-expression but a sequence of things.
But this all is just a guess.
regards
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
iEYEARECAAYFAlfO1y4ACgkQBcgs9XrR2kYE+QCfSkxUBNHV9jcBabqEBLPaIk3i
gPUAnRR05UJu11dcuPSMFmm53ptc3NAD
=5RML
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-09-06 23:07 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-06 14:09 What is "splicing mode" in el-search.el? Chunyang Xu
2016-09-06 14:45 ` Michael Heerdegen
2016-09-06 14:58 ` Michael Heerdegen
2016-09-06 17:55 ` Chunyang Xu
2016-09-06 23:07 ` Michael Heerdegen
2016-09-06 14:48 ` tomas
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.