Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
emacs mode?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  8 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
James Cooper  
View profile  
 More options Apr 16 2011, 10:44 pm
From: James Cooper <jamespcoo...@gmail.com>
Date: Sat, 16 Apr 2011 19:44:32 -0700 (PDT)
Local: Sat, Apr 16 2011 10:44 pm
Subject: emacs mode?

Hi there,

Cool project.  I'm considering taking it for a spin and port a site I wrote
in node.js over to it.  

What's the best way to get emacs configured so it uses python-mode for the
first two pages in a file, and html or django mode for the bottom page?

I'm not an elisp whizz..  Does this involve configuring mmm?

A sample .emacs gist would be stellar if anyone has one.

cheers

-- James


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chad Whitacre  
View profile  
 More options Apr 16 2011, 11:00 pm
From: Chad Whitacre <c...@zetaweb.com>
Date: Sat, 16 Apr 2011 23:00:02 -0400
Local: Sat, Apr 16 2011 11:00 pm
Subject: Re: emacs mode?

James,

Not an emacs user myself, very interested in the answer to your question.
Would love to put this on the site if/when someone figures this out.

chad

On Sat, Apr 16, 2011 at 10:44 PM, James Cooper <jamespcoo...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Cooper  
View profile  
 More options Apr 17 2011, 12:36 am
From: James Cooper <jamespcoo...@gmail.com>
Date: Sat, 16 Apr 2011 21:36:18 -0700 (PDT)
Local: Sun, Apr 17 2011 12:36 am
Subject: Re: emacs mode?

Hi Chad,

This turned out to be pretty easy

https://gist.github.com/923763

I found two-mode-mode.el
here: http://www.emacswiki.org/emacs/MultipleModes#toc5

Then I customized it a bit for aspen.  Example file:

# imports

import sys

^L

# per request

foo = bar()

^L
<html>
    <title>hi</title>
</html>

___

This was my customization:

(defvar default-mode (list "nXHTML" 'nxhtml-mode))
(defvar second-modes (list
                      (list "Python" "#" "\x0c" 'python-mode)
                      ))

So nxhtml-mode is the default mode.  That's probably what you want in case
you have .html files that have no python.

Python blocks are any region that start with a # and end with a page break.
 The # was the best idea I had about how to delimit the start of a Python
block.  Open to better ideas.

Anyhow that seems to work pretty well.

___

tl;dr..   Grab the two-mode-mode.el file and configure your .emacs to load
it.  

Is there a way to tell aspen to use a different file extension for simplate
files?  I'd like to have something unique that I can tell emacs to associate
with this mode.  Right now I'm just invoking it manually when I open a
buffer.

-- James


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chad Whitacre  
View profile  
 More options Apr 17 2011, 3:07 am
From: Chad Whitacre <c...@zetaweb.com>
Date: Sun, 17 Apr 2011 03:07:31 -0400
Local: Sun, Apr 17 2011 3:07 am
Subject: Re: emacs mode?

James,

> This turned out to be pretty easy

Sweet! I put in a quick link here:

    http://aspen.io/page-break/

 Is there a way to tell aspen to use a different file extension for simplate

> files?  I'd like to have something unique that I can tell emacs to associate
> with this mode.  Right now I'm just invoking it manually when I open a
> buffer.

Hmmm ... what about a knob in aspen.conf like simplates_extension? So that
would get tacked onto all requests so if you used ".smpl" then a request for
/foo.html would resolve to /path/to/my/site/foo.html.smpl. But then what
about /path/to/my/site/bar.gif.smpl? You can serve simplates besides HTML,
though certainly that's most common. I guess in non-HTML cases you're
generally going to have a stub in the template part. Like w/ json you would
just have {{ json_encode(out) }} or some such. No mode necessary (html mode
would be fine).

Is there a way in Emacs to use simplates-mode if a file has a page break or
two? This could mess you up if you're Barry Warsaw and you use page breaks
all the time. But maybe as a workaround?

chad

On Sun, Apr 17, 2011 at 12:36 AM, James Cooper <jamespcoo...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Cooper  
View profile  
 More options Apr 17 2011, 11:16 am
From: James Cooper <jamespcoo...@gmail.com>
Date: Sun, 17 Apr 2011 08:16:09 -0700 (PDT)
Local: Sun, Apr 17 2011 11:16 am
Subject: Re: emacs mode?

Hi Chad,

Couldn't we just make the ".html" extension configurable?

[aspen]

simplate_extension=.smpl

And then you'd just name your files:

/
 index.smpl
 foo.smpl
 .aspen/
           my_include.smpl

etc?

-- James


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chad Whitacre  
View profile  
 More options Apr 17 2011, 3:29 pm
From: Chad Whitacre <c...@zetaweb.com>
Date: Sun, 17 Apr 2011 15:29:39 -0400
Local: Sun, Apr 17 2011 3:29 pm
Subject: Re: emacs mode?

James,

Well, the file extension determines the Content-Type header that is
returned--*unless* you manually set it using
response.headers.set('Content-Type', 'text/foo') in your simplate. So you
can have a simplate named foo.pdf that automatically returns application/pdf
data, or bar.png that automatically returns image/png data. And you could
have a foo.smpl file where you set the Content-Type manually to text/html.

The default value is text/plain. But you can change this with
default_mimetype in aspen.conf.

    http://aspen.io/aspen.conf/

That way any unknown extension, including *.smpl, would be sent as
text/html.

Unfortunately, though, only index.html is currently supported as the default
filename. I like the idea of adding a default_filenames knob to aspen.conf
as well, which would take care of that, I think.

On the mimetypes issue, I'm inclined to read a mime.types file from .aspen.
This would be in addition to a mime.types file that I would bundle with
aspen itself; see:

    https://github.com/whit537/aspen/issues/1

Then you could configure .smpl as text/html for your website.

How would you feel about those two configuration options (default_filename +
mime.types)?

chad

On Sun, Apr 17, 2011 at 11:16 AM, James Cooper <jamespcoo...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Cooper  
View profile  
 More options Apr 17 2011, 7:56 pm
From: James Cooper <jamespcoo...@gmail.com>
Date: Sun, 17 Apr 2011 16:56:29 -0700 (PDT)
Local: Sun, Apr 17 2011 7:56 pm
Subject: Re: emacs mode?

Hi Chad,

Yes, I think that combo would work well.  I didn't realize the default mime
type was inferred from the file extension.  pretty cool!

-- James


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chad Whitacre  
View profile  
 More options Apr 21 2011, 4:10 pm
From: Chad Whitacre <c...@zetaweb.com>
Date: Thu, 21 Apr 2011 16:10:05 -0400
Local: Thurs, Apr 21 2011 4:10 pm
Subject: Re: emacs mode?

James,

Ok, default_filenames and mime.types support added in 0.9.35:

    http://aspen.io/aspen.conf/
    http://aspen.io/mime.types/

Let me know if these don't work for you.

chad

On Sun, Apr 17, 2011 at 7:56 PM, James Cooper <jamespcoo...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »