show-paren-mode is a minor-mode that highlights the bracket at point (be it
round, square, or curly) as well as its corresponding open/close counterpart. I
find it a must-have for Elisp and Clojure programming. On the other hand, when
editing Ruby code, it also highlights whole block delimiters, like def, do,
if, and end, and all that must-haviness quickly turns into
in-your-faceviness.
The catch here is that show-paren-mode is a global minor-mode. So you can’t
just enable it locally in lisp-mode-hook, and if you try to do
(show-paren-mode -1) in ruby-mode-hook you’re going to disable it globally
every time you visit a ruby file.
Fortunately, show-paren-function checks the value of the variable
show-paren-mode, so we can pseudo-disable it by setting this variable locally.
With this, the mode will still be active in ruby-mode buffers, but it won’t
actually do anything.
Alternatively, you could reset show-paren-data-function to its original value
(also inside ruby-mode-hook). This will keep only the basic bracket
highlighting.
Locally configure or disable show-paren-mode
18 May 2016, by Artur Malabarba.show-paren-mode
is a minor-mode that highlights the bracket at point (be it round, square, or curly) as well as its corresponding open/close counterpart. I find it a must-have for Elisp and Clojure programming. On the other hand, when editing Ruby code, it also highlights whole block delimiters, likedef
,do
,if
, andend
, and all that must-haviness quickly turns into in-your-faceviness.The catch here is that
show-paren-mode
is a global minor-mode. So you can’t just enable it locally inlisp-mode-hook
, and if you try to do(show-paren-mode -1)
inruby-mode-hook
you’re going to disable it globally every time you visit a ruby file.Fortunately,
show-paren-function
checks the value of the variableshow-paren-mode
, so we can pseudo-disable it by setting this variable locally.With this, the mode will still be active in
ruby-mode
buffers, but it won’t actually do anything.Alternatively, you could reset
show-paren-data-function
to its original value (also insideruby-mode-hook
). This will keep only the basic bracket highlighting.Tags: init.el, emacs,
A review of Mickey Petersen’s “Mastering Emacs” book, for beginners and advanced users »
« validate.el: Schema validation for Emacs-Lisp
Content © 2019, All rights reserved. Icons under CC3.0.