Hacker News new | past | comments | ask | show | jobs | submit login
Emacs Zen Coding - Write markup quickly (emacswiki.org)
41 points by kirubakaran on Nov 8, 2009 | hide | past | favorite | 10 comments



This is pretty neat, but I'm not sure it's really practical. I don't want to learn a new syntax just to save a few keystrokes. When I use JQuery, it's nice that it cuts down on some typing, but the reason I use it is because it abstracts away things like animations.

Is how fast I can write mark-up really bound by how many characters I have to type? For me at least, it's more bound by thinking, so I don't want to do anymore of that. And I don't even type that fast.


This isn't really a new syntax, though -- it mostly just uses standard CSS selectors (.class, sibling+sibling, parent>child, etc).


Wow, you're right: http://www.w3.org/TR/css3-selectors/#child-combinators

It also reminds me of HAML (discussed recently): http://news.ycombinator.com/item?id=925573

Looking at one aspect: The idea of abstracting the verbosity of HTML/XML by just stating the element name once (instead of both open and close tags) is not new. Many people have implemented this idea, but it doesn't seem to catch on. It could be that that very verbosity is a significant factor in the success of HTML and XML (both have widespread adoption).

SGML (the common ancestor of both HTML and XML) allowed a "</>" close tag, which goes part-way towards reducing verbosity, but it was deliberately omitted from HTML and XML. Both have been much more successful than SGML. Though it's hard to know what impact that particular omission had, greater abstraction is harder to read for newcomers, and therefore probably decreases adoptability...

Perhaps it's the Abstraction vs. Verbosity being played out in another forum e.g. Lisp abstraction being more powerful but Java verbosity being more popular.


Yeah, but the SGML declaration for HTML contains SHORTTAG, so

  <a href=../bar/index.html>Bar</a>
is actually shorthand for the invalid

  <a href="..">bar</a>index.html>Bar</a>
Good luck reading real world HTML with a browser that implements that correctly. (And that is why the W3C validator so often complains about a closing A tag that is not open (or at least used to do). )


Well, it's totally new to me!


How about a command for closing whatever tag is open where the cursor is? For repeating the last closed tag? For wrapping a tag in another tag?

I'm an emacs noob but it seems like the tools for actually working with existing markup are impoverished. You only write markup once; you have to maintain it forever.


> How about a command for closing whatever tag is open where the cursor is?

Try `C-h m` to find out what commands your HTML editing mode provides. In HTML Mode, `C-c /` closes the current element, and in nxml mode, `C-c C-f` does the same thing. Even better, in nxml mode, when `nxml-slash-auto-complete-flag` is non-nil the current element is automatically closed when you type a "/".

The nice thing about Emacs is that it's pretty trivial to write a little elisp code to add the other functionality you're looking for.


Ahh the power and fun of Emacs :) Good stuff.


What's the advantage of this over Haml?


That it isn't compiled but is immediately transformed. (In regards to Emacs)




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: