Commits

Toby Davies committed 9b6a3e4

added python awesomeness to emacs

Comments (0)

Files changed (3)

 (push "~/.emacs.d" load-path)
 
 (require 'thingatpt)
-(require 'ipython)
+;(require 'ipython)
+(require 'flymake)
+(require 'flymake-cursor)
 (require 'mediawiki)
 (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
 (add-to-list 'auto-mode-alist '("\\.pl\\'" . prolog-mode))
   'action 'button-woman
   'follow-link t)
 
+(load "flymake-cursor")
+
+(defun flymake-pyflakes-init ()
+  (let* ((temp-file (flymake-init-create-temp-buffer-copy
+		     'flymake-create-temp-inplace))
+	 (local-file (file-relative-name
+		      temp-file
+		      (file-name-directory buffer-file-name))))
+    (list "pycheck"  (list local-file))))
+(add-to-list 'flymake-allowed-file-name-masks
+             '("\\.py\\'" flymake-pyflakes-init))
+
 (defun woman-at-point ()
   (interactive)
   (message (symbol-name (symbol-at-point)))

.emacs.d/flymake-cursor.el

+;; -*- emacs-lisp -*-
+;; License: Gnu Public License
+;;
+;; Additional functionality that makes flymake error messages appear
+;; in the minibuffer when point is on a line containing a flymake
+;; error. This saves having to mouse over the error, which is a
+;; keyboard user's annoyance
+
+;;flymake-ler(file line type text &optional full-file)
+(defun show-fly-err-at-point ()
+  "If the cursor is sitting on a flymake error, display the
+message in the minibuffer"
+  (interactive)
+  (let ((line-no (line-number-at-pos)))
+    (dolist (elem flymake-err-info)
+      (if (eq (car elem) line-no)
+	    (let ((err (car (second elem))))
+	          (message "%s" (fly-pyflake-determine-message err)))))))
+
+(defun fly-pyflake-determine-message (err)
+  "pyflake is flakey if it has compile problems, this adjusts the
+message to display, so there is one ;)"
+  (cond ((not (or (eq major-mode 'Python) (eq major-mode 'python-mode) t)))
+	((null (flymake-ler-file err))
+	  ;; normal message do your thing
+	  (flymake-ler-text err))
+	(t ;; could not compile err
+	  (format "compile error, problem on line %s" (flymake-ler-line err)))))
+
+(defadvice flymake-goto-next-error (after display-message activate compile)
+  "Display the error in the mini-buffer rather than having to mouse over it"
+  (show-fly-err-at-point))
+
+(defadvice flymake-goto-prev-error (after display-message activate compile)
+  "Display the error in the mini-buffer rather than having to mouse over it"
+  (show-fly-err-at-point))
+
+(defadvice flymake-mode (before post-command-stuff activate compile)
+  "Add functionality to the post command hook so that if the
+cursor is sitting on a flymake error the error information is
+displayed in the minibuffer (rather than having to mouse over
+it)"
+  (set (make-local-variable 'post-command-hook)
+       (cons 'show-fly-err-at-point post-command-hook)))
+
+(provide 'flymake-cursor)
 #!/usr/bin/zsh
 pyflakes "$1"
 pep8 --ignore=E221,E701,E202 --repeat "$1"
+pylint "$1"
 true
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.