Emacs Asked on December 4, 2021
I added the following line to my init file to replace ruby-mode
with enh-ruby-mode
:
(setq auto-mode-alist
(mapcar
(lambda (x)
(if (eq (cdr x) 'ruby-mode)
(cons (car x) 'enh-ruby-mode)
x)) auto-mode-alist))
But it works only for the first file. The first ruby
file I open is in enh-ruby-mode
. But in the process the following command is executed:
/usr/share/emacs/26.3/lisp/progmodes/ruby-mode.el.gz
:
;;;###autoload
(add-to-list 'auto-mode-alist
(cons (purecopy (concat "\(?:\.\(?:"
"rbw?\|ru\|rake\|thor"
"\|jbuilder\|rabl\|gemspec\|podspec"
"\)"
"\|/"
"\(?:Gem\|Rake\|Cap\|Thor"
"\|Puppet\|Berks"
"\|Vagrant\|Guard\|Pod\)file"
"\)\'"))
'ruby-mode))
(The same line is in /usr/share/emacs/26.3/lisp/loaddefs.el
.) Which means the second and the following files are opened in ruby-mode
.
I guess to remedy this I’ve got to not change the line in auto-mode-alist
, but add one. Anyways, how does this autoload thing work? When does loaddefs.el
get executed? Is there a way to keep the line out of the file?
The thing can be reproduced with expand-region
package installed.
From what I can see, when enh-ruby-mode
gets activated, expand-region
loads enh-ruby-mode-expansions.el
. But that in its turn loads ruby-mode-expansions.el
, which requires ruby-mode.el
.
As a result, when you open a ruby file, enh-ruby-mode
gets activated, but still ruby-mode.el
is also loaded.
So, if I change auto-mode-alist
in my init file, then when I open a ruby file, ruby-mode.el
gets executed, and adds the association with ruby-mode
back.
To avoid that one has to require ruby-mode.el
in advance (before opening ruby files).
Answered by x-yuri on December 4, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP