In the course of using Emacs I got a dozen of lines that simply make underscore part of a word, and most of them upon byte-compilation are causing warnings like reference to free variable ‘php-mode-syntax-table’
.
I asked on IRC how to deal with that, and it seems the most optimal way is to use eval-after-load
to modify the syntax table. So I made up the code below:
(eval-after-load 'text-mode
'(modify-syntax-entry ?_ "w" text-mode-syntax-table)) ;; make underscore part of a word
(eval-after-load 'rust-mode
'(modify-syntax-entry ?_ "w" rust-mode-syntax-table)) ;; make underscore part of a word
(eval-after-load 'cc-mode
'(modify-syntax-entry ?_ "w" c++-mode-syntax-table)) ;; make underscore part of a word
(eval-after-load 'cc-mode
'(modify-syntax-entry ?_ "w" c-mode-syntax-table)) ;; make underscore part of a word
(eval-after-load 'python
'(modify-syntax-entry ?_ "w" python-mode-syntax-table)) ;; make underscore part of a word
(eval-after-load 'lisp-mode
(modify-syntax-entry ?- "w" lisp-mode-syntax-table)) ;; make underscore part of a word
(eval-after-load 'gud
(modify-syntax-entry ?_ "w" gud-mode-syntax-table)) ;; make underscore part of a word
(eval-after-load 'php-mode
(modify-syntax-entry ?_ "w" php-mode-syntax-table)) ;; make underscore part of a word
(eval-after-load 'haskell-mode
(modify-syntax-entry ?_ "w" haskell-mode-syntax-table)) ;; make underscore part of a word
(eval-after-load 'shell-mode
(modify-syntax-entry ?_ "w")) ;; make underscore part of a word
(eval-after-load 'markdown-mode
(modify-syntax-entry ?_ "w" markdown-mode-syntax-table)) ;; make underscore part of a word
(eval-after-load 'diff-mode
(modify-syntax-entry ?_ "w" diff-mode-syntax-table)) ;; make underscore part of a word
For some reason, Emacs fails at runtime with error like
Warning (initialization): An error occurred while loading ‘/home/constantine/.emacs’:
Symbol's value as variable is void: php-mode-syntax-table
This error not only happens for php-mode
, but also for gud-mode
, haskell-mode
. I can't understand what's causing it — if Emacs really loaded the file, it would clearly have the syntax table. What should I do?