wakatime-mode icon indicating copy to clipboard operation
wakatime-mode copied to clipboard

add proactive language reporting by using major-mode

Open Anton-Latukha opened this issue 3 years ago • 21 comments

Relates to solving the: https://github.com/wakatime/wakatime-mode/issues/37

master algorythm currently provides no info on language, so wakatime does the default - tries to autodetect the languages.

Since:

wakatime --help

...

  --language LANGUAGE   Optional language name. If valid, takes priority over
    auto-detected language.

This patch adds that if case:

  if major-mode name is a valid name to the `--language` option
    then success - language detected
    else waketime uses current default mechanism - tries to autodetect language by itself

What we do is simply: matching https://www.emacswiki.org/emacs/List_Of_Major_And_Minor_Modes#toc2 to https://github.com/wakatime/wakatime/blob/master/wakatime/languages/default.json

In other words: Emacs does: c++-mode -> c++ -> wakatime Wakatime does: c++ -> C++

Profit.

Anton-Latukha avatar Oct 01 '20 15:10 Anton-Latukha

I recommend against merging this as it exists now because it lacks user configuration.

In particular because of https://github.com/wakatime/wakatime-mode/issues/37#issuecomment-702188769

In several situations this will be worse than the current pygments detection.

This major mode name language detection a good idea in general, the implementation just needs some polish to be able to work better.

thomasf avatar Oct 01 '20 15:10 thomasf

@thomasf, please, don't be ridiculous.

Please, read the PR header and its comments in the code before blocking the PR.

Anton-Latukha avatar Oct 01 '20 16:10 Anton-Latukha

Multiple major modes are not supported by Emacs project.

Nobody should support your unofficial hacking system, which officially deprecated by Emacs.

It is if I would launch a decompiler, open ASM, and hack Windows and then should and complain to Microsoft and about Microsoft that they are that they do not support me and my hacks.

Anton-Latukha avatar Oct 01 '20 16:10 Anton-Latukha

I've responded to you in: https://github.com/wakatime/wakatime-mode/issues/37#issuecomment-702234203

Anton-Latukha avatar Oct 01 '20 16:10 Anton-Latukha

Providing info proactively is a be way better and more precise than the use of autodetection.

It is the sole reason #37 exists.

Anton-Latukha avatar Oct 01 '20 16:10 Anton-Latukha

Since in majority of cases this proactive reporting works way better then heuristic autodetection You state:

In several situations this will be worse than the current pygments detection.

Since I refuted one you provided, please can you show valid cases. Where actively sending info that gets checked works worse than sending no info.

Anton-Latukha avatar Oct 01 '20 16:10 Anton-Latukha

@thomasf, please, don't be ridiculous.

Please, read the PR header and its comments in the code before blocking the PR.

if say js2-mode or one of the other examples with the same problem it won't work,. so you don't want to it to be able to work for , It's not a complete solution.

thomasf avatar Oct 01 '20 16:10 thomasf

There is no complete solutions.

Anton-Latukha avatar Oct 01 '20 16:10 Anton-Latukha

Ever.

Anton-Latukha avatar Oct 01 '20 16:10 Anton-Latukha

@thomasf, please, don't be ridiculous. Please, read the PR header and its comments in the code before blocking the PR.

if say js2-mode or one of the other examples with the same problem it won't work,. so you don't want to it to be able to work for , It's not a complete solution.

Jesus, I already responded in https://github.com/wakatime/wakatime-mode/issues/37#issuecomment-702070724, it would ignore the js2 and others and would use the autodetection.

Anton-Latukha avatar Oct 01 '20 16:10 Anton-Latukha

@thomasf, please, don't be ridiculous. Please, read the PR header and its comments in the code before blocking the PR.

if say js2-mode or one of the other examples with the same problem it won't work,. so you don't want to it to be able to work for , It's not a complete solution.

Jesus, I already responded in #37 (comment), it would ignore the js2 and others and would use the autodetection.

Why not just always rely on auto detection then if you don't intend this feature which easily can gain extra features to handle this to have it?

thomasf avatar Oct 01 '20 16:10 thomasf

Do you understand the words "--language LANGUAGE Optional language name. If valid, takes priority over auto-detected language." What part of it you do not understand?

What is "optional" name? Or the word "priority", or "If valid, takes priority".

Anton-Latukha avatar Oct 01 '20 16:10 Anton-Latukha

Do you understand the words "--language LANGUAGE Optional language name. If valid, takes priority over auto-detected language." What part of it you do not understand?

As I understand it this patch is trying to solve the issue where wakatime-cli fails to detect a language, if js2-mode is used and wakatime fails to detect the JS language it will still fail.

I mean it's super easy to add support for a defcustom, I have no idea why you are resisting a more robust internal detection in wakatime-mode.

thomasf avatar Oct 01 '20 16:10 thomasf

I do not understand why you actively trying to block the valid effective solution over some imaginary code.

After this code gets merged - anybody can take this same code add patches with as many defcustoms and functions as they want.

Anton-Latukha avatar Oct 01 '20 16:10 Anton-Latukha

There are such people. Simple, working pragmatic nicely-documented code they do not bother to understand, and while code provided for them for free - that does not satisfies them, and moreover - they complain a lot and expect others to conform to their unreasonable demands.

Anton-Latukha avatar Oct 01 '20 16:10 Anton-Latukha

There is no complete solutions.

I don't think is not complete enough to solve #37 in a way that does not force a new behavior onto users which they might not want and has limitations that it don't work for js2-mode, might even be more wrong than wakatime-cli in multi major mode situations etc.

thomasf avatar Oct 02 '20 03:10 thomasf

Once more, look into basic statement that wakatime makes. This PR does not change the current behaviour in case of js2-mode or multi-major modes (which, once more, - are not supported by Emacs).

You definitely still not read the wakatime documentation and processes.

Anton-Latukha avatar Oct 14 '20 15:10 Anton-Latukha

Statement about js2-mode is a false, because js2 is not a recognized value by wakatime --language option: https://github.com/wakatime/wakatime/blob/master/wakatime/languages/default.json

And if one would take an effort of reading two lines of the official description of --language option is - it explains itself.

Please, read the docs/code and stop repeatedly harassing me and threads and work with same false statements which were explained to you and disproved a number of times already.

Anton-Latukha avatar Oct 14 '20 15:10 Anton-Latukha

I have provided a real world example for one of the most popular modes on melpa here https://github.com/wakatime/wakatime-mode/issues/37#issuecomment-702509731

thomasf avatar Oct 14 '20 15:10 thomasf

I responded to you there.

Still not applicabel example. It does not have intersection with the code and process discussed.

Anton-Latukha avatar Oct 14 '20 15:10 Anton-Latukha

Statement about js2-mode is a false, because js2 is not a recognized value by wakatime --language option

WakaTime uses --language without validation. Currently only Vim modelines are validated in wakatime-cli, otherwise the given --language is sent only with case changes, for ex: c++ -> C++.

alanhamlett avatar Jun 21 '22 06:06 alanhamlett