Skip to content
Browse files

add

  • Loading branch information...
1 parent 3aac98c commit 6eaf1f90911f84fdbad49ac616069ba3c1d6e867 @tavisrudd committed Aug 21, 2012
Showing with 224 additions and 0 deletions.
  1. +100 −0 dss-flymake.el
  2. +24 −0 dss-sh-mode.el
  3. +35 −0 flymake-shell.el
  4. +65 −0 git-modeline.el
View
100 dss-flymake.el
@@ -0,0 +1,100 @@
+(require 'flymake)
+
+(defvar dss-flymake-file-init-func-hash (make-hash-table))
+(defvar dss-flymake-file-cleanup-func-hash (make-hash-table))
+
+(defun flymake-get-init-function (file-name)
+ "Return init function to be used for the file."
+ (let* ((init-f (nth 0 (flymake-get-file-name-mode-and-masks file-name))))
+ ;;(flymake-log 0 "calling %s" init-f)
+ ;;(funcall init-f (current-buffer))
+ (or (gethash file-name dss-flymake-file-init-func-hash) init-f)))
+
+(defun flymake-get-cleanup-function (file-name)
+ "Return cleanup function to be used for the file."
+ (or (gethash file-name dss-flymake-file-cleanup-func-hash)
+ (nth 1 (flymake-get-file-name-mode-and-masks file-name))
+ 'flymake-simple-cleanup))
+
+(defun dss/flymake-ignore ()
+ (interactive)
+ (save-excursion
+ (call-interactively 'comment-dwim)
+ (end-of-line)
+ (insert " flymake-ignore")))
+
+
+(defun dss/flymake-filter-line-err (n)
+ (interactive "nLine: ")
+ (or (loop for ln in flymake-err-info
+ when (not (eq (car ln) n))
+ collect ln)
+ '()))
+(defvar dss-flymake-output-filtered nil)
+
+(defadvice flymake-parse-output-and-residual (before flymake-parse-output-and-residual-before-dss
+ activate)
+ (setq dss-flymake-output-filtered nil)
+ (flymake-report-status "" "")
+ ;ad-do-it
+ )
+(defvar dss-flymake-filtering-on t)
+(defun dss/flymake-toggle-filter ()
+ (interactive)
+ (if dss-flymake-filtering-on
+ (setq dss-flymake-filtering-on nil)
+ (setq dss-flymake-filtering-on t))
+ (flymake-start-syntax-check))
+
+(defadvice flymake-highlight-line (around flymake-highlight-line-around-dss
+ activate)
+ "Ignore lines with flymake-ignore comment"
+ (let ((line-no (ad-get-arg 0))
+ (line-err-info-list (ad-get-arg 1)))
+ (goto-char (point-min))
+ (forward-line (1- line-no))
+ (if (or (not dss-flymake-filtering-on)
+ (not (looking-at ".*flymake-ignore.*$")))
+ ad-do-it
+ (progn
+ (setq dss-flymake-output-filtered t)
+ (setq flymake-check-was-interrupted t)
+ (setq flymake-err-info (dss/flymake-filter-line-err line-no))))))
+
+;; (defadvice flymake-post-syntax-check (around flymake-post-syntax-check-around-dss activate)
+;; ;; (exit-status command)
+;; (if (and dss-flymake-output-filtered
+;; (not flymake-err-info))
+;; (ad-set-arg 0 0))
+;; ad-do-it)
+
+;; (defun flymake-post-syntax-check (exit-status command)
+;; (setq flymake-err-info flymake-new-err-info)
+;; (setq flymake-new-err-info nil)
+;; (setq flymake-err-info
+;; (flymake-fix-line-numbers
+;; flymake-err-info 1 (flymake-count-lines)))
+;; (flymake-delete-own-overlays)
+;; (flymake-highlight-err-lines flymake-err-info)
+;; (let (err-count warn-count)
+;; (setq err-count (flymake-get-err-count flymake-err-info "e"))
+;; (setq warn-count (flymake-get-err-count flymake-err-info "w"))
+;; (flymake-log 2 "%s: %d error(s), %d warning(s) in %.2f second(s)"
+;; (buffer-name) err-count warn-count
+;; (- (flymake-float-time) flymake-check-start-time))
+;; (setq flymake-check-start-time nil)
+
+;; (if (and (equal 0 err-count) (equal 0 warn-count))
+;; (if (equal 0 exit-status)
+;; (flymake-report-status "" "") ; PASSED
+;; (if (not flymake-check-was-interrupted)
+;; (flymake-report-fatal-status "CFGERR"
+;; (format "Configuration error has occurred while running %s" command))
+;; (flymake-report-status nil ""))) ; "STOPPED"
+;; (flymake-report-status (format "%d/%d" err-count warn-count) ""))))
+
+;; (defun flymake-get-real-file-name-function (file-name)
+;; (or (nth 2 (flymake-get-file-name-mode-and-masks file-name))
+;; 'flymake-get-real-file-name))
+
+(provide 'dss-flymake)
View
24 dss-sh-mode.el
@@ -0,0 +1,24 @@
+(require 'flymake-shell)
+(require 'dss-flymake)
+
+(defun dss/sh-electric-pair ()
+ ;; this version doesn't check to see if we're inside of a string or comment
+ (interactive)
+ (let (parens-require-spaces)
+ (insert-pair)))
+
+(defun dss/sh-mode-hook ()
+ (interactive)
+ (define-key sh-mode-map (kbd "C-c v") 'dss/term-source-buffer)
+ (define-key sh-mode-map (kbd "C-x C-e") 'dss/term-eval-region-or-para)
+ (define-key sh-mode-map (kbd "<f4> d") 'dss/term-eval-region-or-para)
+
+ (mapc (lambda (char)
+ (progn
+ (define-key sh-mode-map char 'dss/sh-electric-pair)))
+ '("\"" "'" "(" "[" "{"))
+ (puthash (buffer-file-name) 'flymake-shell-init
+ dss-flymake-file-init-func-hash)
+ (flymake-shell-load))
+(add-hook 'sh-mode-hook 'dss/sh-mode-hook)
+(provide 'dss-sh-mode)
View
35 flymake-shell.el
@@ -0,0 +1,35 @@
+;;; Flymake Shell mode
+;;; http://www.emacswiki.org/emacs/FlymakeShel
+(require 'flymake)
+
+(defcustom flymake-shell-of-choice
+ "/bin/bash"
+ "Path of shell.")
+
+(defcustom flymake-shell-arguments
+ (list "-n")
+ "Shell arguments to invoke syntax checking.")
+
+(defconst flymake-allowed-shell-file-name-masks
+ '(("\\.sh$" flymake-shell-init))
+ "Filename extensions that switch on flymake-shell mode syntax checks.")
+
+(defcustom flymake-shell-err-line-pattern-re
+ '(("^\\(.+\\): line \\([0-9]+\\): \\(.+\\)$" 1 2 nil 3))
+ "Regexp matching JavaScript error messages.")
+
+(defun flymake-shell-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 flymake-shell-of-choice (append flymake-shell-arguments (list local-file)))))
+
+(defun flymake-shell-load ()
+ (setq flymake-allowed-file-name-masks (append flymake-allowed-file-name-masks flymake-allowed-shell-file-name-masks))
+ (setq flymake-err-line-patterns (append flymake-err-line-patterns flymake-shell-err-line-pattern-re))
+ (flymake-mode t)
+ (local-set-key (kbd "C-c d") 'flymake-display-err-menu-for-current-line))
+
+(provide 'flymake-shell)
View
65 git-modeline.el
@@ -0,0 +1,65 @@
+
+
+;;
+;; ref. "test-runner-image.el" posted at
+;; "http://nschum.de/src/emacs/test-runner/"
+;;
+
+(provide 'git-modeline)
+
+(defvar git--state-mark-modeline t) ; modeline mark display or not
+(defvar git--state-mark-tooltip nil) ; modeline tooltip display
+
+(defun git--state-mark-modeline-dot (color)
+ (propertize " "
+ 'help-echo 'git--state-mark-tooltip
+ 'display
+ `(image :type xpm
+ :data ,(format "/* XPM */
+static char * data[] = {
+\"18 13 3 1\",
+\" c None\",
+\"+ c #000000\",
+\". c %s\",
+\" \",
+\" +++++ \",
+\" +.....+ \",
+\" +.......+ \",
+\" +.........+ \",
+\" +.........+ \",
+\" +.........+ \",
+\" +.........+ \",
+\" +.........+ \",
+\" +.......+ \",
+\" +.....+ \",
+\" +++++ \",
+\" \"};"
+ color)
+ :ascent center)))
+
+(defun git--install-state-mark-modeline (color)
+ (push `(git--state-mark-modeline
+ ,(git--state-mark-modeline-dot color))
+ mode-line-format)
+ (force-mode-line-update t))
+
+(defun git--uninstall-state-mark-modeline ()
+ (setq mode-line-format
+ (remove-if #'(lambda (mode) (eq (car-safe mode)
+ 'git--state-mark-modeline))
+ mode-line-format))
+ (force-mode-line-update t))
+
+(defun git--update-state-mark-tooltip (tooltip)
+ (setq git--state-mark-tooltip tooltip))
+
+(defun git--update-state-mark (color)
+ (git--uninstall-state-mark-modeline)
+ (git--install-state-mark-modeline color))
+
+;;
+;; example on state-modeline-mark
+;;
+;; (git--install-state-mark-modeline "red")
+;; (git--uninstall-state-mark-modeline)
+;; (setq git--state-mark-tooltip "testsetset")

0 comments on commit 6eaf1f9

Please sign in to comment.
Something went wrong with that request. Please try again.