From unknown Fri Jun 20 05:34:54 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#3634 <3634@debbugs.gnu.org> To: bug#3634 <3634@debbugs.gnu.org> Subject: Status: emacsclient: unwind-protect prevents printing final form Reply-To: bug#3634 <3634@debbugs.gnu.org> Date: Fri, 20 Jun 2025 12:34:54 +0000 retitle 3634 emacsclient: unwind-protect prevents printing final form reassign 3634 emacs submitter 3634 Jonas Bernoulli severity 3634 normal tag 3634 notabug moreinfo thanks From jonasbernoulli@gmail.com Sat Jun 20 18:43:43 2009 Received: (at submit) by emacsbugs.donarmstrong.com; 21 Jun 2009 01:43:44 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=0.0 required=4.0 tests=none autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n5L1hdnH020126 for ; Sat, 20 Jun 2009 18:43:40 -0700 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MIC5r-0003j6-1L for bug-gnu-emacs@gnu.org; Sat, 20 Jun 2009 21:43:39 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MIC5l-0003gV-Ak for bug-gnu-emacs@gnu.org; Sat, 20 Jun 2009 21:43:37 -0400 Received: from [199.232.76.173] (port=56619 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MIC5l-0003gS-64 for bug-gnu-emacs@gnu.org; Sat, 20 Jun 2009 21:43:33 -0400 Received: from mail-yx0-f201.google.com ([209.85.210.201]:42148) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MIC5k-00087d-Rl for bug-gnu-emacs@gnu.org; Sat, 20 Jun 2009 21:43:32 -0400 Received: by yxe39 with SMTP id 39so1832588yxe.14 for ; Sat, 20 Jun 2009 18:43:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:from:date :x-google-sender-auth:message-id:subject:to:content-type :content-transfer-encoding; bh=8JPMh5OiGwTyBA3DjW+raHgt83iPAuZNRCA6qS/6IXo=; b=OnQcxPTlRVmIXvfKzDqeroLx0eoseUvSx6nlwPDkQjZfEm84I3S2vqcxi3+2TJIvlk IxZr+Sf31SHGYt+EvrFeE+ebrzIGB6UIBE8XqQeJi2ToEBpDrItCfgb9XzsnNyd/yujo EfDMqUpVXGQ5UhccC3MdwiUDBYpoy38Sl41UQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:from:date:x-google-sender-auth:message-id :subject:to:content-type:content-transfer-encoding; b=dZ7dAzghNMjt1KD4B4ZgiSRtYlHG1dkqBor1tXMRV2K6+6buZdbiQPc6yQih43QlsW 9DMhj9K8maV9mcpWId3MzoYimsPIfcJycDyjT5v3MFg1mj0r/qjwgrr3FOY9l9UX9jIt crm/6v8WRWfa6OSoUzYnEjh0IoR9lLWeYsGhQ= MIME-Version: 1.0 Sender: jonasbernoulli@gmail.com Received: by 10.151.72.7 with SMTP id z7mr8548136ybk.52.1245548612055; Sat, 20 Jun 2009 18:43:32 -0700 (PDT) From: Jonas Bernoulli Date: Sun, 21 Jun 2009 03:43:12 +0200 X-Google-Sender-Auth: 0d8ca1f9dbcd5b76 Message-ID: <201bac3a0906201843n35687deck5ac9d82bd4a068d1@mail.gmail.com> Subject: emacsclient: unwind-protect prevents printing final form To: bug-gnu-emacs@gnu.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Hi I am trying to write a wrapper around emacsclient that would allow emacs to be used by external applications to complete some string. However it does not seem to be possible to 1. return the last form and 2. ensure that emacsclient always returns at the same time. (The following examples assumes default-minibuffer-frame exists. Just remove the respective line if it doesn't.) This works as long as the user does not abort: #!/bin/bash STRING=$(emacsclient -e "\ (select-frame-set-input-focus default-minibuffer-frame) (read-string \"> \")" echo ${STRING:1:$((${#STRING}-2)) But when he does, emacsclient never returns. So I tried using unwind-protect to make sure that emacsclient always returns: #!/bin/bash STRING=$(emacsclient -e "\ (let ((emonad-client (car server-clients))) (select-frame-set-input-focus default-minibuffer-frame) (unwind-protect (read-string \"> \") (when (memq emonad-client server-clients) (server-delete-client emonad-client t))))") echo ${STRING:1:$((${#STRING}-2)) Now my script always returns but fails to print the final form to standard output even when input was NOT aborted. I tried several things to work around this: 1. Store the return value of read-string in some variable, and using the variable as last form of let. When I use (message "veni vedi %s" tmp) as last form I can see that forms after unwind-protect are actually evaluated, the last form's value is just never printed to stout. 2. condition-case 3. catch However in all cases nothing was printed to standard output. It seems that as soon as some non-local exit is used emacsclient refuses to print anything to stout. And since exit-minibuffer does (throw 'exit nil) to abort minibuffer output there is now way to prevent such an non-local exit. As a workaround it might be possible to explicitly print to stout, but I could not find any information on how to do that. thx Jonas From jonasbernoulli@gmail.com Sat Nov 7 04:29:13 2009 Received: (at submit) by emacsbugs.donarmstrong.com; 7 Nov 2009 12:29:13 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-1.5 required=4.0 tests=AWL,HAS_BUG_NUMBER autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nA7CTB2S000406 for ; Sat, 7 Nov 2009 04:29:13 -0800 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N6kPn-0002vs-AJ for bug-gnu-emacs@gnu.org; Sat, 07 Nov 2009 07:29:11 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N6kPi-0002uI-UM for bug-gnu-emacs@gnu.org; Sat, 07 Nov 2009 07:29:10 -0500 Received: from [199.232.76.173] (port=43087 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N6kPi-0002u4-Iu for bug-gnu-emacs@gnu.org; Sat, 07 Nov 2009 07:29:06 -0500 Received: from mail-yw0-f194.google.com ([209.85.211.194]:49335) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N6kPi-0007PC-8j for bug-gnu-emacs@gnu.org; Sat, 07 Nov 2009 07:29:06 -0500 Received: by ywh32 with SMTP id 32so1750861ywh.14 for ; Sat, 07 Nov 2009 04:29:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:from:date:x-google-sender-auth:message-id:subject:to :content-type:content-transfer-encoding; bh=/nN4RgZBnnqf3AGz8kTKQGKgMxQXg6ppvQ+8Dam6I3I=; b=YVX1VBA8HWEkApqE6yqpQhwSA+zds0HqvqynIoTPg+8x0ApnxdxDIcaLJruKGF9w9A GN+mL1Y6VPMRc4uVrIavHWQhXDsYJePYzNqjOstq3g+MoGitYn/iQVUV7HejwlqRWDnz AkSNCobLUZU5yhuSur7tgTAul9aRt4/NhLN4A= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type :content-transfer-encoding; b=GIQ55SlMYy/slt6lsb5Ne72ppKypB81O4SRsYTVhgZZ2m7wuUdePWArwIBJdgi9l5i rX1MulYr37MyfvZSxdgVq2jz/CWwVtiK06cmdtKo5LiPQSAUHIBGHlaWipMLwZz5C0mI HVDpv/DmtlkkiTvbaiQiEJQNktZkHUBRlydXY= MIME-Version: 1.0 Sender: jonasbernoulli@gmail.com Received: by 10.150.240.4 with SMTP id n4mr9792071ybh.1.1257596944067; Sat, 07 Nov 2009 04:29:04 -0800 (PST) In-Reply-To: <201bac3a0906201843n35687deck5ac9d82bd4a068d1@mail.gmail.com> References: <201bac3a0906201843n35687deck5ac9d82bd4a068d1@mail.gmail.com> From: Jonas Bernoulli Date: Sat, 7 Nov 2009 13:28:44 +0100 X-Google-Sender-Auth: 22f1c4cb7d624757 Message-ID: <201bac3a0911070428u2542fc94gad3cd5d4d5f5779d@mail.gmail.com> Subject: Re: bug#3634: emacsclient: unwind-protect prevents printing final form To: bug-gnu-emacs@gnu.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) ping On Sun, Jun 21, 2009 at 02:43, Jonas Bernoulli wrote: > Hi > > I am trying to write a wrapper around emacsclient that would allow > emacs to be used by external applications to complete some string. > > However it does not seem to be possible to > 1. return the last form and > 2. ensure that emacsclient always returns > at the same time. > > (The following examples assumes default-minibuffer-frame exists. Just > remove the respective line if it doesn't.) > > This works as long as the user does not abort: > > #!/bin/bash > STRING=3D$(emacsclient -e "\ > (select-frame-set-input-focus default-minibuffer-frame) > (read-string \"> \")" > echo ${STRING:1:$((${#STRING}-2)) > > But when he does, emacsclient never returns. So I tried using > unwind-protect to make sure that emacsclient always returns: > > #!/bin/bash > STRING=3D$(emacsclient -e "\ > (let ((emonad-client (car server-clients))) > =C2=A0(select-frame-set-input-focus default-minibuffer-frame) > =C2=A0(unwind-protect (read-string \"> \") > =C2=A0 =C2=A0(when (memq emonad-client server-clients) > =C2=A0 =C2=A0 =C2=A0(server-delete-client emonad-client t))))") > echo ${STRING:1:$((${#STRING}-2)) > > Now my script always returns but fails to print the final form to > standard output even when input was NOT aborted. > > I tried several things to work around this: > > 1. Store the return value of read-string in some variable, and using > the variable as last form of let. When I use (message "veni vedi %s" > tmp) as last form I can see that forms after unwind-protect are > actually evaluated, the last form's value is just never printed to > stout. > 2. condition-case > 3. catch > > However in all cases nothing was printed to standard output. It seems > that as soon as some non-local exit is used emacsclient refuses to > print anything to stout. And since exit-minibuffer does (throw 'exit > nil) to abort minibuffer output there is now way to prevent such an > non-local exit. > > As a workaround it might be possible to explicitly print to stout, but > I could not find any information on how to do that. > > thx > > Jonas > > > > > From monnier@IRO.UMontreal.CA Sat Nov 7 19:50:21 2009 Received: (at 3634) by emacsbugs.donarmstrong.com; 8 Nov 2009 03:50:22 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-4.0 required=4.0 tests=AWL,HAS_BUG_NUMBER autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from chene.dit.umontreal.ca (chene.dit.umontreal.ca [132.204.246.20]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nA83oJvm011465 for <3634@emacsbugs.donarmstrong.com>; Sat, 7 Nov 2009 19:50:21 -0800 Received: from ceviche.home (faina.iro.umontreal.ca [132.204.26.177]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id nA83oFfk020680; Sat, 7 Nov 2009 22:50:16 -0500 Received: by ceviche.home (Postfix, from userid 20848) id CDD8BB40E4; Sat, 7 Nov 2009 22:50:15 -0500 (EST) From: Stefan Monnier To: Jonas Bernoulli Cc: 3634@debbugs.gnu.org Subject: Re: bug#3634: emacsclient: unwind-protect prevents printing final form Message-ID: References: <201bac3a0906201843n35687deck5ac9d82bd4a068d1@mail.gmail.com> <201bac3a0911070428u2542fc94gad3cd5d4d5f5779d@mail.gmail.com> Date: Sat, 07 Nov 2009 22:50:15 -0500 In-Reply-To: <201bac3a0911070428u2542fc94gad3cd5d4d5f5779d@mail.gmail.com> (Jonas Bernoulli's message of "Sat, 7 Nov 2009 13:28:44 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV3401=0 >> But when he does, emacsclient never returns. So I tried using >> unwind-protect to make sure that emacsclient always returns: I'd expect that using condition-case to catch `quit' would work. Have you tried it? Stefan From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 26 17:59:30 2010 Received: (at control) by debbugs.gnu.org; 26 Jan 2010 22:59:30 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NZuNe-0006Wg-50 for submit@debbugs.gnu.org; Tue, 26 Jan 2010 17:59:30 -0500 Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NZuNc-0006Wa-Ri for control@debbugs.gnu.org; Tue, 26 Jan 2010 17:59:29 -0500 Received: from rgm by fencepost.gnu.org with local (Exim 4.69) (envelope-from ) id 1NZuNZ-0005iV-10; Tue, 26 Jan 2010 17:59:25 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <19295.29644.873399.225898@fencepost.gnu.org> Date: Tue, 26 Jan 2010 17:59:24 -0500 From: Glenn Morris To: control Subject: control X-Attribution: GM X-Mailer: VM (www.wonderworks.com/vm), GNU Emacs (www.gnu.org/software/emacs) X-Hue: green X-Ran: &(VbNfmJXZ;[J{*G3aTbd+b!ecJ2-$GFxDMQQe0OAuT_7w/9GVc(bITh-`eB%[Y;QuxJkO X-Debbugs-No-Ack: yes X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.0 (-----) merge 3598 3599 severity 3625 wishlist tags 3634 moreinfo severity 3639 minor unmerge 3728 From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 12 19:07:20 2011 Received: (at 3634-done) by debbugs.gnu.org; 12 Jul 2011 23:07:20 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qgm2x-00010P-O4 for submit@debbugs.gnu.org; Tue, 12 Jul 2011 19:07:20 -0400 Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qgm2w-00010E-1u for 3634-done@debbugs.gnu.org; Tue, 12 Jul 2011 19:07:18 -0400 Received: from localhost ([127.0.0.1]:35525) by fencepost.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qgm2m-0005n0-W5; Tue, 12 Jul 2011 19:07:09 -0400 From: Glenn Morris To: 3634-done@debbugs.gnu.org Subject: Re: bug#3634: emacsclient: unwind-protect prevents printing final form References: <201bac3a0906201843n35687deck5ac9d82bd4a068d1@mail.gmail.com> <201bac3a0911070428u2542fc94gad3cd5d4d5f5779d@mail.gmail.com> X-Spook: kilo class secure encryption embassy government infowar X-Ran: W'rOm\j#.RApkA|sd[2!?B^N>;g2e,-9zJ!-(JrSxpy6UCATQIJp%94+[n}6F65%h8$dD" X-Hue: green X-Attribution: GM Date: Tue, 12 Jul 2011 19:07:08 -0400 In-Reply-To: (Stefan Monnier's message of "Sat, 07 Nov 2009 22:50:15 -0500") Message-ID: User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -6.4 (------) X-Debbugs-Envelope-To: 3634-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.4 (------) Stefan Monnier wrote: > I'd expect that using condition-case to catch `quit' would work. > Have you tried it? Works for me. STRING=$(emacsclient -e "(condition-case nil (read-string \"> \") (quit nil))") From unknown Fri Jun 20 05:34:54 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 10 Aug 2011 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator