Emacs setup for fortran - emacs

I currently work on a big Fortran project with emacs, but I have the feeling that my current setup is inadequate to the task.
I use f90-mode with auto-complete (without fortran-specific setup, so I only have completion for opened files), and I really miss function header information on hover (as in elisp code), code-folding, lists of subroutines in the current buffer, lists of included files, info on the origin of subroutines and used variables (C-xC-f to open the source file?), …
How can I best add modern supporting functionality for fortran in my emacs?
Mostly I need tools which help me understanding the projects code.
The project uses its own build tool and copies files from different directories into a build directory before building, actually overwriting some files with different versions of the code, so I need a quite flexible tool which can cope with that.

There's a small Emacs plugin called Fortran-tags. It can find the definition of any variable or procedure under the cursor, so it's similar to Ctags, except that it is able to correctly identify all local and global variables and has some additional features. Also, it is developed with the focus on modern Fortran.

Using fortran-language-server (after installation simply start fortls in the terminal) and lsp-mode in emacs works perfectly.

I now found the f90-interface-browser in elpa.
If you use emacs 24 or later, you can just use
M-x package-list-packages
and then search for f90-interface-browser.
You write (or work on) large, modern fortran code bases. These
make heavy use of function overloading and generic interfaces. Your
brain is too small to remember what all the specialisers are
called. Therefore, your editor should help you.

Related

How to use Emacs as multiple IDEs with EVIL running in them all

Im just starting to look into Emacs as a IDE. There are lots of articles about how to setup Emacs as an IDE for languages XYZ. Most of these articles talk about how to switch content in your emacs.d. However this would only work if you use Emacs for one language?
Say for example I want to use Emacs with Clojue, Javascript and Python. For Clojure i want to use LiveMode and for Javascript i want to use some other mode and the same for Python. All highly specialized with a background repl running. How would I go about setting emacs up for this and what if I would like to use for example EVIL mode on all the IDE:s? Would it be possible to switch IDE setup at runtime depending on file ending or do i have to restart Emacs loading different settings each time?
Emacs allows to use so-called modes with files, e.g. python-mode for Python files etc. Automated enabling of modes for a specific file is either happening through file-local special variables or via associations of file-types via auto-mode-alist.
Modes actually provide these "special" settings you are talking about. If you want to add a special additional behavior in some mode, you typically add the required setup functions in the so-called mode-hook.
It might happen you run into incompatibilities between various extensions or modes, but this is a pretty rare case.

Run Specific Plugins for each Emacs Instance

