0

I was using fortran-mode for some time without problem, but recently the bindings M-f and M-b stopped working.

It seems that they are not bound to the forward-word and backward-word moving commands anymore, but instead to some commands defined in a file called ftnchek.el (this is what C-h k told me about them), which is apparently a "fortran 77 syntax and semantics checker". In this file, I found these:

    ; I'm not sure I like these but nobody's complaining.
    (define-key fortran-mode-map "\C-x`" 'ftnchek-next-error)
    (define-key fortran-mode-map "\M-s" 'ftnchek-subprogram)
    (define-key fortran-mode-map "\M-b" 'ftnchek-buffer)
    (define-key fortran-mode-map "\M-p" 'ftnchek-previous-subprogram)
    (define-key fortran-mode-map "\M-n" 'ftnchek-next-subprogram)
    (define-key fortran-mode-map "\M-f" 'ftnchek-first-executable)
    (define-key fortran-mode-map "\M-h" 'ftnchek-what-subprogram)

which I think causes the problem.

So I have two questions:

  1. Why do you think these keybindings were working just like in text-mode for some time and then started to run the above checking functions?

  2. What do you think is the best to do to have the classical behavior of M-f and M-b, while still accessing the above checking functions? If you think I should modify the part of ftnchek.el I am displaying above, do you have any suggestions on new keybindings?

(Note: I am not able to tag this question with "fortran-mode")

1 Answer 1

1

ftncheck.el is not part of Emacs, so it's part of your config.

If you don't need ftncheck.el then you can just disable it or remove it. Otherwise, you can just remove those keybindings:

(add-hook 'fortran-mode-hook
          (lambda ()
            ;; Use default global binding for M-f and M-b.
            (local-set-key "\M-f" nil)
            (local-set-key "\M-b" nil)))
9
  • Thank you. How is it that it is part of my config while I hadn't heard of ftncheck.el prior to this problem? And one more thing: there is still a problem: I have to manually M-x fortran-mode for the effect of the configuration you suggest to take effect. In other words it doesn't seem to work when I open my file with emacs myfile.f. Any ideas why?
    – Giuseppe
    May 22, 2017 at 15:39
  • It's ftnchek.el and not ftncheck.el, sorry.
    – Giuseppe
    May 22, 2017 at 15:48
  • There is no file whose name starts with ftn in Emacs itself. So it has to come from your config (probably packages you installed or something like that). E.g. maybe because you don't use vanilla Emacs or you use some pre-made config like Prelude or Spacemacs.
    – Stefan
    May 22, 2017 at 17:45
  • As for why you need to call M-x fortran-mode to make it take effect, my best guess is that some part of your config load ftnchek.el "lazily", so it takes place after your hook was run the first time, thus overriding the effect of the first run of the hook (but on the second run, the package isn't re-loaded so the hook's effect stick that time around). Maybe the value of fortran-mode-hook could give us some idea what's going on.
    – Stefan
    May 22, 2017 at 17:49
  • Thanks a lot for all that. The value of fortran-mode-hook is the following:((lambda nil (local-set-key "\346" nil) (local-set-key "\342" nil)) ftnchek-mode) Original value was nil. By the way, could you please tell me what is the best way to "disable" ftnchek.el?
    – Giuseppe
    May 22, 2017 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.