6 ms·
> Emacs famously has its idiosyncratic brace style and indentation style using a mix of tabs and spaces that no-one else uses. Specifically, 'one indent is fou
by mst 3y ago
> Emacs famously has its idiosyncratic brace style and indentation style using a mix of tabs and spaces that no-one else uses.
Specifically, 'one indent is four spaces, two indents is one tab, repeat', which caused utter carnage for newbies editing YAML files since literal tabs aren't valid YAML.
Back in the day, I built consensus to switch the perl https://p3rl.org/Catalyst https://p3rl.org/Catalyst framework over to defaulting to an apache style config in the scaffold generator specifically because about 75% of our "confused newbie" questions on IRC at the time were people whose emacs config had broken their YAML config file.
Of course we're -ahem- a few years on from that now, and people generally have already had at least one pitched battle with YAML before installing/adopting another thing that uses it, but still, oh gods but that was frustrating for a while.
- jonnycomputer 3y agoIs this in text mode? I don't think this happens when editing python or bash scripts. But as a default for any mode that cycle is ... nuts. Though I'm sure there must have been some reason for it.
- jonnycomputer 3y agoI mean it almost sounds like a compromise solution proposed by a Committee of Indentation composed of both advocates of tabs and spaces. (:
- xmprt 3y agoThey probably think this is actually a good idea: https://xkcd.com/1292/ https://xkcd.com/1292/
- adrianmonk 3y agoI'm pretty sure the reason was to save bytes in the file. 1 tab character is 87.5% smaller than 8 spaces. Back in the day when disk space was extremely limited, people actually did care about this. They saved bytes any way they could. The standard tab width (in most software, not just emacs) is 8. Basically nobody wants that much indentation, so your options are: (1) Don't use tabs at all. Just use spaces. If space efficiency is a requirement, that eliminates this option. (2) Use tabs only and change the tab width to match your desired indentation level. This is a simpler method. The downside is other people need to change their tab width to match yours. They may not want to, or their software may not support it. You have to decide whether you want to deal with that. (3) Mix tabs and spaces. This is more complicated, but most software will display the files as expected without any tweaking. TLDR: Tabs save disk space, but tabs are too wide, and changing tab width is a hassle, so mixed tabs/spaces is a compromise.
- jonnycomputer 3y agoInteresting. Easy to believe.
- drewg123 3y agoThe benefit of using tabs with a tab width of 8, and limiting screen with to 80 columns (like old text based terminal) is that you limit how many loops and conditions you can nest in a single function due to running out of horizontal space. Eg, it encourages you to break functions with complex nested loops/conditionals into smaller functions. EDIT: Both the Linux and BSD kernel coding style specify tabs for indentation, and a tab width of 8. The Linux guide says it best: "In short, 8-char indents make things easier to read, and have the added benefit of warning you when you’re nesting your functions too deep. Heed that warning."
- rollcat 3y ago> Eg, it encourages you to break functions with complex nested loops/conditionals into smaller functions. Did you read the Emacs source much? They compensate by having functions span thousands of lines
- deleted 3y ago[deleted]
- bsder 3y ago> "In short, 8-char indents make things easier to read, and have the added benefit of warning you when you’re nesting your functions too deep. Heed that warning." And, yet, that becomes so much religious dogma that people will shoot themselves in the foot. I fixed a lot of network locking code way back when. I made sure that I had a validation framework to go along with it. It was a gigantic state machine, because that's what locking and protocol are. But, you know, that thing had single exit point and 4-5 indent levels and extended past 80 characters because it was a goddamn state machine, had states and variables lifted directly from the specification state machine, and tested as a state machine with the validation suite. But, hey, the kernel devs just had to rewrite it to match 2 indents and 80 character lines. So, they did. And took 9 months until they passed the validation suite again. They didn't add a single feature. They didn't fix a single bug. But, hey, they dedented it real good. What finally did the deed was that one of the senior devs finally got fed up, went back to my original code, wrote a Perl script (that's how regular my code was) to rewrite every state block into a function with extremely short, unintelligibly cryptic names and args in order to remove two levels of indent and make sure the function calls would fit in 80 characters. The final kicker: someone genuinely found a real bug about 5 weeks afterward. They tried to fix it in the "better" code with less indents. They couldn't figure out which state was the problem because they mangled all the names. I went into my old code, fixed it, added a test to the suite and reran the refactoring script--and that's how the bug got fixed. We're not developing on punch cards and VT100s anymore people--quit being stupid. (Side note: the main issue that bit the devs is that people who are dogmatic about 2 tabs-80 characters tend to rely on early return to avoid fully-fleshed if-then-else which cause deeper chains. This does not work for state machines. There is no early return--every state should leave at exactly the point when you advance from the old state to the new state at the atomic swap. So, you can do what the senior dev did and cryptify everything, or you can just leave the damn state machine alone and accept 4 indents and 132 characters.)
- eduction 3y agoI had this same question, because wouldn't the mode author for a given language define this? I can't imagine this is the same across literally all modes that involve indentation and/or braces?
- mst 3y agoI don't honestly know the details, I'm an heirloom-vi user and was just on the other side of the conversation from the confused newbie multiple times. So "apparently under some distro configs in some circumstances it does that" is pretty much all I bothered to find out, because the config data structures people were mostly expressing worked fine with a less touchy format. (and this was only the -default- format configured by the scaffold, if you handed the config system a YAML file it was still happy to load it)
- snicker7 3y agoYAML was a mistake. Couldn’t count how many issues I and my colleagues encountered due to white space misalignment.
- entropie 3y agoI use yaml for over 15 years now and never had any issues. Iam a rubyist, naturally that was how i first met yaml and since then I really like it. Also with homeassistant I was "forced" to write a lot of yaml by hand and also never had real issues. Maybe its because emacs handles writing yaml fine. Anyways. I like yaml.
- mst 3y agoYour emacs config may. Their emacs configs didn't. Hopefully most distros' default emacs installs do the right thing these days but it's not something I've checked because these days pretty much everybody already has a setup that works for YAML because of how prevalent it is. (I like YAML for just-about-human-editable data structures but then people try to text template it rather than actually treating it as data and then I want to cry)
- jwmcq 3y agoReally? I think YAML perfectly fills the niche of a config format that is both hard for humans to write, and difficult for machines to read.
- dwringer 3y agoEmacs user here... Today I learned why sometimes my YAML files seemed inexplicably to end up with tabs in them.
- zajio1am 3y agoI like Emacs indenting style. It emphasizes the fact that in indentation, important are visual columns, not implementation details like tabs or spaces.
- radlad 3y agoThe problem is that tabs do not have consistent visual columns across applications. For example, I would argue that MOST modern text editors treat a tab as approximately 4 spaces, not 8 spaces.
- Rygian 3y agoThat's not a default, that must be a bug!
- mst 3y agoSo far as I can tell it's emacs' internal indent style and some configurations end up using it for things that aren't emacs internal code. Exactly how said "some configurations" came to be I never figured out, it may have been a particular set of distro defaults.
- Ferret7446 3y agoEmacs does not have an "idiosyncratic indentation style". Indentation is mode (file type) dependent. For example, for Python the default is 4 spaces if it cannot infer from an existing file what is being used. For C, it appears to be two spaces. If your language has a convention, then likely Emacs implements it. If not, you can send a patch to fix it.