Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Automatically use hard tabs for Makefile buffers #3

Closed
cbednarski opened this issue Mar 20, 2014 · 52 comments
Closed

Automatically use hard tabs for Makefile buffers #3

cbednarski opened this issue Mar 20, 2014 · 52 comments
Assignees
Labels

Comments

@cbednarski
Copy link

Since makefiles require hard tabs, I'd like Atom to automatically use hard tabs whenever I'm editing a Makefile. Atom already detects the buffer type automatically.

Sublime Text accomplishes this via language-specific configuration files. So for example, I can independently specify 2 spaces default for javascript, 4 spaces default for python, and hard tab default for Makefiles. Not sure if this makes sense in Atom land but it seems like a simple way to do it.

@noseglid
Copy link

+1

@iamdanfox
Copy link

👍 This was the first thing that forced me to switch back to Sublime Text!!

@azhang
Copy link

azhang commented May 10, 2014

👍 just ran into this problem now.

@lost-carrier
Copy link

+1

Makefile:X: *** missing separator.  Stop.

OMG! Pain in the a... please fix this!!!

@liangshan
Copy link

+1

@kgrossjo
Copy link

+1

I will edit it in vim for the time being.

@bral
Copy link

bral commented May 16, 2014

I ended up just writing this and placing it in my Atom > Init Script

path = require 'path'

# Set Makefile[.any extension] and '.mk' files to always use hard tabs
atom.workspaceView.eachEditorView (editorView) ->
  editor = editorView.getEditor()
  if path.basename(editor.getPath()) is 'Makefile'
    editor.setSoftTabs(false)
  if path.extname(editor.getPath()) is '.mk'
    editor.setSoftTabs(false)

Seems to be working so far

@parabuzzle
Copy link

I'll look into creating a pull request for a fix for this

@johnwebbcole
Copy link

+1

@parabuzzle
Copy link

I wonder if anyone is going to review my pull request... 😕

@yoshuawuyts
Copy link

@parabuzzle Have you started the PR? This bug is super annoying.

@parabuzzle
Copy link

@yoshuawuyts the pull request has been open since May -> #8

@parabuzzle
Copy link

@yoshuawuyts according to the PR referenced here for the core Atom code (atom/atom#2917) It appears that languages can specify hard tabs as an option.

I'll look into it today. If that's the case, I'll submit a new PR using this new option.

@probablycorey probablycorey removed their assignment Aug 25, 2014
@mbrevoort
Copy link

+1

@banacorn
Copy link

+1
Seems like the problem is still in 0.125.0

@kelvich
Copy link

kelvich commented Sep 11, 2014

+1

1 similar comment
@nakardo
Copy link

nakardo commented Sep 11, 2014

+1

@kelvich
Copy link

kelvich commented Sep 12, 2014

Seems it is fixed in 0.127, working for me now

@parabuzzle
Copy link

@kelvich really? It doesn't seem to work for me and I don't see it in the release notes here: https://github.com/atom/atom/releases/tag/v0.127.0

Are you using the hack that @brannonlucas provided earlier on this thread?

@chpmrc
Copy link

chpmrc commented Sep 17, 2014

Using version 0.130 and this still hasn't been fixed.

@jbrunner
Copy link

+1

1 similar comment
@franciscod
Copy link

+1

@mniak
Copy link

mniak commented Nov 9, 2014

+1

@parabuzzle
Copy link

so I count 16 +1's so far ...

@franciscod
Copy link

why isn't anyone merging #8? what's bad about it?

@DamonOehlman
Copy link

+1

and it's back to LightTable for me...

@kevinsawicki
Copy link
Contributor

I just want to apologize for the long delay in getting this issue addressed.

It got held up in trying to fix it the "right way" when it should have been addressed immediately while that right way is figured out and implemented.

The "right way" in this case was having this be a scoped setting that any language package can use.

I've added a workaround for now that hard codes this grammar's scope name in core and uses hard tabs as the default.

Again, apologies for the long delay in getting this addressed, it will be fixed in Atom 0.146 which should be out shortly.

@franciscod
Copy link

nice @kevinsawicki! thanks!

@yoshuawuyts
Copy link

🎉 thanks!

@parabuzzle
Copy link

dance

@kevinsawicki
Copy link
Contributor

0.146 is now released with this fix included in it, apologies again for how long this took to get fixed.

@banacorn
Copy link

thanks!

@DamonOehlman
Copy link

Thanks @kevinsawicki - appreciate it :)

