all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Enabling a mode if disabled
@ 2023-07-13 11:03 uzibalqa
  2023-07-13 12:27 ` Robby Zambito
  2023-07-13 13:04 ` Adham Omran
  0 siblings, 2 replies; 4+ messages in thread
From: uzibalqa @ 2023-07-13 11:03 UTC (permalink / raw)
  To: uzibalqa via Users list for the GNU Emacs text editor


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)



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Enabling a mode if disabled
  2023-07-13 11:03 Enabling a mode if disabled uzibalqa
@ 2023-07-13 12:27 ` Robby Zambito
  2023-07-13 13:04 ` Adham Omran
  1 sibling, 0 replies; 4+ messages in thread
From: Robby Zambito @ 2023-07-13 12:27 UTC (permalink / raw)
  To: uzibalqa; +Cc: help-gnu-emacs

Hi,

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)

You can use: (scroll-bar-mode 'toggle)

Robby



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Enabling a mode if disabled
  2023-07-13 11:03 Enabling a mode if disabled uzibalqa
  2023-07-13 12:27 ` Robby Zambito
@ 2023-07-13 13:04 ` Adham Omran
  2023-07-13 14:18   ` uzibalqa
  1 sibling, 1 reply; 4+ messages in thread
From: Adham Omran @ 2023-07-13 13:04 UTC (permalink / raw)
  To: uzibalqa, uzibalqa via Users list for the GNU Emacs text editor

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



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Enabling a mode if disabled
  2023-07-13 13:04 ` Adham Omran
@ 2023-07-13 14:18   ` uzibalqa
  0 siblings, 0 replies; 4+ messages in thread
From: uzibalqa @ 2023-07-13 14:18 UTC (permalink / raw)
  To: Adham Omran; +Cc: uzibalqa via Users list for the GNU Emacs text editor


------- 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.



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-07-13 14:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-13 11:03 Enabling a mode if disabled uzibalqa
2023-07-13 12:27 ` Robby Zambito
2023-07-13 13:04 ` Adham Omran
2023-07-13 14:18   ` uzibalqa

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.