Emacs TAB Issue in Makefile#
Introduction to Emacs and Makefile TAB Issues#
During work with Emacs
and Makefile
, you may encounter an issue with the TAB
key.
This post will show you how to notice this issue and how to fix it.
Why Your Makefile Might Fail to Run#
When one is working with shell and runs make
command, one can see following error:
$ make
Makefile:5: *** missing separator. Stop.
Above error is caused by the issue with the TAB
key in the Makefile.
Editing the Makefile for Compatibility#
Emacs
is good editor with built-in support for Makefiles.
However there is an issue with the TAB
key in the Makefile.
Even when one opens Makefile and press TAB
key, it is not always working as expected.
And this is not easy to notice.
Please see the following screenshot:
Hint
To make this bigger please right click on screenshot and open in new tab
On the screenshot above, one can see:
There are four dots in the beginning of the line which are not visible in the editor (without special mode) And even when
TAB
was pressed from some reasonEmacs
converted it to spaces.Line below one needed to force
TAB
key to be inserted by pressingC-q TAB
key sequence (C-q
stands forCTRL-q
)Emacs
is aware that is working with MakefileEmacs
is havingmakefile-mode
enabled
This is something which is not easy to notice and can cause issues with running Makefile.
Visualizing Whitespace in Emacs#
Above points allowed to notice the issue with the TAB
key in the Makefile.
However Emacs
needs to be configured to show whitespace characters which are not visible by default.
To enable this feature please run following command: M-x whitespace-mode
Steps to Resolve the TAB Issue#
Once the whitespace characters are visible, one can run following commands to fix the issue:
Move cursor to the beginning of file
M-<
Select full buffer:
M-SPC
andM->
Run command
M-x tabify
Final Thoughts on Emacs TAB Fixes#
This post showed how to notice and fix the issue with the TAB
key in the Makefile when working with Emacs
.
Additional Resources#
See also