bug#34294: 27.0.50; flymake-start-on-save-buffer has no effect

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

bug#34294: 27.0.50; flymake-start-on-save-buffer has no effect

Juri Linkov-2
X-Debbugs-CC: João Távora <[hidden email]>

I have flymake-start-on-save-buffer customized to 't' to check syntax
only when a buffer is saved, but it still checks the unfinished work
while edits are in progress, showing the errors that make no sense
until the buffer is saved, even when flymake-start-syntax-check-on-newline
and flymake-start-on-flymake-mode are nil.

Is it possible to customize flymake to kick in only on saving?



Reply | Threaded
Open this post in threaded view
|

bug#34294: 27.0.50; flymake-start-on-save-buffer has no effect

João Távora
On Sat, Feb 2, 2019 at 9:33 PM Juri Linkov <[hidden email]> wrote:
>
> X-Debbugs-CC: João Távora <[hidden email]>
>
> I have flymake-start-on-save-buffer customized to 't' to check syntax
> only when a buffer is saved, but it still checks the unfinished work
> while edits are in progress, showing the errors that make no sense
> until the buffer is saved

They "make sense" if you were to interpret/compile the buffer's
contents at that moment.  It's called fly-make for a reason ;-).

> , even when flymake-start-syntax-check-on-newline
> and flymake-start-on-flymake-mode are nil.
> Is it possible to customize flymake to kick in only on saving?

You can set flymake-no-changes-timeout to nil. See its docstring.

If that works, you can probably close this bug.

--
João Távora



Reply | Threaded
Open this post in threaded view
|

bug#34294: 27.0.50; flymake-start-on-save-buffer has no effect

Juri Linkov-2
>> I have flymake-start-on-save-buffer customized to 't' to check syntax
>> only when a buffer is saved, but it still checks the unfinished work
>> while edits are in progress, showing the errors that make no sense
>> until the buffer is saved
>
> They "make sense" if you were to interpret/compile the buffer's
> contents at that moment.  It's called fly-make for a reason ;-).

I just want flymake to fly a little lower ;-)

>> , even when flymake-start-syntax-check-on-newline
>> and flymake-start-on-flymake-mode are nil.
>> Is it possible to customize flymake to kick in only on saving?
>
> You can set flymake-no-changes-timeout to nil. See its docstring.
>
> If that works, you can probably close this bug.

Thanks, I'll try to set flymake-no-changes-timeout to nil.

Meanwhile, a few additional suggestions:

1. The defcustom definition of flymake-no-changes-timeout
   currently doesn't allow customizing its value to nil,
   because it's type is only 'number.  It could provide
   an option for `nil'.

2. Naming inconsistency - there are following customizable variables:

(defcustom flymake-start-on-flymake-mode t
(defcustom flymake-start-on-save-buffer t
(defcustom flymake-start-syntax-check-on-newline t

The last is unnecessary long and could be simplified to just:

(defcustom flymake-start-on-newline t

Please compare it with another variable already renamed with:

(define-obsolete-variable-alias 'flymake-start-syntax-check-on-find-file
  'flymake-start-on-flymake-mode "26.1")

3. Maybe the documentation could be improved with the docstring of
flymake-start-on-save-buffer having a hint about disabling
flymake-no-changes-timeout?

For example, etc/TODO has such entry:

  ** Flymake's customization mechanism needs to be both simpler (fewer
  levels of indirection) and better documented, so it is easier to
  understand.  I find it quite hard to figure out what compilation
  command it will use.

4. Also I found these related entries in the same etc/TODO file:

  ** Display something in the margin on lines that have compilation errors.

  ** Allow fringe indicators to display a tooltip (provide a help-echo property?)

What do you think about displaying a tooltip on the fringe indicator
with the same text that is displayed on the tooltip over the location
of the error in the source buffer?  It's easier to hover on the fringe
than finding the location in the buffer to hover.



Reply | Threaded
Open this post in threaded view
|

bug#34294: 27.0.50; flymake-start-on-save-buffer has no effect

João Távora
Juri Linkov <[hidden email]> writes:

>>> I have flymake-start-on-save-buffer customized to 't' to check syntax
>>> only when a buffer is saved, but it still checks the unfinished work
>>> while edits are in progress, showing the errors that make no sense
>>> until the buffer is saved
>>
>> They "make sense" if you were to interpret/compile the buffer's
>> contents at that moment.  It's called fly-make for a reason ;-).
>
> I just want flymake to fly a little lower ;-)

OK, no problem.

> 1. The defcustom definition of flymake-no-changes-timeout
>    currently doesn't allow customizing its value to nil,
>    because it's type is only 'number.  It could provide
>    an option for `nil'.

