bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#4310: Flymake standardizing(slightly) patch


From: Jimmy Yuen Ho Wong
Subject: bug#4310: Flymake standardizing(slightly) patch
Date: Wed, 02 Sep 2009 01:25:48 -0400
User-agent: Thunderbird 2.0.0.23 (Macintosh/20090812)

Hi Emacs LISPers!

I'm not sure if this issue has been raised before (searching the mailing list comes up nothing), but here it goes:

I was frustrated with the fact that flymake-mode is the one minor-mode that I use often and complicated enough but doesn't come with anyway to extend it with hooks or keymaps. So I've patch the trunk flymake.el to be a little more emacsy.

I've added a default keymap and a minor-mode hook to flymake, I was hoping this will make it into the next Emacs version.

Comments welcome.

Jimmy Yuen Ho Wong

P.S The attached patch is in git format.
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index 69eac56..cbd7dd5 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -1322,12 +1322,30 @@ For the format of LINE-ERR-INFO, see 
`flymake-ler-make-ler'."
   :group 'flymake
   :type 'boolean)
 
+(defvar flymake-prefix-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map "s" 'flymake-start-syntax-check)
+    (define-key map "n" 'flymake-goto-next-error)
+    (define-key map "p" 'flymake-goto-prev-error)
+    (define-key map "m" 'flymake-display-err-menu-for-current-line)
+    map))
+
+(defvar flymake-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map "\C-c;" flymake-prefix-map)
+    map)
+  "The keymap provides the default flymake-mode bindings.")
+
+(defvar flymake-mode-hook nil
+  "Mode hook for `flymake-mode`. This hook is run __before__
+syntax check happens, but after all the initialization is done.")
+
 ;;;###autoload
 (define-minor-mode flymake-mode
   "Minor mode to do on-the-fly syntax checking.
 When called interactively, toggles the minor mode.
 With arg, turn Flymake mode on if and only if arg is positive."
-  :group 'flymake :lighter flymake-mode-line
+  :group 'flymake :lighter flymake-mode-line :keymap flymake-mode-map
   (cond
 
    ;; Turning the mode ON.
@@ -1344,6 +1362,8 @@ With arg, turn Flymake mode on if and only if arg is 
positive."
       (setq flymake-timer
             (run-at-time nil 1 'flymake-on-timer-event (current-buffer)))
 
+      (run-hooks 'flymake-mode-hook)
+
       (when flymake-start-syntax-check-on-find-file
         (flymake-start-syntax-check))))
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]