From: Felix Dietrich <felix.dietrich@sperrhaken.name>
To: help-gnu-emacs@gnu.org
Subject: Re: terminal command with output in current buff
Date: Sat, 17 Jul 2021 13:33:13 +0200 [thread overview]
Message-ID: <87r1fxnpja.fsf@sperrhaken.name> (raw)
In-Reply-To: <ea-mime-60f2a0a4-137-794dc851@www-7.mailo.com> (lisa-asket@perso.be's message of "Sat, 17 Jul 2021 11:19:32 +0200 (CEST)")
lisa-asket@perso.be writes:
> I am getting a small problem when using `(cmd-cnum (read-number "context: "))`
>
> Wrong type argument: sequencep, 8
Please provide, if possible, small self-contained examples that
reproduce your problem and more context around your snippets: I had to
hunt for the context in your past messages. Here is a simplified
version of your code that causes the problem and serves as an example of
what I mean by “self-contained example”:
(let* ((cmd-cnum (read-number "Number: "))
(cmd-temp `("grep" ,cmd-cnum))
;; same as: (cmd-temp (list "grep" cmd-cnum))
(mapconcat #'shell-quote-argument cmd-temp " "))
> number-to-string seems to be what is required
Anyway you have found a solution to your problem. Let me just add a
short explanation in case the issue is not entirely clear to you yet:
‘shell-quote-argument’ works on strings; when you map over a list, you
apply the function on each element of the list and collect the results.
Therefore, in your call to ‘mapconcat’ the function
‘shell-quote-argument’ will eventually be passed the value of
‘cmd-cnum’, which you have inserted into the list. Examples that do not
work:
(shell-quote-argument 5)
⇒ Wrong type argument: sequencep, 5
(mapconcat #'shell-quote-argument '(5) " ")
⇒ Wrong type argument: sequencep, 5
(mapconcat #'shell-quote-argument '("grep" 5) " ")
⇒ Wrong type argument: sequencep, 5
(mapconcat #'shell-quote-argument '(5 "grep") " ")
⇒ Wrong type argument: sequencep, 5
> After selecting wy search pattern and storing it in `cmd-ptrn`, how
> can I highlight the pattern when tho grep results are being
> transferred to the current buffer ?
Now itʼs getting complicated and I couldnʼt give you an answer of the of
my head: look into adding text properties [1] to strings and at process
filters [2]. How could you identify the information elements grep puts
on each line and their position? It will probably also be insightful to
look at how the Emacs command “M-x grep” [3] is implemented.
Footnotes:
[1] <https://www.gnu.org/software/emacs/manual/html_node/elisp/Text-Props-and-Strings.html>
[2] <https://www.gnu.org/software/emacs/manual/html_node/elisp/Filter-Functions.html>
[3] <https://www.gnu.org/software/emacs/manual/html_node/emacs/Grep-Searching.html>
--
Felix Dietrich
next prev parent reply other threads:[~2021-07-17 11:33 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-16 6:43 Run terminal command with output in current buffer lisa-asket
2021-07-16 6:53 ` Jean-Christophe Helary
2021-07-16 7:07 ` Eli Zaretskii
2021-07-16 9:04 ` lisa-asket
2021-07-16 11:32 ` Eli Zaretskii
2021-07-16 11:48 ` lisa-asket
2021-07-16 11:30 ` lisa-asket
2021-07-16 11:58 ` lisa-asket
2021-07-16 15:14 ` Felix Dietrich
2021-07-16 15:21 ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-07-16 15:44 ` lisa-asket
2021-07-16 16:32 ` Felix Dietrich
2021-07-16 17:00 ` lisa-asket
2021-07-16 19:35 ` Felix Dietrich
2021-07-16 19:48 ` lisa-asket
2021-07-16 21:58 ` Felix Dietrich
2021-07-17 5:58 ` lisa-asket
2021-07-17 9:09 ` terminal command with output in current buff lisa-asket
2021-07-17 9:19 ` lisa-asket
2021-07-17 11:33 ` Felix Dietrich [this message]
2021-07-19 1:10 ` terminal command with output in current buffer Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-19 4:54 ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-07-19 23:12 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-20 12:05 ` ‘read-string’ over ‘read-from-minibuffer’ Felix Dietrich
2021-07-20 15:11 ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-07-20 15:46 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-20 12:55 ` terminal command with output in current buffer Felix Dietrich
2021-07-20 18:15 ` Yuri Khan
2021-07-20 18:23 ` lisa-asket
2021-07-16 16:36 ` Run " Stefan Monnier via Users list for the GNU Emacs text editor
2021-07-16 17:24 ` lisa-asket
2021-07-16 18:01 ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-07-16 18:07 ` lisa-asket
2021-07-16 18:04 ` lisa-asket
2021-07-19 0:42 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-19 4:49 ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-07-19 20:51 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-16 15:22 ` lisa-asket
2021-07-16 13:25 ` Felix Dietrich
2021-07-16 13:48 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-16 14:28 ` lisa-asket
2021-07-16 15:06 ` lisa-asket
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r1fxnpja.fsf@sperrhaken.name \
--to=felix.dietrich@sperrhaken.name \
--cc=help-gnu-emacs@gnu.org \
/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.
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).