From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Felix Dietrich Newsgroups: gmane.emacs.help Subject: Re: Run terminal command with output in current buffer Date: Fri, 16 Jul 2021 15:25:49 +0200 Message-ID: <87y2a6pezm.fsf@sperrhaken.name> References: <83h7gu68k6.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20168"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 16 15:37:05 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 1m4O1Z-00053O-F9 for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 16 Jul 2021 15:37:05 +0200 Original-Received: from localhost ([::1]:33224 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m4O1Y-00054J-Gq for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 16 Jul 2021 09:37:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37922) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4O0f-00041f-Sp for help-gnu-emacs@gnu.org; Fri, 16 Jul 2021 09:36:10 -0400 Original-Received: from mout.kundenserver.de ([212.227.126.134]:52709) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4Nqn-0004f5-KI for help-gnu-emacs@gnu.org; Fri, 16 Jul 2021 09:25:59 -0400 Original-Received: from localhost ([77.11.230.244]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MUGuZ-1leMls0GH5-00RGyZ for ; Fri, 16 Jul 2021 15:25:55 +0200 In-Reply-To: (lisa-asket@perso.be's message of "Fri, 16 Jul 2021 13:30:01 +0200 (CEST)") X-Provags-ID: V03:K1:7L8tAIrPt6B3fyhf+sCxtkXMAvvTLqYm1aEr7912LYNTpP3NNWU 1k45138PQbddkY8DpljM31XM2+ifXKbsNQVw7wYAt1kW9MDJ6RmjBJXS3/Qoo8Fqf4FGLOX kaz/Qay1MAcMv4aFXsYOHJn+wj9kUSIxvdFAUCqruMoYQ200uhfEGNA7ICPH5eFqNlKcyMx Ef/TYcElIfbemWwrPZKHA== X-UI-Out-Filterresults: notjunk:1;V03:K0:fv1MwdMelXs=:UanAgXe64GyPYIQboWFLPr YMkbP3VKSCxCPoI3ZvLM+7Cqb4kX/SkPUuuZFsYntos7gYPS0rVy5gNrLWIP80WBuYJJXS9r0 S0p6U0+noB5THHAgAlQYjSoRWjLvyRoF8MFPpVpaeH/b4wZSyUMplCmtSIb1cTg5IDrDI09FB AmfBqLlMsyGAtMu5Yv0Z/UJjhSwE4ODUPGbYP1fPRxbL7b6TKZN9CRlimHJl/UKCdOr2lb4j1 olioujzF6rg9r/QVrpSWqBve8hsK1VksxcrkLYoW6UAghhuEVIbAvXsseo+H+GKWnsTVT0FGY YKv67tip7+mYH1QeeuaLVZhnOSi/PUsaJesDl1vzMfgOdOazZt2MwTR8A3Bw8XGr8X8CBz6Jx Mr+5bAtpV+lxjeKZKyyK9C2Sd/IxvAuZSwV54Qed1wPnqSd0OaVdiVP37fc62y8UiQB7bztyL ozdpfDHXMBCsaQgydm6fqLUciFbhXvSVvxOuw9YjE/RWNRx6nGdQUFpOG35OtSabd8gdM36lL cD6DyxUHqmk6PoFArdTpeVxzfbE0PG2nv2RitbC73wkZaOHm89KkrnKCr0+SU4gfjE3bbvAn8 aaD7gthfqKYkzlnNUtvQCr0BIPAAmBLHqyW8rVLvZ1XkT2dfeDvqzsVNc7XiZkaa+3mQ7avHi b/26KRBBZu00S3vliysLqPZJXfLyb7RkXayeCPMzLzSiJC1cl7JhHqch/Y9C142RwEeuL4jKt kBGS+UB8AotIgLp0HQS1vyKgUbzeSxTqv3m05RjCY+8TaiuW207g0j3SBxf/6b36t0fyF0cX Received-SPF: none client-ip=212.227.126.134; envelope-from=felix.dietrich@sperrhaken.name; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=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:131745 Archived-At: lisa-asket@perso.be writes: > ;; grep -hir --exclude=3D\*.el --include=3D\*.{org,texi} -C 8 "node-gnu-f= dl" . >=20 > (cmd-excl (read-from-minibuffer "exclude: ")) > (setq cmd-excl (concat " -C --exclude=3D\*." cmd-excl)) > > (cmd-incl (read-from-minibuffer "include: ")) > (setq cmd-incl (concat " -C --include=3D\*." cmd-incl)) The backslash is special in Emacs strings, and you need to escape it with an extra backslash if you want it to be part of the string. Compare the strings inserted by these two commands: (insert "\*") ; This will insert just =E2=80=98*=E2=80=99. (insert "\\*") ; This will insert =E2=80=98\*=E2=80=99. In front of certain characters, the backlash translates these characters into other characters [1][2]. Characters preceded by a backslash that are not known =E2=80=9Cescape sequences=E2=80=9D stand for themselves; this= is the case for =E2=80=98*=E2=80=99, and that is why you need to double the backslash. Similarly, you may need to escape characters for the shell in the string read from the minibuffer: have a look at the function =E2=80=9Cshell-quote-argument=E2=80=9D. Is the first string to =E2=80=9Cconcat=E2=80=9D missing a space at it=CA=BC= s end? If this isn=CA=BCt an exercise for fun or otherwise: you can call grep from within Emacs using the command =E2=80=9CM-x grep=E2=80=9D. Footnotes: [1] (elisp) Basic Char Syntax [2] (elisp) Syntax for Strings --=20 Felix Dietrich