Is it possible to have only certain plugins run when first starting emacs?
Let's say I develop in Python and also in Ruby. So I want to have one emacs instance running with Python plugins and another running Ruby plugins.
What I'm imagining is I can call rb-emacs or py-emacs from the command line.
So I think part of my solution lies here
http://stackoverflow.com/questions/2112256/emacs-custom-command-line-argument
And then I can alias the emacs call with the custom switches to one of the above
But then, how can I associate a specific plugin with a specific switch?
Am I on the right track with this? Or should I be doing something else entirely?
Edit:
Since my problem does not seem to be clear, I'll try to reiterate here. I'm not worried about long loading times. I'm worried about potential conflicts between plugins. I've used emacs before but only on a basic scale. Now I'd like to go more in depth with plugins. Though I don't fully understand how the plugins work.
Say I have a plugin (or two or three, I don't know how many it might be) for each language I code in. Won't those conflict with each other? Also, I don't want views / windows that are unneeded for that particular language.
You'll just need a different init file for each of your Emacs instances. Then you can create shell aliases for opening Emacs with those init files.
From the Emacs Wiki:
Start Emacs with a specific init file: emacs -q -l ~/my-init-file.el
Then you'll just set up a shell alias like:
alias rb-emacs=emacs -q -l ~/.rb-emacs-init.el
But why do this with separate Emacs processes? If you're concerned about the startup time, you can use lazy loading of packages or Emacs Server with Emacsclient.
I'm voting for "doing something else entirely", but I'm not 100% sure what the problem you're trying to solve is.
In general you can use mode hooks, eval-after-load, and autoload to ensure that you only load a particular elisp library when it is required.
If your problem is that you're forcibly loading everything and it takes too long, then you need to change your code so that you only load things when necessary. See OptimizingEmacsStartup.
If your problem is that you are setting global values for variables that need to have different values for different projects, then you want to be using buffer-local values for them, either via mode hooks, or using directory local variables.
What is the problem you're trying to solve?

Emacs config script for Lisp

What are some of the choices for pre-made Emacs config scripts? e.g. Lisp-centric keybindings, auto-complete / "intellisense", bracket matching, code formattting, etc.
So far I've only found:
emacs-starter-kit
redshank
There is also Prelude, which I can recommend. It has clean structure and code, and is regularly updated to include new interesting and useful packages or settings.
Do not use configurations from EmacsWiki. Most of what is posted there is very old, has never been updated since, and is hence rather out-dated now. Many of them will not work in modern GNU Emacs versions.
Instead, also look at the Github accounts of people who write Emacs packages, and you'll find many Emacs configurations. Some of these are created to be re-used by other people, for instance https://github.com/purcell/emacs.d.
See http://emacswiki.org/emacs/CategoryDotEmacs, especially under "Some complete InitFiles" and below.
This is my configuration script:
https://github.com/huseyinyilmaz/emacs-config

What is the short-cut key to jump to declaration in Emacs?

In visual studio it 's easier to push F12 button to jump to a declaration of a function or variable when editing C/C++ code.
Is there a short-cut key in emacs to do that?
Well, it's a bit more involved than that.
By default, Emacs doesn't "know" about function declarations for C or C++ code. First, obtain Exuberant Ctags. Then, use command etags (ctags for Emacs) on your source code. A file named TAGS will be generated.
Then, while editing your source code, when you want to jump to a declaration, press M-. (meta and dot, or alt and dot on modern keyboards). At first, Emacs will ask you for location of your tags file. Point it to the one you generated and afterwards navigation will be automatic.
I'd suggest reading Emacswiki article about tags for a better understanding of this functionality.
The newest version of Emacs (23.2) comes with CEDET integrated, which has more advanced features for C and C++ navigation, but it can be a bit difficult to set up right, so read more about it if you're interested.
M-. key will take you to the function definition emacs.
As others have said there is no built-in universal solution for this in emacs. That said, after having this functionality in IntelliJ I wanted it in emacs too so I made Dumb Jump.
Right now Dumb Jump has basic support for:
JavaScript
Emacs Lisp
Python
Go
PHP
Ruby
Faust
and more... (over 20 now)
It's available via MELPA and is actively being developed.
There are multiple ways to do this. As darioo mentioned, Ctags is one, but it goes to the definition by default (which might work for you). Looking further, though, you can see that prefixing M-.(ie, C-u M-.) will take you to the next tag match (which is often the declaration). There is also a --declarations option, but Exuberant Ctags doesn't seem to support it.
CEDET is another option, but in my experience, it's still not ready for production. Often times in C++ semantic-ia-fast-jump will go to forward declarations instead of the definition or the declaration.

Best practices in building and deploying Clojure applications: good tutorials?

I am new to Clojure, and am beginning to experiment with building an application.
So far, everything I've seen about tutorials on compiling Clojure programs involves interactivity. For example, "load up the REPL and type (load-file "this-or-that") to run. This is fine, but it's not enough.
I am so used to the edit-compile-run idioms of languages like C or Delphi, that I am instinctively driven to make edits, then hit "M-x compile".
The problem is that "lein uberjar", which I understand is the equivalent to "make", is painfully slow to execute even for a hello world. So I'm going to have to figure out how this "interactive development" stuff works, stop using the uberjar like it's quick make, and save it only for the end of the day.
Another thing I noticed while building (using lein uberjar) is that the small GUI app I am working on pops up frames in the compilation process, as if they are executing while compiling. It just seems a bit counterintuitive to me; it is not quite as analogous to "make" as I had thought.
I know the Lisp way of developing things is interactively working in the REPL, and I am not trying to change that: I would like to adapt to this way of life. Unfortunately, I have seen little in the form of documentation on how to do so. For instance, how to reset the current state of the machine. It just seems kind of messy to just keep compiling individual snippets on the fly without being able to do some sort of reset.
Most tutorials I have seen on Clojure (and Lisp) in general seem to focus on hacking in the REPL. Best practices on the deployment of applications remains a mystery to me. My users are just going to be users; they are not going to be developers that are going to load files into a REPL.
So here is my question: any resources for good information or tutorials on the entire process of building a Clojure application, including deployment?
(Note: I have all of the prerequisites installed and working (e.g. Emacs, Slime, Leiningen, etc.), so this is not a question about that).
A couple of quick hints, then some links:
Don't use lein uberjar during development; prefer lein jar. The difference is that lein uberjar puts all your dependencies in the generated jar (including Clojure itself), so that your single jar is an entirely self contained package with your app inside; lein jar only jars your own code. The uberjar approach has obvious benefits for deployment, but for development, you should be able to just use the appropriate classpath when running your app, saving yourself the time necessary to prepare an uberjar. If you don't want to hand-manage the classpath for test runs, check out the lein run plugin.
Also, most likely the majority of your code should not actually be AOT compiled. AOT is necessary in some Java interop scenarios, but most of the time it brings one a slight boost in startup speed and annoying problems with binary compatibility with different releases of Clojure. I suppose the latter issue is not relevant to an uberjar-ed standalone app kind of project, but any library code at least should be left to be JIT-ed if at all possible. With Leiningen, you can put a :namespaces clause in the defproject form in project.clj to determine which namespaces are to be compiled; whatever you leave out will currently be JIT-ed by default. Older versions of Leiningen used to compile everything by default, which is actually a good reason to upgrade!
As for the windows popping out during compilation, I would guess that you're either running window-out-popping code during macro expansion time or outside of any function definition or similar construct. (Something like a (println "Foo!") at the top level.) That's just something you shouldn't do, I suppose -- unless you are planning to run your code as a script, anyway. To avoid the problem, wrap side-effecting code up in function definitions and provide an entry point to your application using the :main clause in project.clj. (If you say :main foo, then the -main function from the foo namespace will be used as the entry point to your app. That's the default, anyway, and at least the above mentioned lein run seems to have the name hardcoded -- not sure about lein itself.)
As for resetting the state of the REPL -- you can just restart it. With SLIME, M-x slime-restart-inferior-lisp will do just that while maintaining all other state of your Emacs session.
See also these discussions on the Clojure Google group:
Clojure for system administration
Prepping clojure for packaging (was: Re: Clojure for system administration)
Leiningen, Clojure and libraries: what am I missing?
No, you do not enter functions on the REPL.
You edit your source files, just as usual. The Lisp advantage is that you have the system running in the background at the same time, so you can compile individual functions from your source file and put them into the running system, or even replace them there.
If you use Slime, you press C-c C-c in your source file to compile and load the function at point. You can then switch to the REPL to test and explore, but anything you want to persist as source, you put into your source files.
Tutorials usually start by typing things on the REPL, because there is not much you need to set up for this, but serious development integrates the running system and source file management.
Just to illustrate, my usual workflow (I am using Common Lisp, but Clojure is similar) is like this:
Start Emacs
M-x slime to start Slime, the Lisp system, and connect the two via Swank
, (command) load-system foo to load the current project (compiling only if necessary) into the image
C-x b switch to a source buffer
C-c ~ make the source directory the current directory and the source package the current package of the REPL
Now, I'm set up with my system running in the background. Working is then:
change or add a function or class definition
C-c C-c to compile and load it into the image
switch to REPL, test
debug
There are no significant compilation pauses, because I never compile the whole thing at once, just individual definitions.