From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id M1NXOYMqtF6XEAAA0tVLHw (envelope-from ) for ; Thu, 07 May 2020 15:34:27 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id 0EFbC5AqtF5uMwAA1q6Kng (envelope-from ) for ; Thu, 07 May 2020 15:34:40 +0000 Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:470:142::17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 18CB3940DD4 for ; Thu, 7 May 2020 15:34:38 +0000 (UTC) Received: from localhost ([::1]:57330 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jWiXm-0005oA-M7 for larch@yhetil.org; Thu, 07 May 2020 11:34:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57508) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jWiWa-0004mb-Bu; Thu, 07 May 2020 11:33:24 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:34335) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jWiWZ-00025y-1W; Thu, 07 May 2020 11:33:24 -0400 Received: by mail-wm1-x344.google.com with SMTP id v4so7742258wme.1; Thu, 07 May 2020 08:33:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=8QJGzCscd3lLItN82Bgc81x7K7UV0FB/HCU6Tm0RbSI=; b=ddRXBXQCHxpedKD2YW/MtzvxpauyTKcOtjuzE/d6qmay4KnC63QXsOizDfQqjoCmzg 13AqVhdI3k8Vq2c1GG2S3T/St9M39SPZdWRVskx2S3b+teeGSRgkVTnPSAiPqs8IEdRO jfWyg8+cuR+fwware/Z84exlRTE914TQP5BCu5e3ALb8PZUurSORnwP6eeMMqjpjyGj3 Yzj86fdRrafL/4/vLeD5TcaB/tc4hKnsp6BF70dvIGOJTahR8CN6rN584oR+5veoDwxw 9wfcJlxxXe1/bv26LOYnygv49E4rVbyKNbVUZsScBMZugtH/eiBsSXZYc/MiLHGkGFqV 8RiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=8QJGzCscd3lLItN82Bgc81x7K7UV0FB/HCU6Tm0RbSI=; b=C2M+eVfliCFd3qwfKNp+lLG7DNHkQoWnISLTwOdUqJ9Xc9Y8CdlEJo5nHnkvYjaFNb LADJn84jw3Y+xhOU4zq6AVqSUin7vFvwAzLYiLHkldDeCvj+dIv7/vaUMjM+Y3PKTKtx fUIIMDwMkZJD0zKFHkT8WgBCVzkZ+Yyc+wRfoKNz9AFb9sMpO38ui+TOaTPCrETW+nn/ C8bghkC0QpD8qGPa0o7nqx9ragARr1zVF+69HoDxkZ/lGe0BXei5ZrYXC0jJKcTO5m11 Tx9uIzRM3PByxhkUAaR/cJ4CtFMDzZwPOo/x8BWlr16hZJLnki98kC8PuGvlqQnphAT9 ikGQ== X-Gm-Message-State: AGi0PuauFnAXhOfdpCuQ77vlQ8Y1MVhGk6iFl7C0McIuw88TZk7DktR+ E1TfccnnX962r0WxDP71HTurQUQuNyOYYA== X-Google-Smtp-Source: APiQypI4ZEzUfBKwPovoCGwa6HlbcF6H9UKRaNeHfPZ01mGuYFLk7euMMchIEns1VBn6djTE6wmfxQ== X-Received: by 2002:a1c:4e15:: with SMTP id g21mr10538131wmh.29.1588865600538; Thu, 07 May 2020 08:33:20 -0700 (PDT) Received: from my-little-tumbleweed (200.143.13.109.rev.sfr.net. [109.13.143.200]) by smtp.gmail.com with ESMTPSA id a12sm8617666wro.68.2020.05.07.08.33.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2020 08:33:19 -0700 (PDT) From: =?utf-8?Q?K=C3=A9vin_Le_Gouguec?= To: Stefan Monnier Subject: Re: [PATCH] Make RET and C-j obey `electric-indent-mode' in org-mode References: <20200426172206.GC18629@ACM> <87y2qhnc9a.fsf@gmail.com> <20200427102311.GA4976@ACM> <87mu6xtano.fsf@gmail.com> <87k120ohsq.fsf@mail.linkov.net> <87blnbir01.fsf@nicolasgoaziou.fr> <87o8rbmbfa.fsf@mail.linkov.net> <87k11yftqo.fsf@nicolasgoaziou.fr> <87pnbqo74t.fsf_-_@gmail.com> <87ees6fp8r.fsf@nicolasgoaziou.fr> <87y2q89dx7.fsf@gmail.com> <874ksv4uv1.fsf@nicolasgoaziou.fr> <87ftcfekxt.fsf@gmail.com> <877dxpazbo.fsf_-_@gmail.com> Date: Thu, 07 May 2020 17:33:18 +0200 In-Reply-To: (Stefan Monnier's message of "Thu, 07 May 2020 09:53:20 -0400") Message-ID: <87blmzrc8x.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2a00:1450:4864:20::344; envelope-from=kevin.legouguec@gmail.com; helo=mail-wm1-x344.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Org Mode list , Emacs developers Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 X-Spam-Score: -1.71 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=ddRXBXQC; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 2001:470:142::17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Scan-Result: default: False [-1.71 / 13.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; GENERIC_REPUTATION(0.00)[-0.4983125449366]; DWL_DNSWL_FAIL(0.00)[gmail.com:server fail,2001:470:142::17:server fail]; R_SPF_ALLOW(-0.20)[+ip6:2001:470:142::/48:c]; FREEMAIL_FROM(0.00)[gmail.com]; IP_REPUTATION_HAM(0.00)[asn: 22989(0.11), country: US(-0.00), ip: 2001:470:142::17(-0.50)]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; MX_GOOD(-0.50)[cached: eggs.gnu.org]; MAILLIST(-0.20)[mailman]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_IN_DNSWL_FAIL(0.00)[2001:470:142::17:server fail]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:22989, ipnet:2001:470:142::/48, country:US]; MID_RHS_MATCH_FROM(0.00)[]; TAGGED_FROM(0.00)[larch=yhetil.org]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; RCVD_COUNT_FIVE(0.00)[6]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; URIBL_BLOCKED(0.00)[umontreal.ca:email]; FROM_NEQ_ENVFROM(0.00)[kevinlegouguec@gmail.com,emacs-orgmode-bounces@gnu.org]; MIME_GOOD(-0.10)[text/plain]; HAS_LIST_UNSUB(-0.01)[]; RECEIVED_SPAMHAUS_PBL(0.00)[109.13.143.200:received]; FORGED_SENDER_MAILLIST(0.00)[] X-TUID: AJVFE9afGivB Stefan Monnier writes: >> +(defmacro org-test-with-minor-mode (mode state &rest body) >> + "Run BODY after setting MODE to STATE. >> +Restore MODE to its former state afterward." >> + (declare (debug (sexp sexp body)) (indent 2)) >> + `(let ((old-state ,mode)) >> + (,mode (if ,state 1 0)) >> + ,@body >> + (,mode (if old-state 1 0)))) > > This should probably use `unwind-protect` in case `body` exits > non-locally. > [ And also, for buffer-local minor modes, we should try and be careful > to restore the mode in the same buffer, tho this can be pushed as > a responsability of `body`. ] Thanks for confirming my nagging feeling that this macro was a bit too naive :) Nicolas actually ditched it and turned on/off electric-indent-local-mode in the temporary buffer where the Org commands are run; that should take care of these issues IIUC.