Posts Tagged ‘lisp’

Quick Access to .dotfiles in Emacs

Monday, August 1st, 2011

For those moments when you want fast access to “~/.something” – what nicer than M-x .thatsomething

(defmacro dotfile (filename)
  "Define the function `filename' to edit the dotfile in question"
  (let ((filestr (symbol-name filename)))
    `(progn
       (defun ,(intern filestr) ()
         ,(format "Open %s for editing" filestr)
         (interactive)
         (find-file ,(concat "~/" filestr))))))

With which we can define a M-x .emacs function with:

(dotfile .emacs)

Love regards etc

Announcing Pony Mode – a Django editing mode for Emacs

Saturday, May 28th, 2011

I’m pleased to announce the first beta ‘release’ of Pony Mode, a minor mode for working on Django projects in Emacs.

This mode provides integration with the django management commands within emacs, as well as test integration, a minor-mode with syntax highlighting for editing templates, will determine whether you are using Fabric or Buildout, as well as much more!

This mode is under active development, so please file any bugs at the Github page, and feel free to provide any feedback/feature requests etc.

Current features include:

  • 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
  • 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]

Grab it while it’s hot!

Mass buffer revert in emacs

Saturday, May 21st, 2011

One of the problems with doing branchy development in Emacs is that when you have lots of files open and then switch branches, the bufer contents stay on the previous branch. Thankfully Emacs will warn you that the file’s contents have changed before you edit/save the file, but calling M-x revert-buffer on lots of open files gets old very fast.

This being Emacs though, the natural solution to any irritation is to program your way out of it. M-x regexp-revert let’s you enter a regexp, and then reverts any buffer with a file location matching that regexp to the file’s current state on disk.

(defun regexp-revert (regexp)
  "Revert all buffers whose path matches regexp"
  (interactive "sPath Regexp: ")
  (dolist (buffer (buffer-list))
    (if (string-match-p regexp (or (buffer-file-name buffer) ""))
        (progn
          (set-buffer buffer)
          (revert-buffer nil t)
          (message "Reverting %s" (buffer-file-name buffer))))))

Love regards etc