I am new to emacs, but I know how to navigate the basics.
I simply want Django integration with emacs 24 on ubuntu.
Django-mode seems to be the only game in town, but is there a tutorial that is written with more complete steps? A typical use case would be someone who is not an expert in emacs, but wants to add Django support to emacs.
I have virtualenv and virtualenvwrapper all set up properly. But django-mode is not detecting my virtualenv no matter what I do.
I have a great deal of trouble with the quoted paragraph below on Directory local variables as the documentation is poorly written.
Is this file .dir-locals.el optional? Many of his explanations are confusing. Do I need iPython? I would think not, but I'm guessing the python-shell-interpreter is not optional.
I have made a .dir-locals.el file and added my virtualenv path, but django-mode is not detecting my virtualenv. In emacs it says: virtualenv none.
There are also screenshots of a menu bar that allows alot of neat stuff like running ./manage.py collectstatic, etc....but no mention of how to activate the menu. Maybe this is a basic emacs command but I don't know it and would appreciate it if someone could show me how to set up emacs with django.
Are there any other alternatives or is django mode the way to go? Did I miss a huge chunk of documentation (like is it hiding inside emacs)
Thanks!
Directory Local variables Now we have all set there's a really
important topic to talk about and that's Directory Local Variables.
python.el is directory local variables aware and is in favor of
directory based configurations, that's why understanding this topic is
that important. So I suggest you to read the relevant part of the
manual with M-: (info "(emacs)Directory Variables").
The .dir-locals.el is a file which contains an Association List, but
don't let the name scare you, the following is a quite complete
example of what I'm using to open the current project.
((python-mode (python-shell-interpreter . "python")
(python-shell-interpreter-args .
"/home/fgallina/Code/Projects/anue-site/anue/manage.py shell")
(python-shell-prompt-regexp . "In \[[0-9]+\]: ")
(python-shell-prompt-output-regexp . "Out\[[0-9]+\]: ")
(python-shell-completion-setup-code . "from IPython.core.completerlib
import module_completion")
(python-shell-completion-module-string-code .
"';'.join(module_completion('''%s'''))\n")
(python-shell-completion-string-code .
"';'.join(get_ipython().Completer.all_completions('''%s'''))\n")
(python-shell-extra-pythonpaths
"/home/fgallina/Code/Projects/anue-site/anue/apps/")
(python-shell-virtualenv-path . "/home/fgallina/.virtualenvs/anue")))
http://from-the-cloud.com/en/emacs/2013/01/28_emacs-as-a-django-ide-with-python-djangoel.html
There was recent a question at Help-gnu-emacs#gnu.org whose answers pertains to your case also
http://lists.gnu.org/archive/html/help-gnu-emacs/2013-06/msg00425.html
WRT this answer only replace Pymacs by django-mode.
For the moment, just use Emacs as editor. Otherwise see some risk to end up in frustration.
IPython is great to learn Python itself, basically it provides an enhanced interactive shell. On IPython is built Enthought -- a Python Distribution providing scientists with a comprehensive set of tools to perform rigorous data analysis and visualization.
Don't see it related to Django so far.
Related
I'm a non-programmer (except of some Perl and R skills).
I'm starting my Phd this year and considering to have org-mode as a laboratory notebook. However, before I spend time learning it, I have a bunch of questions..
Most importantly, at work I'm working on a different PC than I do at home, but I use both of them for work, so what I need is a seamless connectivity.
So my idea was to store the org file on a cloud, but actually I will have files that are linked in my org-mode file, but those are actually on a server (at work) which I am not allowed to store on my cloud. This means, lets say I've got some data in a spreadsheet and want to link this spreadsheet in my org file. However, on my private PC this file does not exist. How does org-mode deal with that? Is it even possible? I mean, does it complain?
Also, there are folder on my work PC that are locked for me, so installations and stuff is usually done by the IT service. Does emacs than even work? I tried with R and it works, even installing packages from within R, however, Perl does not as executing perl scripts from the terminal requires folders that are locked.
Also, If you can recommend me good sources for getting started I will be pleased :)
Thanks in advance!
I use org-mode for lots of notes. I use different computers also. The most basic thing I do is have the most inexpensive Amazon AWS compute instance (10-15$ a month IIRC). Emacs has this great system called TRAMP mode that allows you to edit remote files as if they are local. So in my .emacs file I have:
(find-file "/ssh:ec2-user#ec2-11-222-3-444.us-west-2.compute.amazonaws.com:~/logs/year/2018/may.org")
so when I startup emacs it grabs this month's org file. I also maintain a separate directory for tasks that span more than one day:
in the may.org file:
** [[../../tasks/something useful.org][something useful]]
then in the directory:
/ssh:ec2-user#ec2-11-222-3-444.us-west-2.compute.amazonaws.com:/home/ec2-user/logs/tasks/something useful.org
This setup seems ok for my basic needs. for your second requirement you might be able to use tramp mode. You can use org-mode's link system and tramp mode together:
[[file+emacs:/ssh:someUser#otherMachine:~/someDir/TextFile.txt][TextFile.txt]]
you will need to have your ssh-keys setup so you don't have to login:
in ~/.bashrc
ssh-add ~/.ssh/my-aws-secret.pem
ultimately to get emacs to do different things on different machines you may have to get down to conditional branching:
from my .emacs file (p is for predicate):
(defun p-is-windows-os ()
(eq system-type 'windows-nt))
(defun p-is-mac-os ()
(eq system-type 'darwin))
(if (p-is-windows-os)
(setq-default ispell-program-name "C:\\Program Files (x86)\\Aspell\\bin\\aspell.exe"))
if its the same OS on both computers, you might be able to do the condition on the network IP or something.
I really like org-mode and emacs in general. But, I am hesitant to recommend them because they are so different/weird from everything else (I'm a programmer, so weird make sense). Whatever you do: backup your data! Let me know if you want more info.
I strongly recommend you look at Dr. John Kitchin materials.
He does computational chemistry, but a lot of his materials are generic enough to be useful (specially those related to paper writing).
http://kitchingroup.cheme.cmu.edu/blog/category/emacs/
he has a very informative youtube channel.
https://www.youtube.com/channel/UCQp2VLAOlvq142YN3JO3y8w
he has also created some packages to improve org. I consider John as the best source of material for a researcher wanting to use org.
I personally use org-mode all the time for my own research.
About using the cloud. Place your org-files in a common directory (e.g. Dropbox) and make sure that you enable
(global-auto-revert-mode t)
This way if a file is changed in one machine, it will be updated automatically in any other emacs running. This will avoid conflicts.
Also, learn to use org-babel. It is absolutely amazing for R. It is the hacker's version of Jupyter Notebook. This is a good tutorial:
https://orgmode.org/worg/org-tutorials/org-R/org-R.html
--dmg
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?
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
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.
How can I change the initial directory on emacs? I started using it today and there are a lot of things to learn!
Right now I'm using M-X cd and then I change the directory that I use for C-x C-f, but in a daily work I'm going to heavily use one particular directory so I need to make the change permanent.
Also if you have some tips for a starter it will be nice.
To set a default directory, simply put
(cd "/default/path/")
in your ~/.emacs file.
Emacs has a steep learning curve, but with constant use the most common commands will soon become second nature. As you discover more, emacs may become your favorite text editor, file manager, and email reader :)
To learn emacs, I'd start by pressing C-h t to start plowing through the excellent tutorial. Have a pad of paper beside you and write down the commands as you learn them. You'll use the crib sheet at first, but after a while, as I mentioned before, your fingers will learn the key combinations without your brain conciously intervening.
Good luck and have fun!
Default directory is determined by:
(setq default-directory "~/")
in this case, set to the users home dir, but it could be somewhere else.
If this variable is not set, the initial load point for find-file will be the directory where the emacs executable lives.
EDIT: on windows, a global HOME environment variable can be defined (HOME=c:\path\to\user\home\directory), ensuring that Emacs translates ~ to the correct value. This makes the Emacs settings usable across platforms.
Start up emacs only after changing to that "initial directory", effectively setting the current directory for emacs.
This is a solution specific to Windows.
Create a shortcut to emacs.exe" called GNU Emacs
Open Properties on the GNU Emacs shortcut
Set Start in to %USERPROFILE%\Documents
This solution works for multi-user workstations whether they are on or off Active Directory.
This shortcut will start Emacs in the current user's Documents folder.
Print out the Gnu Emacs Reference card and keep it by the desk.