Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enabling modes in emacs

Tags:

emacs

elisp

I have just started to customize the emacs. If I want to enable some mode (globally) in emacs, I need to put some code in the .emacs file. For visual mode the code will be (global-visual-line-mode t). But the same syntax doesn't work for something like show-paren-mode. So is there any way to recognise the syntax has to be used for globally enabling a mode? Or is it something which has to be known?

like image 264
sudeepdino008 Avatar asked Mar 16 '26 09:03

sudeepdino008


2 Answers

Use the Emacs help system:

M-x describe-function RET show-paren-mode RET

...or use the 'Help' menu in the menu bar:

Help => Describe => Describe Function... show-paren-mode RET

,,,or the keyboard binding:

C-h f describe-function RET show-paren-mode RET

Finally, consider using the Emacs 'custom' package (M-x customize RET) which will maintain many settings in your .emacs file for you. Or for a specific option, from the menu bar:

Options => Customize Emacs => Specific Option...

Also, while typing in the minibuffer, entering zero or more characters followed by TAB will offer completion options.

like image 131
DavidRR Avatar answered Mar 20 '26 00:03

DavidRR


The generally helpful answer is to use customize. They you don't have to know the exact syntax (or even in fact any Elisp at all); just tick the checkbox and enable for all sessions.

If you really care about the Elisp, there are regrettably three different conventions.

  • As you have discovered, many modes have something like (activate-mode) or (name-of-mode t).
  • Others have a toggle, some of which work with an optional numeric argument to not toggle, but turn on or off; (toggle-mode -1) to turn on unconditionally.
  • The mode may have a variable associated with it, so you would (setq mode-variable t) and the mode would know to activate itself. This is a marginal case.
like image 39
tripleee Avatar answered Mar 20 '26 00:03

tripleee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!