From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [BUG, PATCH] org-indent-mode not correctly deactivated Date: Wed, 15 Jan 2014 22:26:14 +0100 Message-ID: <87txd5vsw9.fsf@gmail.com> References: <87fvoqh7tf.fsf@bzg.ath.cx> <877ga1s8s1.fsf@gmail.com> <87txd5ryox.fsf@bzg.ath.cx> <87txd5qjoc.fsf@gmail.com> <87a9exrxte.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34312) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W3XyN-0006Tp-5X for emacs-orgmode@gnu.org; Wed, 15 Jan 2014 16:26:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W3XyG-00036v-UC for emacs-orgmode@gnu.org; Wed, 15 Jan 2014 16:26:03 -0500 In-Reply-To: <87a9exrxte.fsf@bzg.ath.cx> (Bastien's message of "Wed, 15 Jan 2014 17:53:33 +0100") 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.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Bastien Cc: emacs-orgmode@gnu.org Bastien writes: > Nicolas Goaziou writes: > >> Bastien writes: >> >>> Nicolas Goaziou writes: >>> >>>> (cond (org-startup-indented (require 'org-indent) (org-indent-mode 1)) >>>> ((org-bound-and-true-p org-indent-mode) (org-indent-mode -1))) >>> >>> This will not work, because (org-bound-and-true-p org-indent-mode) >>> returns nil at the time `org-mode' is called. >> >> If it returns nil, it means that `org-startup-indented' is nil and >> either `org-indent' isn't loaded or `org-indent-mode' is off. >> >> I don't get why it wouldn't work. > > Try to edebug-defun `org-mode' with the recipe I posted and you'll > see: yes, `org-startup-indented' and `org-indent-mode' are off, > but the org-indent properties have not been removed from the before, > as they are by manually turning off with M-x org-indent-mode RET I see, thank you. But I still don't understand where, and when, `org-indent-mode' is reset. Anyway, we can also patch `org-mode-restart', from (defun org-mode-restart () (interactive) (funcall major-mode) (hack-local-variables) (message "%s restarted" major-mode)) to, (defun org-mode-restart () (interactive) (let ((indent-status (org-bound-and-true-p org-indent-mode))) (funcall major-mode) (hack-local-variables) (when (and indent-status (not (org-bound-and-true-p org-indent-mode))) (org-indent-mode -1))) (message "%s restarted" major-mode)) Still not pretty, but a bit better, IMO. Also, there's a dangling (defvar org-indent-mode nil) in org.el that looks suspicious. I don't think we need it if we use `org-bound-and-true-p' whenever we need to check for `org-indent-mode' value. Regards, -- Nicolas Goaziou