From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.orgmode,gmane.emacs.devel Subject: Re: [PATCH] Make RET and C-j obey `electric-indent-mode' in org-mode Date: Thu, 07 May 2020 09:53:20 -0400 Message-ID: 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> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="80183"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Org Mode list , Emacs developers To: =?windows-1252?Q?K=E9vin?= Le Gouguec Original-X-From: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane-mx.org@gnu.org Thu May 07 15:54:15 2020 Return-path: Envelope-to: geo-emacs-orgmode@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 1jWgyd-000Kl6-Tr for geo-emacs-orgmode@m.gmane-mx.org; Thu, 07 May 2020 15:54:15 +0200 Original-Received: from localhost ([::1]:48358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jWgyc-00021N-TT for geo-emacs-orgmode@m.gmane-mx.org; Thu, 07 May 2020 09:54:14 -0400 Original-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 ) id 1jWgxq-0001yI-Fp; Thu, 07 May 2020 09:53:26 -0400 Original-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 ) id 1jWgxp-0003yE-7j; Thu, 07 May 2020 09:53:25 -0400 Original-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) Original-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== Original-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) 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") 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." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-orgmode" Xref: news.gmane.io gmane.emacs.orgmode:128906 gmane.emacs.devel:249175 Archived-At: > +(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