Emacs: help me solve this problem with auto boot with flymake and csharp

How can I deliver a module that requires a flymake fix, with minimal startup time (= autoload) and minimal impact on the user emacs.el?

I am working on a flymake-for-csharp module. He works with flymake, teaches him how to be more flexible with C # code files. For example, instead of just using makefile, flymake-for-csharp can also use the .csproj file or it can directly call csc.exe.

The module is working fine. Now I am trying to do this automatically.

here is the challenge.

To determine which languages ​​flymake'd gets, flymake.el includes a list of file extensions (.java, .cs, .c, etc.) along with init and cleanup routines for each of these languages. There is an entry for C # in the default flymake.el file, but, as I said, the default C # behavior is not flexible enough. To make it more flexible, I need to replace the C # entry in alm flymake so that it points to the new initialization / cleanup logic in the flymake-for-csharp module. Am I with me?

No problem fixing alist at runtime. It looks like this:

  (let (elt
        (csharp-entry nil)
        (masks flymake-allowed-file-name-masks))

    ;; Find the existing C# entry
    (while (consp masks)
      (setq elt (car masks))
      (if (string= "\\.cs\\'" (car elt))
          (setq csharp-entry elt))
      (setq masks (cdr masks)))

    ;;  remove the original entry for C# ...
    (if csharp-entry
        (setq flymake-allowed-file-name-masks
              (delete csharp-entry flymake-allowed-file-name-masks)))

    ;; Now add a new entry for C#, with the custom init and cleanup methods.
    (setq flymake-allowed-file-name-masks
          (cons
           '("\\.cs\\'" flymake-for-csharp-init flymake-for-csharp-cleanup)
           flymake-allowed-file-name-masks)))

The long-term solution is to convince the authors of flymake and emacs to accept the logic that is currently in flymake-for-csharp. Then alist will get more flexible init / cleanup and bob your uncle routines.

flymake-for-csharp () flymake.el. : flymake-for-csharp, alist?

, emacs.el :

(autoload 'flymake-for-csharp-init "flymake-for-csharp" nil nil)

... (eval-after-load ...

, flymake-for-csharp-init , flymake alist , #.

?


, , (require 'flymake-for-csharp) autoload. flymake-for-csharp , , -, . ? flymake-for-csharp 2 ?

, , eval-after-load flymake.el. . :

  • , flymake ? ​​eval-after-load , , () eval-after-load eval'd?

  • , emacs.el?


, , flymake, (= autoload) emacs.el?

+3
1

, .emacs, :

;;;###autoload
(eval-after-load "flymake" '(code-that-patches-flymake-allowed-file-name-masks))
(autoload 'flymake-for-csharp-init "flymake-for-csharp" nil nil)

, , , loaddefs.el , , ;;;###autoload eval-after-load , loaddefs.el.

, , .emacs.


, , :

(let ((csharpentry (assoc "\\.cs\\'" flymake-allowed-file-name-masks)))
  (when csharpentry
    (setcdr csharpentry '(flymake-for-csharp-init flymake-for-csharp-cleanup))))
+1

Source: https://habr.com/ru/post/1775289/


All Articles