From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: =?utf-8?Q?K=C3=A9vin_Le_Gouguec?= Newsgroups: gmane.emacs.devel,gmane.emacs.orgmode Subject: Re: [PATCH] Make RET and C-j obey `electric-indent-mode' in org-mode Date: Thu, 07 May 2020 17:33:18 +0200 Message-ID: <87blmzrc8x.fsf@gmail.com> 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="31906"; 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: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu May 07 17:33:55 2020 Return-path: Envelope-to: ged-emacs-devel@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 1jWiX5-0008Cc-8y for ged-emacs-devel@m.gmane-mx.org; Thu, 07 May 2020 17:33:55 +0200 Original-Received: from localhost ([::1]:56192 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jWiX4-0005KE-Bu for ged-emacs-devel@m.gmane-mx.org; Thu, 07 May 2020 11:33:54 -0400 Original-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 Original-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 Original-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) Original-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) In-Reply-To: (Stefan Monnier's message of "Thu, 07 May 2020 09:53:20 -0400") 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-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:249187 gmane.emacs.orgmode:128907 Archived-At: 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.