5

I have enabled org-indent-mode in all org files as such:

(add-hook 'org-mode-hook 'org-indent-mode)

Now I want to diminish the "Ind" minor mode, which seems to be beyond my abilities. I know the diminish package is loading and working properly, as other diminishes work as expected.

I managed to find (add-hook 'org-mode-hook '(diminish 'org-indent-mode)), which actually diminishes the mode, but also shows File mode specification error: (invalid-function (diminish (quote org-indent-mode))) in messages, which seems like I'm doing something wrong.

A list of other things I've tried that don't work:

(eval-after-load "org" '(diminish 'org-indent-mode))

(diminish 'org-indent-mode)

(add-hook 'org-mode-hook
      (lambda ()
      (diminish 'org-indent-mode))

(defun dim-org-ind-mode ()
    "Hah, this doesn't work either."
    (interactive)
    (diminish 'org-indent-mode))
(add-hook 'org-mode-hook 'dim-org-ind-mode)

Using M-x diminish works fine with no errors in messages.

  • 1
    There's a missing closing paren in your first add-hook. I'm referring to the list of things you tried. – Manuel Uberti May 25 '16 at 16:51
6

Your eval-after-load is close. Check out C-h f org-indent-mode (after Org is loaded):

org-indent-mode is an interactive autoloaded compiled Lisp function in `org-indent.el'.

Diminish hacks directly into the variable minor-mode-alist, so the call to it must occur after org-indent.el has been loaded, not just org.el:

(eval-after-load 'org-indent '(diminish 'org-indent-mode))

| improve this answer | |
1

Either of these worked for me:

; whacka's answer
(eval-after-load 'org-indent '(diminish 'org-indent-mode))

; fixed Gastove's answer
(add-hook 'org-indent-mode-hook (lambda () (diminish 'org-indent-mode)))
| improve this answer | |
  • OP mentioned that these snippets don't work for him. – user12563 May 15 '19 at 21:27
  • I don't see where OP mentioned that. Please read more carefully and you will see that there is a difference between my solution and what they tried. Every character counts. – niko May 15 '19 at 22:31
  • You're right, I haven't paid enough attention to hook names. – user12563 May 15 '19 at 22:34
  • The first version is included in whacka's answer – Andrew Swann May 16 '19 at 11:44
  • It is indeed. That's where I got mine from. I actually just wanted to comment on Gastove's answer but since I didn't have enough points I figured to post yet another answer with all versions that worked for me. – niko May 16 '19 at 22:36
1

You're very close! add-hook expects that you're going to add a function to a hook, not the evaluation of an expression. You just need to wrap your call to diminish in a lambda, like this:

(add-hook 'org-indent-mode-hook (lambda () (diminish 'org-indent-mode)))
| improve this answer | |
  • I can't seem to get @gastove's answer to work for some reason, but it pushed me to try something else, which does work: (add-hook 'org-mode-hook (lambda () (org-indent-mode 1) (diminish 'org-indent-mode))) I think it might be because of a load-order issue, perhaps because org-indent-mode takes time to complete? – Geoff May 25 '16 at 17:33
  • Yes, org-mode-hook is the wrong hook to use. See niko's answer for the more appropriate hook. The eval-after-load method is better, though, so I recommend using that instead of a mode hook. – phils May 16 '19 at 22:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.