unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#4310: Flymake standardizing(slightly) patch
@ 2009-09-02  5:25 Jimmy Yuen Ho Wong
  2009-09-03  6:02 ` Glenn Morris
  2016-02-28  6:44 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 7+ messages in thread
From: Jimmy Yuen Ho Wong @ 2009-09-02  5:25 UTC (permalink / raw)
  To: bug-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 583 bytes --]

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.

[-- Attachment #2: flymake.el.patch --]
[-- Type: text/plain, Size: 1634 bytes --]

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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#4310: Flymake standardizing(slightly) patch
  2009-09-02  5:25 bug#4310: Flymake standardizing(slightly) patch Jimmy Yuen Ho Wong
@ 2009-09-03  6:02 ` Glenn Morris
  2009-09-03 12:23   ` Jimmy Yuen Ho Wong
  2009-09-04  5:13   ` Kevin Rodgers
  2016-02-28  6:44 ` Lars Ingebrigtsen
  1 sibling, 2 replies; 7+ messages in thread
From: Glenn Morris @ 2009-09-03  6:02 UTC (permalink / raw)
  To: Jimmy Yuen Ho Wong; +Cc: 4310

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.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#4310: Flymake standardizing(slightly) patch
  2009-09-03  6:02 ` Glenn Morris
@ 2009-09-03 12:23   ` Jimmy Yuen Ho Wong
  2009-09-03 13:43     ` Stefan Monnier
  2009-09-04  5:13   ` Kevin Rodgers
  1 sibling, 1 reply; 7+ messages in thread
From: Jimmy Yuen Ho Wong @ 2009-09-03 12:23 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 4310

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.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#4310: Flymake standardizing(slightly) patch
  2009-09-03 12:23   ` Jimmy Yuen Ho Wong
@ 2009-09-03 13:43     ` Stefan Monnier
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2009-09-03 13:43 UTC (permalink / raw)
  To: Jimmy Yuen Ho Wong; +Cc: 4310

> 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






^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#4310: Flymake standardizing(slightly) patch
  2009-09-03  6:02 ` Glenn Morris
  2009-09-03 12:23   ` Jimmy Yuen Ho Wong
@ 2009-09-04  5:13   ` Kevin Rodgers
  1 sibling, 0 replies; 7+ messages in thread
From: Kevin Rodgers @ 2009-09-04  5:13 UTC (permalink / raw)
  To: bug-gnu-emacs

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







^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#4310: Flymake standardizing(slightly) patch
  2009-09-02  5:25 bug#4310: Flymake standardizing(slightly) patch Jimmy Yuen Ho Wong
  2009-09-03  6:02 ` Glenn Morris
@ 2016-02-28  6:44 ` Lars Ingebrigtsen
  2019-06-27 17:52   ` Lars Ingebrigtsen
  1 sibling, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2016-02-28  6:44 UTC (permalink / raw)
  To: Jimmy Yuen Ho Wong; +Cc: 4310

Jimmy Yuen Ho Wong <wyuenho@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





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#4310: Flymake standardizing(slightly) patch
  2016-02-28  6:44 ` Lars Ingebrigtsen
@ 2019-06-27 17:52   ` Lars Ingebrigtsen
  0 siblings, 0 replies; 7+ messages in thread
From: Lars Ingebrigtsen @ 2019-06-27 17:52 UTC (permalink / raw)
  To: Jimmy Yuen Ho Wong; +Cc: 4310

Lars Ingebrigtsen <larsi@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





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-06-27 17:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-02  5:25 bug#4310: Flymake standardizing(slightly) patch Jimmy Yuen Ho Wong
2009-09-03  6:02 ` Glenn Morris
2009-09-03 12:23   ` Jimmy Yuen Ho Wong
2009-09-03 13:43     ` Stefan Monnier
2009-09-04  5:13   ` Kevin Rodgers
2016-02-28  6:44 ` Lars Ingebrigtsen
2019-06-27 17:52   ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).