Coder Social home page Coder Social logo

pony-mode's Introduction

Pony Mode -a Django mode for emacs

A Django mode for emacs.

Features (Non-exhaustive):

  • Run dev server in an emacs buffer [C-c C-p r] * Checks to see if runserver_plus is available * If not uses in-built runserver
  • Jump to current project in browser (start server if required) [C-c C-p b]
  • Run test case at point in buffer [C-c C-p t]
  • Run tests for current app in buffer [C-c C-p t]
  • Run Syncdb on current project
  • Run Celeryd [C-c C-p c]
  • Management commands for current project in interactive buffer
  • South integration - run south convert, schemamigration, migrate
  • Run django shell in buffer [C-c C-p s] * Checks for shell_plus * If not defaults to shell
  • Fabric integration [C-c C-p f]
  • Startapp and dumpdata on current project within emacs
  • Database integration with Emacs sql-mode interactive buffer [C-c C-c d
  • Django Template minor mode with syntax highlighting for django template tags
  • Snippet collection for django
  • generate tags table for project
  • run manage commands in interactive buffer
  • Buildout integration
  • Generate TAGS table for project to enable quick navigation
  • Jump to template at point or from editing view [C-c C-p g t]
  • Virtualenv integration

Documentation

The full documentation is available at http://www.deadpansincerity.com/docs/pony/

Installation

  1. clone this repo somewhere $ git clone https://github.com/davidmiller/pony-mode

  2. (optional) Byte-compile the files:

    M-x byte-compile-file (path/to/pony-mode/src/*.el)
    
  3. Add the path to your load-path:

    (add-to-list 'load-path "path/to/pony-mode/src")
    
  4. Add to your .emacs:

    (require 'pony-mode)
    
  5. Enjoy

Bugs

Please report any bugs on the github issue tracker

Configuration

Configuration options per project are available via .dir-locals.el

The file should look something like this:

;; Pony mode config for the megacorp project
((nil . ;; This applies these settings regardless of major mode

  ((pony-settings (make-pony-project
                   :python "/home/david/virtualenvs/megacorp/production/bin/python"
                   :pythonpath "/home/david/megacorp/libs/projectzero"
                   :settings "local_settings_file"
                   :appsdir "testproject/apps/")
))))

Help

Turns out that there is a mailing list at https://groups.google.com/group/pony-mode .

Low frequency, high helpfulness. Feel free to stop by for helps & chats...

Licence

Totally GPL

Roadmap

Check the org-mode file pony.org for current todo/wish list

(If you can stand the org-to-github-markdown transition: https://github.com/davidmiller/pony-mode/blob/master/pony.org )hs

pony-mode's People

Contributors

andreas-roehler avatar arhpreston avatar bartvandendriessche avatar bjchambers avatar craynot avatar davidmiller avatar garaud avatar gareth-rees avatar jacobbarssbailey avatar jdufresne avatar jzellman avatar markhepburn avatar milkypostman avatar myrjola avatar rabio avatar ryuslash avatar sfllaw avatar starenka avatar tarsius avatar thomasf avatar tomscytale avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pony-mode's Issues

pony-db-shell renames a random buffer to *PonyDbShell*

Description

  1. Visit mysite/myapp/models.py in one buffer.
  2. Visit mysite/myapp/views.py in another buffer.
  3. Run the command pony-db-shell.

What I expect to happen: a new buffer pops up containing a database shell.

What actually happens: the buffer containing models.py pops up, renamed to *PonyDbShell*

Analysis

This is caused by the interaction of three bugs:

  1. In my settings.py I have 'ENGINE': 'django.db.backends.mysql' but Pony tests (equalp (pony-db-settings-engine db) "mysql")
  2. If Pony can't find an appropriate sql-connect-* function to call, it calls (pony-pop "*SQL*") and (rename-buffer "*PonyDbShell*") anyway.
  3. pony-pop calls (pop-to-buffer (get-buffer buffer)) which means that if the buffer does not exist, get-buffer returns nil, and pop-to-buffer applies its default behaviour: "If BUFFER-OR-NAME is nil, choose some other buffer."

Fixes

I pushed a fix for this, but for the record, here's what I did:

Fixing stuff bottom-up, first pony-pop. (Note that this doesn't need an autoload cookie since it's not interactive: there is no reason for anyone to call it before pony-mode.el has been loaded.)

(defun* pony-pop (buffer-or-name &key dirlocals)
  "Select `buffer-or-name' in some window, as for `pop-to-buffer'.
Return the selected buffer if successful, or `nil' otherwise.

If the optional keyword argument `:dirlocals' is non-nil, set the
variable `dir-local-variables-alist' in the target buffer to be
equal to the value in the current buffer.  This is useful because
comint buffers without filenames associated will otherwise not
pick up directory-local settings."
  (let ((buffer (get-buffer buffer-or-name))
        (current-locals dir-local-variables-alist))
    (when buffer
      (pop-to-buffer buffer)
      (pony-mode)
      (and dirlocals
           current-locals
           (pony-local! 'dir-local-variables-alist current-locals)))
    buffer))

Second, pony-db-shell. I took the opportunity to make the following improvements:

  1. Put the name of the created buffer in a variable to avoid repeating ourselves.
  2. If the database shell buffer already exists, don't create a new one, just pop to the old one.
  3. There's no need to change the global settings for sql-user and so on: we can use (let ...) to set them locally around the creation of the *SQL* buffer.
  4. We don't need to maintain our own enumeration of SQL backends and which function to call: we can use sql-product-alist.
  5. By calling (sql-product-interactive) we get features turned on via (sql-interactive-mode) including syntax highlighting,
  6. Call rename-buffer with unique set to t so that the rename doesn't throw an error if the buffer already exists.
  7. The use of the pony-db-settings structure is overkill since its only use is to get the data for pony-db-shell.
;;;###autoload
(defun pony-db-shell ()
  "Run interpreter for this project's default database as an inferior process."
  (interactive)
  (let ((buffer-name "*pony-db-shell*")
        (db-format (if (pony-setting-p "DATABASE_ENGINE") "DATABASE_%s"
                     "DATABASES['default']['%s']")))
    (if (comint-check-proc buffer-name)
        (pop-to-buffer buffer-name)
      (flet ((db-setting (name) (pony-get-setting (format db-format name)))
             ;; Rebind sql-get-login so that sql-product-interactive
             ;; doesn't try to prompt the user.
             (sql-get-login (&rest what)))
        (let* ((db-engine (db-setting "ENGINE"))
               (engine (car (last (split-string db-engine "\\."))))
               (sql-product
                (loop for product in sql-product-alist
                      if (search (symbol-name (car product)) engine)
                      return (car product)
                      finally do
                      (error "Don't know how to connect to %s" engine)))
               (sql-user (db-setting "USER"))
               (sql-password (db-setting "PASSWORD"))
               (sql-database (db-setting "NAME"))
               (sql-server (db-setting "HOST")))
          (sql-product-interactive)
          (when (pony-pop "*SQL*")
            (rename-buffer buffer-name t)))))))

pony-test throws "Search failed" error if point is not after method

I opened my file tests.py and ran the pony-test command (C-c C-p t). It threw the error:

Search failed: "\\(def\\)"

That's because pony-get-func looks like this:

(defun pony-get-func()
  "Get the function currently at point"
  (save-excursion
    (if (search-backward-regexp "\\(def\\)")
        (if (looking-at "[ \t]*[a-z]+[\s]\\([a-z_]+\\)\\>")
            (buffer-substring (match-beginning 1) (match-end 1))
          nil))))

Comments on this code:

  1. The function search-backward-regexp is interactive, so if it fails to find what it's looking for, it throws an error. You need re-search-backward instead (passing t for the noerror argument).
  2. The nested if forms are unnecessary. The usual Lisp idiom for if-then-if is to use and.
  3. In Python, def must be the first non-whitespace on the line, but your search finds it anywhere in the line.
  4. The \\(...\\) are unnecessary in the backward search, since you don't use the captured value. Probably you meant \\<...\\> instead, so as to find def as a word.
  5. Having successfully searched backwards for def, we must now be looking at def, so writing [a-z]+ is obscure (since it always matches def).
  6. The string escape sequence \s just turns into a space, so use that instead.
  7. Python function names are allowed to include numbers, so [a-z_]+ will miss some functions.
  8. You can avoid the call to looking-at by combining the two searches into one.
  9. Using match-string is simpler than calling (buffer-substring ...).

There are similar problems in pony-get-class. You could rewrite these functions like so:

(defun pony-get-func ()
  "Return the name of the function before point, or nil if there
are no functions before point."
  (save-excursion
    (when (re-search-backward "^[ \t]*def[ \t]+\\([A-Za-z_][A-Za-z_0-9]*\\)\\>" nil t)
      (match-string 1))))

(defun pony-get-class ()
  "Return the name of the class before point, or nil if there
are no classes before point."
  (save-excursion
    (when (re-search-backward "^[ \t]*class[ \t]+\\([A-Za-z_][A-Za-z_0-9]*\\)\\>" nil t)
      (match-string 1))))

But why not defer this work to the Python Mode function python-current-defun, which already does what you need?

Can't run pony commands from database shell

Description

  1. Run pony-db-shell (C-c C-p d)
  2. In the database shell, run any pony command, for example, pony-shell.
  3. Pony throws the error Opening input file: No such file or directory, /Users/gdr/mysite/myapp/.ponyrc

Analysis

The database shell buffer isn't attached to a file, so it doesn't get a value for dir-local-variables-alist.

Fix

pony-pop has a keyword option for copying dir-local-variables-alist to a new buffer, so use that in pony-db-shell. The only wrinkle is that sql-product-interactive calls pop-to-buffer so we have to wrap it in save-excursion so that pony-pop can access the dir-local-variables-alist in the buffer from which pony-db-shell was run.

          (save-excursion (sql-product-interactive))
          (when (pony-pop "*SQL*" :dirlocals t)
            (rename-buffer buffer-name t)))))))

End of file during parsing (pony-mode.el:78:1)

To reproduce:

$ git clone https://github.com/davidmiller/pony-mode
(in emacs) M-x byte-compile file (pony-mode.el)

Error:
Compiling file /home/mmclark/tools/pony-mode/src/pony-mode.el at Tue Sep 4 09:59:29 2012
pony-mode.el:78:1:Error: End of file during parsing

Looking at the source, it appears there's a missing closing paren on line 79 of src/pony-mode.el:

78: (defcustom pony-tpl-indent-moves nil
79: "Should TAB move (point) ? if set to t, TAB will move (point)."

{% comment %} tag freezes emacs

After many tries, I think I've identified that using {% comment %} template tag with pony-mode freezes emacs.
Any one can reproduce?

"Unknown command: 'shell_plus'"

For some reason, every time I try to run the shell (or to start the server) I get an "Unknown command: 'shell_plus'" or "Unknown command: 'server_plus'" error

django-extensions is installed and running python manage.py shell_plus in a terminal works just fine...

After messing around a lot, I think the problem could be that pony-mode cannot find my settings file. I'm a bit confused as to what I should put in my .dir-locals.el file for the "settings" key.

If it helps at all, this is my current directory structure:

.
|- .dir-locals.el
|- manage.py
|- static
|- apps
|- |- (all my apps are in here)
|- settings
|- |- local.py
|- |- common.py 

as you can see, my local settings file is in a directory, so I wasn't so sure what my .dir-locals.el file should look like. This is what I have right now:

((nil
(pony-settings .
             (make-pony-project
                :python "/Users/jeannicolas/.virtualenvs/eggs-of-the-day/bin/python"
                :settings "local")
              )
))

I also tried changing :settings to "settings/local" but, no luck... Any help would be appreciated.

pony-rc is over-complicated

The function pony-rc reads as follows:

(defun pony-rc ()
  "Get The settings for the current project.

Read the current pony-project variable from the current buffer's .dir-locals.el"
  (let ((settings
         (if (memq 'pony-settings
                   (mapcar 'first dir-local-variables-alist))
             (cdr (find-if (lambda (x) (equal (first x) 'pony-settings))
                           dir-local-variables-alist))
           ;; For backwards compatibility we also allow ourselves to use .ponyrc
           (eval (pony-read-file (concat (pony-project-root) ".ponyrc"))))))
    (eval settings)))

Four questions:

  1. Why use equal when comparing against a symbol?
  2. Why not use the built-in function assq for looking up a key in an association list?
  3. In the .ponyrc case it looks the contents of the file get evaluated twice. Is this right?
  4. The docstring refers to the pony-project variable but what actually gets looked up is the pony-settings variable. Which is right?

If the double evaluation is wrong, the function could be rewritten like this:

(defun pony-rc ()
  "Get the settings for the current project.

Evaluate the pony-settings variable from the directory-local variables,
or if it does not exist, load .ponyrc instead."
  (eval (cdr (or (assq 'pony-settings dir-local-variables-alist)
                 (cons nil (pony-read-file (concat (pony-project-root) ".ponyrc")))))))

support tab completion if using shell with ipython

If having iPython installed django's 'shell' command automatically makes use of it. Unfortunately in pony-mode one of my favorite features there doesn't work: auto completion of vars, classes, methods and so on.

pony-runserver command does not work with Django 1.4 default project structure

In the Django 1.4 default project structure, I can not seem to get the pony-runserver command to work.

Contents of *pony-server* buffer:

Traceback (most recent call last):
  File "... sbr-regesten/manage.py", line 10, in 
    execute_from_command_line(sys.argv)
  File "/home/user/.virtualenvs/proj/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/home/user/.virtualenvs/softproj/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/user/.virtualenvs/softproj/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 252, in fetch_command
    app_name = get_commands()[subcommand]
  File "/home/user/.virtualenvs/softproj/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 101, in get_commands
    apps = settings.INSTALLED_APPS
  File "/home/user/.virtualenvs/softproj/local/lib/python2.7/site-packages/django/utils/functional.py", line 184, in inner
    self._setup()
  File "/home/user/.virtualenvs/softproj/local/lib/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/user/.virtualenvs/softproj/local/lib/python2.7/site-packages/django/conf/__init__.py", line 93, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/home/user/.virtualenvs/softproj/local/lib/python2.7/site-packages/django/utils/importlib.py", line 29, in import_module
    raise TypeError("relative imports require the 'package' argument")
TypeError: relative imports require the 'package' argument

Process ponyserver exited abnormally with code 1

General information:

  • Emacs 24.2.1
  • pony-mode from GitHub (f104732)

Project structure:
.
├── .dir-locals.el
├── .gitignore
├── manage.py
├── regesten_webapp
│   ├── admin.py
│   ├── init.py
│   ├── models.py
│   ├── tests.py
│   ├── utils.py
│   └── views.py
├── sbr_regesten
│   ├── init.py
│   ├── settings.py
│   ├── urls.py
│   ├── wsgi.py

Contents of manage.py (as generated by Django):

#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sbr_regesten.settings")

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)

Contents of .dir-locals.el:

((nil

  (pony-settings . (make-pony-project
                    :python "/home/user/.virtualenvs/proj/bin/python"
                    :settings "sbr_regesten.settings")
)))

I've tried several other values for the :settings option in .dir-locals.el (the most sensical one being just "settings"), to no avail. Letting pony-mode figure things out by itself by removing .dir-locals.el did not help either.


The only way to make the command work was to

  • symlink to the settings file from the top level of the project:
    .
    ├── .dir-locals.el
    ├── manage.py
    ├── regesten_webapp
    │ ├── ...
    ├── sbr_regesten
    │ ├── settings.py
    │ ├── ...
    ├── settings.py -> ./sbr_regesten/settings.py
  • change the second argument to os.environ.setdefault in manage.py from "sbr_regesten.settings" to "settings"

With this configuration, the pony-runserver command itself works fine even if I remove .dir-locals.el completely -- BUT the app is unusable in the browser because Django keeps looking for the wrong tables in the database.


My Elisp skills are limited, but based on a quick glance over pony-mode.el I'm assuming that this is not the intended behavior, which is why I'm posting this issue.

Best,
Jeyd

Virtualenv support

I am working on my Django projects within a virtualenv environment, and pony-mode uses the system's libraries not the ones from the virtualenv.
I have to manually start Emacs from the virtualenv so pony-mode can find the right Python libraries.

Would it make sense to add virtualenv support to pony-mode?

Typo in README.rst

For me

(pony-make-project :python "some/path")

as mentioned in README.rst didn't work, but

(make-pony-project :python "some/path")

does.

Indentation Issues

I don't know if I should file two separate issues or not. I intuit they are relaed

First issue about indentation

<ul class="nav pull-right">
  {% if user.is_authenticated %}
  <li><a href="/register/">Regístrate</a></li>
  {% else %}
    <li><a href="/register/">Regístrate</a></li>
  <li><a href="/login/">Login</a></li>
{% endif %}
</ul>

When it should look like this

<ul class="nav pull-right">
  {% if user.is_authenticated %}
  <li><a href="/register/">Regístrate</a></li>
  {% else %}
    <li><a href="/register/">Regístrate</a></li>
    <li><a href="/login/">Login</a></li>
  {% endif %}
</ul>

Althought it correctly indendents this

{% if user.is_authenticated %}
  <ul class="nav pull-right">      
      <li><a href="/register/">Regístrate</a></li>
  </ul>
{% else %}
  <ul class="nav pull-right">
    <li><a href="/register/">Regístrate</a></li>
    <li><a href="/login/">Login</a></li>
  </ul>
{% endif %}

The second issue is that pony-mode doesn't indent and prevents HTML-mode to indent if there are no characters on the line. Not even ctrl-j works.

Template syntax highlighting?

Syntax highlighting for templates looks the same as the usual html-mode, which is to say, template-tags aren't prettyfied.

Screenshot

Pony is on my path, required, and is being activated in the correct buffers. Am I missing something?

Pass environment variables to manage.py through local variables

I need to be able to send some environment variables (locations of certain resources, modifications of the PYTHONPATH, etc) into manage.py. I could see two ways to do this: local variables or through some sort of hook that modifies the state before the actual python process is started.

I've started looking at it, but I'm not familiar enough with how comint works to know how to modify the environment before the process starts. So my request is either to have such a feature or some strong pointers on how to do this myself so I can provide a patch. :)

Snippet directory var definition causes problems with el-get

I've been trying to create an el-get recipe to install pony-mode, but there are runtime problems because of the snippets directory. pony-mode gets installed inside ~/.emacs.d/el-get/pony-mode/, but instead of looking for snippets in el-get/pony-mode/snippets/, it's looking in el-get/snippets/.

The problem seems to be the pony-snippet-dir variable definition in https://github.com/davidmiller/pony-mode/blob/master/pony-mode.el#L811. Is it possible to modify this definition so that it fixes the problem, or alternatively could pony-mode be made to work with an external definition for the snippet dir that could be customized after requiring pony-mode? Something like this:

(require 'pony-mode)
(setq pony-mode-snippet-dir "~/.emacs.d/el-get/pony-mode/snippets")

The el-get recipe I'm using:

(:name pony-mode
       :website "https://github.com/davidmiller/pony-mode"
       :description "A Django mode for Emacs."
       :type git
       :url "https://github.com/davidmiller/pony-mode"
       )

compiling issue

Can someone explain how to compile the file on step 2? I'm new to Emacs...
thanks in advance

pony-comint-pop: Symbol's value as variable is void: dir-local-variables-alist

I have just installed pony-mode on ubuntu 10.04, django 1.4.2 (set up in virtualenv).

I am getting this error when trying to run Django shell in the buffer [C-c C-p s] or when trying to launch Pony shell:
pony-comint-pop: Symbol's value as variable is void: dir-local-variables-alist

I am do not know any lisp to know whether it is an issue, or it's me missing something.
I used python-mode.el for years and was looking for something to evaluate code from the buffer to the django shell. I would appreciate any help on the matter.

pony-south-schemamigration throws an error if run from non-file buffer

Description

  1. Run the command pony-runserver (C-c C-p r).
  2. Run the command pony-south-schemamigration.
  3. The command throws the error Wrong type argument: char-or-string-p, nil

Analysis

pony-get-app uses the file name of the current buffer in order to guess the name of the app. This doesn't work in buffers like *ponyserver* because the buffer is not associated with a file. It would be a good idea to try default-directory if buffer-file-name is nil.

Fix

I took the opportunity to make the following additional improvements:

  1. pony-get-app doesn't need an autoload cookie, because it's not interactive and so does not need to be called before pony-mode.el has been loaded.
  2. It's overkill to create a temporary buffer just to do a regexp match. Simpler to use string-match.
  3. An app name might include underscores.
  4. If the project root contains regular expression metacharacters, the match will fail. Need to use regexp-quote for safety.

And here's the result:

(defun pony-get-app ()
  "Return the name of the current app, or nil if no app found."
  (let* ((root (pony-project-root))
         (re (concat "^" (regexp-quote root) "\\([A-Za-z_]+\\)/"))
         (path (or buffer-file-name (expand-file-name default-directory))))
    (when (string-match re path)
      (match-string 1 path))))

Key bindings tweaks

When I do C-c p r and a *ponyserver* buffer already exists instead show a error message saying a server is already running it should show the buffer *ponyserver* (as happens to a start a server).

Inside the *ponyserver*, the key binding C-c p r should restart the server.

I suppose it is a good behavior since I find similar ones in many Emacs stuff.

Consider the same suggestion above to C-c p s.

Thank you!

Pony startproject

It would be neat to be able to start a fresh project with pony-startproject .

As of the minute this fails because we don't know to look for django-admin.py

pony-test throws an error if the current function has a short name

Suppose I have a file containing the following:

def foo():
    pass

I place point at the end of the file and run pony-test (C-c C-p t). This throws an error:

Args out of range: #("foo" 0 3 (fontified t face font-lock-function-name-face)), 0, 4

The culprit is the call to (string= "test" (substring func 0 4)) — this throws an error if func has fewer than four characters.

A more robust way to write this test would be (string-match "^test" func).

Do not use .ponyrc but .dir-locals.el

Emacs already provide a directory based configuration. Currently I have to keep both (.dir-locals.el and .ponyrc).

.dir-locals.el example:

((nil . ((pony-mode . t)
         (pony-python-command . "/path/to/python"))))

Settings in .dir-locals.el require .ponyrc

Hi,
I configured the .dir-locals.el as described in the README:
((nil
(pony-settings .
(make-pony-project
:python "/home/user/Envs/dev/bin/python"
:settings "settings_local")
)
))

But when I do C-c C-p r Emacs tells me that the file .ponyrc could not be found.
Is there something wrong?

Best Jacques

pony-tpl-mode doesn't highlight syntax unless nxhtml autostart.el has been loaded

I just removed nxhtml mode from my init file in favor of using pony-tpl-mode. When I load my init file with the nxhtml autostart load script commented out, and then open a django template, I'm unable to get syntax highlighting with pony-tpl-mode to work. However, when I load the nxhtml autoload file and then open a template, pony-tpl-mode is fully activated and syntax highlighting works just fine. Kind of strange to me, as nxhtml-mode (or anything it requires) didn't seem to be a requirement for pony-mode.

This is the line in my init.el file that loads nxhtml-mode.
(load-file "~/.emacs.d/plugins/nxhtml/autostart.el")

I'm using emacs version 24.0.94.1, nxhtml-mode 2.08 (the most recent version), and pony-mode from HEAD.

Template indentation is wrong when there are multiple tags on a line

Open the following template in pony-tpl-mode:

<img>
{% block foo %}{% endblock %}
<img>

and indent the whole file (C-x h C-M-\). The result is as follows:

<img>
{% block foo %}{% endblock %}
  <img>

with the second <img> incorrectly indented. This is because pony-calculate-indent-backward recognizes that the {% block foo %} starts an indented block but does not recognize that the {% endblock %} closes that block.

The indentation calculation needs to look at all tags on a line, not just the first tag.

Pony Runserver broken when using nonstandard manage.py

I've modified my app and the manage.py to allow for using multiple settings files. This way I can set one for development and one for production. However, this does not work with pony-runserver

The issue seems to be in the pony-manage-pop function where the --settings= option is added, rather than allowing manage.py to figure it out. Perhaps this could be conditionally added?

load-file-name might be nil

M-x eval-buffer RET

of pony-mode.el results in error below..

replacing load-file-name by
(or load-file-name default-directory)
should fix it.

;;;;;;;;;;;;

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
file-name-directory(nil)
(concat (file-name-directory load-file-name) "./snippets")
(expand-file-name (concat (file-name-directory load-file-name) "./snippets"))
eval((expand-file-name (concat (file-name-directory load-file-name) "./snippets")))
custom-initialize-reset(pony-snippet-dir (expand-file-name (concat (file-name-directory load-file-name) "./snippets")))
custom-declare-variable(pony-snippet-dir (expand-file-name (concat (file-name-directory load-file-name) "./snippets")) "Directory in which to locate Yasnippet snippets for Pony Mode" :group pony :type string)
eval-buffer() ; Reading at buffer position 2245
call-interactively(eval-buffer record nil)
command-execute(eval-buffer record)
execute-extended-command(nil "eval-buffer")
call-interactively(execute-extended-command nil nil)
command-execute(execute-extended-command)

Make TAGs include Python, CSS, JS, HTML files

I tried replacing the find command with the following:

find . -path '/migrations' -prune -o -type f ( -name '.py' -o -name '.html' -o -name '.css' -o -name '*.js' ) -print | xargs etags

but it didn't have any effect. Outside emacs, the code works. (I'm excluding the migrations dir to exclude south migration files).

Thanks,

Ustun

Support for prefix to ignore for app finding

In my company's django project, we have all of our apps in an "apps" directory. The pony-get-app function always returns apps rather than "integration" or what-have-you. This was my solution for it.

;; should probably be customization field?
(setq pony-app-dir-prefix "apps")

(defun pony-get-app ()
  "Return the name of the current app, or nil if no app
found. Corrects for excluded prefix."
  (let* ((root (pony-project-root))
     (excluded-prefix (if (nil-blank-string pony-app-dir-prefix)
                  (concat root pony-app-dir-prefix "/")
                root))
         (re (concat "^" (regexp-quote excluded-prefix) "\\([A-Za-z_]+\\)/"))
         (path (or buffer-file-name (expand-file-name default-directory))))
    (when (string-match re path)
      (match-string 1 path)))))

Virtualenv support

It would be wonderful to have support for virtualenv.

Here's how other's do it. There's currently a virtualenv.el but that has an external dependency on virtualenvwrapper. nose.el has a hack where you can define nose-project-names to point to a wrapper script that activates virtualenv.

The problem with virtualenv.el is that it should be called virtualenvwapper.el. ;)

The problem with nose.el is that you have to customize every project, which is tedious and repetitive, and doesn't support changing envs mid-ship. Out of the box nose also doesn't run django tests well.

I should add that the new python mode [0] claims to have support for virtualenv, so maybe that is the way to go, since it will presumably be merged into emacs and be the defacto python mode.

For now I'm using M-x shell to activate my env and run my tests .....

0 - https://github.com/fgallina/python.el

pony-indent does not place point at end of indentation

If you press tab in pony-tpl-mode, the point does not travel to the end of indentation because of the save-excursion. This save-excursion is not needed, because we want the point to move.

It should be implemented like this:

(defun pony-indent ()
  "Indent current line as Jinja code"
  (interactive)
  (beginning-of-line)
  (let ((indent (pony-calculate-indent)))
    (if (< indent 0)
        (setq indent 0))
    (indent-line-to indent)))

pony-test doesn't know whether a function belongs to a class or not

Suppose I have a file containing the code:

class Test(TestCase):
    pass

def test_foo():
    pass

I place point at the end of the file and run pony-test (C-c C-p t). The prompt that appears is

test: mysite.Test.test_foo

but this is not a suitable default to offer as test_foo is not a method on the Test class.

Template tags are not all highlighted

Not all of Django's built-in template tags are highlighted when visiting a file in pony-tpl-mode. Tags that are not highlighted include autoescape, blocktrans, csrf_token, empty, and with.

Repository Layout Query

I am a maintainer of melpa and we want to include a full-featured version of this package but due to restriction in how we currently package things, we have some restrictions on how files should be organized. The main reason is to make it easier for people to create new packages rather than making the packaging more complex.

So I just am writing to see what the reason for putting your package files in the src/ directory is as opposed to putting them directly in the root of the project and/or putting snippets/ under the src/ directory.

Basically, the package creation process looks for a common subdirectory path for all files in the package but it breaks in this instance.

I have added the package but it doesn't currently include the snippets which I would definitely like to add. Anyways, seeing if you had opinion or input. Not so much how we could change our end---cause we know how to do that---but rather to maybe see your reaction to that possibility.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.