@flying-sheep
Copy link

@parabuzzle is this a subtle advertisement for using rake instead? 😀

@rgbkrk
Copy link

rgbkrk commented Oct 15, 2015

Could my own settings be overriding this somehow? I'm still ending up with spaces by default.

@rgbkrk
Copy link

rgbkrk commented Oct 15, 2015

To answer my own question, it's a result of soft being set instead of auto in settings under "Tab Type":

screenshot 2015-10-15 17 09 21

@thomasjo
Copy link
Contributor

@rgbkrk The language settings should win, and in the case of language-make, the tab type is set hard.

@atom/feedback Can any of you repro this?

@50Wliu
Copy link
Contributor

50Wliu commented Oct 16, 2015

I believe it's because Make 0.18.0 (which added the scoped setting) isn't installed on Atom 1.0.19.
https://github.com/atom/atom/blob/7229d1a4295dd0fcb644b7c891a64e6836b2c3b2/package.json#L138

@DJviolin
Copy link

@50Wliu I installed the language-make 0.19.0 with apm install language-make command, but still inserting spaces instead of tabs. :(

Console output:

$ apm install language-make
The language-make package is bundled with Atom and should not be explicitly installed.
You can run `apm uninstall language-make` to uninstall it and then the version bundled
with Atom will be used.
Installing language-make to C:\Users\[USERNAME]\.atom\packages done

@asbjornu
Copy link

I've been struggling like a nutbag with this in Atom 1.4.1. I've tried every possible setting of "Soft Tabs" and "Tab Type". I've tried to convert spaces to tabs. Whatever I do; when the Makefile is saved, it has spaces in it.

Checking "Show invisibles" reveals that I do get tabs when I press the tab key (represented by ») in the editor, but when I save, they are replaced with spaces.

I finally figured out what it was. The tabs to spaces package has a configuration that I obviously must have turned on at some point:

"tabs-to-spaces":
    "onSave": "untabify"

This was being applied even when the package was disabled. Perhaps I need to restart Atom for the package's config to be ignored when the package is disabled? I don't know. I've tried to change the package's configuration to this:

"*":
  "tabs-to-spaces":
    "onSave": "untabify"
"Makefile":
  "tabs-to-spaces":
    "onSave": "tabify"

But it doesn't help. I know this is beyond the scope of this issue, but I just wanted to mention it, for anyone else who stumble on to this with the same problem as I.

@thomasjo
Copy link
Contributor

@asbjornu Are you able to reproduce the behavior in safe mode? atom --safe. Nothing in Atom (should) perform anything like this on save, so I'm guessing this is actually caused by the tabs-to-spaces package (which has "on save" behavior).

@asbjornu
Copy link

@thomasjo You're right. As I've updated my comment above, tabs-to-spaces and its onSave functionality is to blame. I was just dumbfounded that it was doing its thing even though I had disabled the package. Adjusting the configuration also doesn't help, so I'm creating an issue with it.

@sunjay
Copy link

sunjay commented Feb 26, 2017

For anyone who ends up here from Google and sees @asbjornu's configuration, it needs to look like this:

"*":
  "tabs-to-spaces":
    "onSave": "untabify"
".source.makefile":
  "tabs-to-spaces":
    "onSave": "tabify"

This was addressed in: lee-dohm/tabs-to-spaces#42

@braadworst
Copy link

@sunjay, ace! I couldnt figure out what the scope key name was for makefiles.

@bennabiy
Copy link

I am still having this issue, but not sure what package is causing it as I do not have tabs-to-spaces installed. I have tabs in my Makefile, but on save, I get 8 spaces instead.

@bennabiy
Copy link

I may be dense, but where do I set those settings to make it work?

@dcburleigh
Copy link

How do I tell Atom which files are makefiles? I have some files like makefile.dev, makefile.inc,
and I'd like Atom to give me hard tabs, syntax highlighting, etc.

@50Wliu
Copy link
Contributor

50Wliu commented Dec 3, 2017

@dcburleigh you can use the Grammar Selector (Ctrl+Shift+L on Windows/Linux, cmd-shift-L on macOS), or follow the instructions at https://discuss.atom.io/t/how-do-i-make-atom-recognize-a-file-with-extension-x-as-language-y/26539.

@richardPFisk
Copy link

I had some joy using .editorconfig with this setting:

[Makefile]
indent_style = tab

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests