GNU bug report logs - #4310
Flymake standardizing(slightly) patch

Previous Next

Package: emacs;

Reported by: Jimmy Yuen Ho Wong <wyuenho <at> gmail.com>

Date: Wed, 2 Sep 2009 05:30:04 UTC

Severity: wishlist

Tags: patch

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 4310 in the body.
You can then email your comments to 4310 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4310; Package emacs. (Wed, 02 Sep 2009 05:30:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jimmy Yuen Ho Wong <wyuenho <at> gmail.com>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Wed, 02 Sep 2009 05:30:04 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Jimmy Yuen Ho Wong <wyuenho <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Flymake standardizing(slightly) patch
Date: Wed, 02 Sep 2009 01:25:48 -0400
[Message part 1 (text/plain, inline)]
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.
[flymake.el.patch (text/plain, inline)]
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))))
 

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4310; Package emacs. (Thu, 03 Sep 2009 06:05:08 GMT) Full text and rfc822 format available.

Message #8 received at 4310 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Jimmy Yuen Ho Wong <wyuenho <at> gmail.com>
Cc: 4310 <at> debbugs.gnu.org
Subject: Re: bug#4310: Flymake standardizing(slightly) patch
Date: Thu, 03 Sep 2009 02:02:05 -0400
Jimmy Yuen Ho Wong wrote:

> I've added a default keymap and a minor-mode hook to flymake

With regards to the hook part, it already runs flymake-mode-hook, as
you can see eg by:

(add-hook 'flymake-mode-hook (lambda () (error "foo")))

The define-minor-mode macro takes care of this. There is no need for a
hook to be defvar'd before use.



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4310; Package emacs. (Thu, 03 Sep 2009 12:30:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jimmy Yuen Ho Wong <wyuenho <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Thu, 03 Sep 2009 12:30:05 GMT) Full text and rfc822 format available.

Message #13 received at 4310 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Jimmy Yuen Ho Wong <wyuenho <at> gmail.com>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 4310 <at> debbugs.gnu.org
Subject: Re: bug#4310: Flymake standardizing(slightly) patch
Date: Thu, 03 Sep 2009 08:23:31 -0400
Ah right. I missed that part of the documentation. Noob mistake.

However, this brings me to a question, since all the initialization is 
essentially done before flymake finally runs syntax check at the end of 
the minor mode definition. If I want to run the minor mode hook before 
syntax check, but not after, what should I do?

Also, I'd imagine some people might want to do something after syntax 
check is done too, like echoing to the minibuffer, or automatically jump 
to the first line of error etc. That means I should probably add a 
post-syntax-check hook. But it seems rather complicated due to the 
number of cases in which it may fail. Any suggestions?


Glenn Morris wrote:
> Jimmy Yuen Ho Wong wrote:
> 
>> I've added a default keymap and a minor-mode hook to flymake
> 
> With regards to the hook part, it already runs flymake-mode-hook, as
> you can see eg by:
> 
> (add-hook 'flymake-mode-hook (lambda () (error "foo")))
> 
> The define-minor-mode macro takes care of this. There is no need for a
> hook to be defvar'd before use.



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4310; Package emacs. (Thu, 03 Sep 2009 15:35:24 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Thu, 03 Sep 2009 15:35:24 GMT) Full text and rfc822 format available.

Message #18 received at 4310 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Jimmy Yuen Ho Wong <wyuenho <at> gmail.com>
Cc: 4310 <at> debbugs.gnu.org, Glenn Morris <rgm <at> gnu.org>
Subject: Re: bug#4310: Flymake standardizing(slightly) patch
Date: Thu, 03 Sep 2009 09:43:42 -0400
> However, this brings me to a question, since all the initialization is
> essentially done before flymake finally runs syntax check at the end of the
> minor mode definition. If I want to run the minor mode hook before syntax
> check, but not after, what should I do?

Change flymake-mode to offer this functionality.  Maybe one way to do
that is to move the (flymake-start-syntax-check) to after flymake-mode
is over.  E.g. by running it via run-with-timer.

> Also, I'd imagine some people might want to do something after syntax check
> is done too, like echoing to the minibuffer, or automatically jump to the
> first line of error etc. That means I should probably
> add a post-syntax-check hook.

Yes, that would probably be a good addition.

> But it seems rather complicated due to the number of cases in which it
> may fail.  Any suggestions?

No, you'll have to study the code and/or reorganize it until you feel
comfortable doing it.


        Stefan




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4310; Package emacs. (Fri, 04 Sep 2009 05:20:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Kevin Rodgers <kevin.d.rodgers <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Fri, 04 Sep 2009 05:20:04 GMT) Full text and rfc822 format available.

Message #23 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Kevin Rodgers <kevin.d.rodgers <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#4310: Flymake standardizing(slightly) patch
Date: Thu, 03 Sep 2009 23:13:02 -0600
Glenn Morris wrote:
> There is no need for a
> hook to be defvar'd before use.

No need by Emacs/Lisp, but for the user's sake.

-- 
Kevin Rodgers
Denver, Colorado, USA





Severity set to 'wishlist' from 'normal' Request was from Glenn Morris <rgm <at> gnu.org> to control <at> emacsbugs.donarmstrong.com. (Fri, 04 Sep 2009 16:35:05 GMT) Full text and rfc822 format available.

Added tag(s) patch. Request was from Dan Nicolaescu <dann <at> ics.uci.edu> to control <at> debbugs.gnu.org. (Sun, 20 Dec 2009 15:59:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#4310; Package emacs. (Sun, 28 Feb 2016 06:45:01 GMT) Full text and rfc822 format available.

Message #30 received at 4310 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Jimmy Yuen Ho Wong <wyuenho <at> gmail.com>
Cc: 4310 <at> debbugs.gnu.org
Subject: Re: bug#4310: Flymake standardizing(slightly) patch
Date: Sun, 28 Feb 2016 17:44:22 +1100
Jimmy Yuen Ho Wong <wyuenho <at> gmail.com> writes:

> 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.

[...]

> +(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.")

As Glenn said, the hook isn't needed, but I think the minor mode map
might make sense.

I've never used flymake, though, so I can't really say.  Anybody?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#4310; Package emacs. (Thu, 27 Jun 2019 17:53:02 GMT) Full text and rfc822 format available.

Message #33 received at 4310 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Jimmy Yuen Ho Wong <wyuenho <at> gmail.com>
Cc: 4310 <at> debbugs.gnu.org
Subject: Re: bug#4310: Flymake standardizing(slightly) patch
Date: Thu, 27 Jun 2019 19:52:08 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

>> +(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.")
>
> As Glenn said, the hook isn't needed, but I think the minor mode map
> might make sense.
>
> I've never used flymake, though, so I can't really say.  Anybody?

Didn't seem to be much enthusiasm for this over the years, so it seems
unlikely that progress will be made, and I'm closing this bug report.
Please reopen if somebody wants to add that keymap...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug closed, send any further explanations to 4310 <at> debbugs.gnu.org and Jimmy Yuen Ho Wong <wyuenho <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 30 Jun 2019 21:54:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 29 Jul 2019 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 284 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.