From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>
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 qEZIFAQTtF6rCAAA0tVLHw
	(envelope-from <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Thu, 07 May 2020 13:54:12 +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 4JJTIBATtF6idQAA1q6Kng
	(envelope-from <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Thu, 07 May 2020 13:54:24 +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 520AB940B0F
	for <larch@yhetil.org>; Thu,  7 May 2020 13:54:22 +0000 (UTC)
Received: from localhost ([::1]:48358 helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>)
	id 1jWgyk-00021N-P4
	for larch@yhetil.org; Thu, 07 May 2020 09:54:22 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:35838)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <monnier@iro.umontreal.ca>)
 id 1jWgxq-0001yI-Fp; Thu, 07 May 2020 09:53:26 -0400
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:16715)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <monnier@iro.umontreal.ca>)
 id 1jWgxp-0003yE-7j; Thu, 07 May 2020 09:53:25 -0400
Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id A6C5F450A34;
 Thu,  7 May 2020 09:53:23 -0400 (EDT)
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 37480450403;
 Thu,  7 May 2020 09:53:22 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1588859602;
 bh=VwNAWxykO/zea+72K3ubIsGVUAH5WnWCXcT4N+FFZZ0=;
 h=From:To:Cc:Subject:References:Date:In-Reply-To:From;
 b=kWzVpKJcaahzDo7v2xqbO9W8ycl+kX0WQmZqaojB2DS+nevLuOE8uxCYncE3YW1v9
 U2+zipPbQMtzOpCBIWBlab6M+BvA68cUmQHXBUHfEBA4C31Yt1DNaI/OKHyDlQC3+V
 YYqJr2grYW+XLGYrQQpz0dZbarhnLBKqjGVqumFa2mrHKZPwdQEoxvtrfgO92cBHIy
 xWOdUWpVS+QHWv2CTPGYWA3RBYl3HMMi0RWo1EXCmMhlbELrKqGM/mdRnTCaSAJXll
 Cdj37cn+lxVMWGCpuE+mM6oIlPiuITlmzVwfDjZy5qjww8TJuo/gTyA00NSy7cDhGJ
 FR7yTTDFZvSVg==
Received: from alfajor (unknown [216.154.3.202])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id D0467120749;
 Thu,  7 May 2020 09:53:21 -0400 (EDT)
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: =?windows-1252?Q?K=E9vin?= Le Gouguec <kevin.legouguec@gmail.com>
Subject: Re: [PATCH] Make RET and C-j obey `electric-indent-mode' in org-mode
Message-ID: <jwvd07f4zut.fsf-monnier+emacs@gnu.org>
References: <CADwFkm=qkNCWA40ieZ9Dv-gbk6xAzjG16sOa64GT+Zbv9pCC_A@mail.gmail.com>
 <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 09:53:20 -0400
In-Reply-To: <877dxpazbo.fsf_-_@gmail.com> (=?windows-1252?Q?=22K=E9vin?= Le
 Gouguec"'s message of "Wed, 06 May 2020 16:54:35 +0200")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL -0.071 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
Received-SPF: pass client-ip=132.204.25.50;
 envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca
X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/07 08:11:37
X-ACL-Warn: Detected OS   = Linux 2.2.x-3.x [generic]
X-Spam_score_int: -42
X-Spam_score: -4.3
X-Spam_bar: ----
X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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." <emacs-orgmode.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/emacs-orgmode>,
 <mailto:emacs-orgmode-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/emacs-orgmode>
List-Post: <mailto:emacs-orgmode@gnu.org>
List-Help: <mailto:emacs-orgmode-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/emacs-orgmode>,
 <mailto:emacs-orgmode-request@gnu.org?subject=subscribe>
Cc: Org Mode list <emacs-orgmode@gnu.org>,
 Emacs developers <emacs-devel@gnu.org>
Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org
Sender: "Emacs-orgmode" <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>
X-Scanner: scn0
X-Spam-Score: -1.71
Authentication-Results: aspmx1.migadu.com;
	dkim=pass header.d=iro.umontreal.ca header.s=mail header.b=kWzVpKJc;
	dmarc=pass (policy=none) header.from=iro.umontreal.ca;
	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.49818319599307];
	 DWL_DNSWL_FAIL(0.00)[umontreal.ca:server fail,2001:470:142::17:server fail];
	 R_SPF_ALLOW(-0.20)[+ip6:2001:470:142::/48:c];
	 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)[iro.umontreal.ca:+];
	 MX_GOOD(-0.50)[cached: eggs.gnu.org];
	 DMARC_POLICY_ALLOW(-0.50)[iro.umontreal.ca,none];
	 MAILLIST(-0.20)[mailman];
	 FREEMAIL_TO(0.00)[gmail.com];
	 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];
	 TAGGED_FROM(0.00)[larch=yhetil.org];
	 FROM_NEQ_ENVFROM(0.00)[monnier@iro.umontreal.ca,emacs-orgmode-bounces@gnu.org];
	 ARC_NA(0.00)[];
	 R_DKIM_ALLOW(-0.20)[iro.umontreal.ca:s=mail];
	 URIBL_BLOCKED(0.00)[iro.umontreal.ca:dkim];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[3];
	 FORGED_RECIPIENTS_MAILLIST(0.00)[];
	 TAGGED_RCPT(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_LIST_UNSUB(-0.01)[];
	 RCVD_COUNT_SEVEN(0.00)[7];
	 FORGED_SENDER_MAILLIST(0.00)[]
X-TUID: 6jLKJhoqjYdL

> +(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`.  ]


        Stefan