A patch is welcome to to fix this.

> 2. Naming inconsistency - there are following customizable variables:
>
> (defcustom flymake-start-on-flymake-mode t
> (defcustom flymake-start-on-save-buffer t
> (defcustom flymake-start-syntax-check-on-newline t
>
> The last is unnecessary long and could be simplified to just:
>
> (defcustom flymake-start-on-newline t
>
> Please compare it with another variable already renamed with:
>
> (define-obsolete-variable-alias 'flymake-start-syntax-check-on-find-file
>   'flymake-start-on-flymake-mode "26.1")

A second patch is welcome to fix this too.  Please use obsolete variable
aliases, as you suggested.  I trust you will choose good names.

> 3. Maybe the documentation could be improved with the docstring of
> flymake-start-on-save-buffer having a hint about disabling
> flymake-no-changes-timeout?
>
> For example, etc/TODO has such entry:
>
>   ** Flymake's customization mechanism needs to be both simpler (fewer
>   levels of indirection) and better documented, so it is easier to
>   understand.  I find it quite hard to figure out what compilation
>   command it will use.

That is probably obsolete and can be erased.  My flymake.el redesign
should have taken care of that, and is documented in the Flymake info
node.  If you feel it is sufficient documentation, a third patch is
welcome to remove that TODO entry.

> 4. Also I found these related entries in the same etc/TODO file:
>
>   ** Display something in the margin on lines that have compilation
>   errors.

Flymake does this, even though it uses the fringe by default, but I
don't have more clues to what the author of this line intended.

>   ** Allow fringe indicators to display a tooltip (provide a help-echo
>   property?)

I think this is a more generic wish and is not strictly Flymake related.

> What do you think about displaying a tooltip on the fringe indicator
> with the same text that is displayed on the tooltip over the location
> of the error in the source buffer?  It's easier to hover on the fringe
> than finding the location in the buffer to hover.

I don't have any strong opinion. It's fine, I guess, but not
specifically tied to Flymake.  It may be difficult to implement.  BTW
you can use flymake-goto-next-error and flymake-goto-prev-error to
navigate between errors, it's what I use all the time.

So to summarize, it'd be great if you could provide the three patches to
implement the suggestions you gave.

João



Reply | Threaded
Open this post in threaded view
|

bug#34294: 27.0.50; flymake-start-on-save-buffer has no effect

Juri Linkov-2
>> 4. Also I found these related entries in the same etc/TODO file:
>>
>>   ** Display something in the margin on lines that have compilation
>>   errors.
>
> Flymake does this, even though it uses the fringe by default, but I
> don't have more clues to what the author of this line intended.

I guess this is exactly what Flymake already does.

>> What do you think about displaying a tooltip on the fringe indicator
>> with the same text that is displayed on the tooltip over the location
>> of the error in the source buffer?  It's easier to hover on the fringe
>> than finding the location in the buffer to hover.
>
> I don't have any strong opinion. It's fine, I guess, but not
> specifically tied to Flymake.  It may be difficult to implement.

Yes, this is a more general feature.  I could look at how easy it
would be to implement, and later to use in Flymake.

> BTW you can use flymake-goto-next-error and flymake-goto-prev-error to
> navigate between errors, it's what I use all the time.

Thanks for the suggestion.  I could also look how easy to integrate
flymake-goto-next-error into the more general next-error framework that
provides easy to type keybindings.

> So to summarize, it'd be great if you could provide the three patches to
> implement the suggestions you gave.

OK, I'll provide these three patches.  But first please look at my feedback
on your suggestion to set flymake-no-changes-timeout to nil: after trying it,
I see that it helps me, but also it requires setting
flymake-start-syntax-check-on-newline to nil, because otherwise
syntax check is started on an unsaved buffer when yanking text
that contains newlines.



Reply | Threaded
Open this post in threaded view
|

bug#34294: 27.0.50; flymake-start-on-save-buffer has no effect

João Távora
Juri Linkov <[hidden email]> writes:

>>> 4. Also I found these related entries in the same etc/TODO file:
>>>
>>>   ** Display something in the margin on lines that have compilation
>>>   errors.
>>
>> Flymake does this, even though it uses the fringe by default, but I
>> don't have more clues to what the author of this line intended.
>
> I guess this is exactly what Flymake already does.

Then maybe remove it in a fourth patch?

>>> What do you think about displaying a tooltip on the fringe indicator
>>> with the same text that is displayed on the tooltip over the location
>>> of the error in the source buffer?  It's easier to hover on the fringe
>>> than finding the location in the buffer to hover.
>>
>> I don't have any strong opinion. It's fine, I guess, but not
>> specifically tied to Flymake.  It may be difficult to implement.
>
> Yes, this is a more general feature.  I could look at how easy it
> would be to implement, and later to use in Flymake.

Fine by me.  I would personally concentrate efforts elsewhere, but you
get to work whereever you prefer.

>> BTW you can use flymake-goto-next-error and flymake-goto-prev-error to
>> navigate between errors, it's what I use all the time.
>
> Thanks for the suggestion.  I could also look how easy to integrate
> flymake-goto-next-error into the more general next-error framework that
> provides easy to type keybindings.

This would be quite welcome, especially since I think there are
revent improvements to the next-error framework.

Whatever you do to flymake.el, and I forgot to mention this earlier, you
have to make sure it still loads and works in Emacs 26.1, because
flymake.el is also distributed through ELPA.

Fifth patch.

>> So to summarize, it'd be great if you could provide the three patches to
>> implement the suggestions you gave.
>
> OK, I'll provide these three patches.  But first please look at my feedback
> on your suggestion to set flymake-no-changes-timeout to nil: after trying it,
> I see that it helps me, but also it requires setting
> flymake-start-syntax-check-on-newline to nil, because otherwise
> syntax check is started on an unsaved buffer when yanking text
> that contains newlines.

I think flymake-start-syntax-check-on-newline should just be deprecated,
set to nil, and hidden away from the user.  It doesn't make much sense:
I don't see why a newline is different from any other character.  So you
can do this in a sixth patch.

João



Reply | Threaded
Open this post in threaded view
|

bug#34294: 27.0.50; flymake-start-on-save-buffer has no effect

Juri Linkov-2
> Whatever you do to flymake.el, and I forgot to mention this earlier, you
> have to make sure it still loads and works in Emacs 26.1, because
> flymake.el is also distributed through ELPA.

Everything is done in the following patch that doesn't break old versions:


diff --git a/etc/TODO b/etc/TODO
index ccb82cd296..dc594a007e 100644
--- a/etc/TODO
+++ b/etc/TODO
@@ -143,15 +143,6 @@ See the 'test' directory for examples.
 
 * Small but important fixes needed in existing features:
 
-** Flymake's customization mechanism needs to be both simpler (fewer
-levels of indirection) and better documented, so it is easier to
-understand.  I find it quite hard to figure out what compilation
-command it will use.
-
-I suggest totally rewriting that part of Flymake, using the simplest
-mechanism that suffices for the specific needs.  That will be easy
-for users to customize.
-
 ** Distribute a bar cursor of width > 1 evenly between the two glyphs
    on each side of the bar (what to do at the edges?).
 
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index 261e50a613..ddf12328da 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -4,7 +4,7 @@
 
 ;; Author:  Pavel Kobyakov <[hidden email]>
 ;; Maintainer: João Távora <[hidden email]>
-;; Version: 1.0.5
+;; Version: 1.0.6
 ;; Package-Requires: ((emacs "26.1"))
 ;; Keywords: c languages tools
 
@@ -38,10 +38,9 @@
 ;; The main interactive entry point is the `flymake-mode' minor mode,
 ;; which periodically and automatically initiates checks as the user
 ;; is editing the buffer.  The variables `flymake-no-changes-timeout',
-;; `flymake-start-syntax-check-on-newline' and
-;; `flymake-start-on-flymake-mode' give finer control over the events
-;; triggering a check, as does the interactive command
-;; `flymake-start', which immediately starts a check.
+;; `flymake-start-on-newline' and `flymake-start-on-flymake-mode'
+;; give finer control over the events triggering a check, as does the
+;; interactive command `flymake-start', which immediately starts a check.
 ;;
 ;; Shortly after each check, a summary of collected diagnostics should
 ;; appear in the mode-line.  If it doesn't, there might not be a
@@ -178,14 +177,19 @@ flymake-fringe-indicator-position
  (const right-fringe)
  (const :tag "No fringe indicators" nil)))
 
-(defcustom flymake-start-syntax-check-on-newline t
+(define-obsolete-variable-alias 'flymake-start-syntax-check-on-newline
+  'flymake-start-on-newline "27.1")
+
+(defcustom flymake-start-on-newline t
   "Start syntax check if newline char was added/removed from the buffer."
   :type 'boolean)
 
 (defcustom flymake-no-changes-timeout 0.5
   "Time to wait after last change before automatically checking buffer.
-If nil, never start checking buffer automatically like this."
-  :type 'number)
+If nil, never start checking buffer automatically like this.
+You may also want to disable `flymake-start-on-newline'."
+  :type '(choice (number :tag "Timeout in seconds")
+                 (const :tag "No check on timeout" nil)))
 
 (defcustom flymake-gui-warnings-enabled t
   "Enables/disables GUI warnings."
@@ -203,7 +207,7 @@ flymake-start-on-flymake-mode
   :type 'boolean)
 
 (defcustom flymake-start-on-save-buffer t
-  "If non-nil start syntax check when a buffer is saved.
+  "If non-nil, start syntax check when a buffer is saved.
 Specifically, start it when the saved buffer is actually displayed."
   :version "27.1"
   :type 'boolean)
@@ -939,12 +943,11 @@ flymake-mode
 called backends, and visually annotates the buffer with the
 results.
 
-Flymake performs these checks while the user is editing.  The
-customization variables `flymake-start-on-flymake-mode',
-`flymake-no-changes-timeout' and
-`flymake-start-syntax-check-on-newline' determine the exact
-circumstances whereupon Flymake decides to initiate a check of
-the buffer.
+Flymake performs these checks while the user is editing.
+The customization variables `flymake-start-on-flymake-mode',
+`flymake-no-changes-timeout' and `flymake-start-on-newline'
+determine the exact circumstances whereupon Flymake decides
+to initiate a check of the buffer.
 
 The commands `flymake-goto-next-error' and
 `flymake-goto-prev-error' can be used to navigate among Flymake
@@ -1036,7 +1039,7 @@ flymake-after-change-function
 START and STOP and LEN are as in `after-change-functions'."
   (let((new-text (buffer-substring start stop)))
     (push (list start stop new-text) flymake--recent-changes)
-    (when (and flymake-start-syntax-check-on-newline (equal new-text "\n"))
+    (when (and flymake-start-on-newline (equal new-text "\n"))
       (flymake-log :debug "starting syntax check as new-line has been seen")
       (flymake-start t))
     (flymake--schedule-timer-maybe)))