[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Enabling a mode if disabled
From: |
uzibalqa |
Subject: |
Re: Enabling a mode if disabled |
Date: |
Thu, 13 Jul 2023 14:18:44 +0000 |
------- Original Message -------
On Friday, July 14th, 2023 at 1:04 AM, Adham Omran <mail@adham-omran.com> wrote:
> uzibalqa uzibalqa@proton.me writes:
>
> > I want to enable scroll-bar only if the mode happens to be disabled. And
> > conversely to disable it if it is enabled. What can I do?
> >
> > (scroll-bar-mode 1)
>
>
> A hook should useful here.
>
> (defun my-scroll-bar-mode-hook ()
> (if (eq major-mode 'org-mode)
> (scroll-bar-mode 1)
> (scroll-bar-mode -1)))
>
> (add-hook 'after-change-major-mode-hook 'my-scroll-bar-mode-hook)
>
> Use the proper hook depending on when you want the change to occur.
> Here it occurs after calling *-mode.
>
> Adham Omran
The test should be done upon scroll-bar-mode rather than some other major mode.