I was wondering whether there is a way to ask for a specific password when booting Emacs? I think I can ask for a pre-defined password which I can define in my .emacs file but I dont know how? I'm mainly interested to do this in an x- or graphical environment..
btw, I do know that the .emacs file can be seen and etc..but in my case it's not an issue.
I use epg to keep encrypted data in file. Then it simply loaded as normal emacs lisp file, as in my config. EPG will automatically ask for passphrase, and you can analyze return code of load function to determine, was loading successful or not
If I understand correctly, you are in a situation where multiple people share the same account on a computer -- that is, not only will they run the same emacs binary, they also have the same home directory where Emacs searches for the .emacs file.
It seems like you not only want to prevent others from reading the .emacs file, you actually don't want them to be able to run emacs at all.
Unfortunately for you, Emacs can be started with -q or -Q in which case the .emacs file is not evaluated at all. Thus any "protection" that relies on your .emacs file can easily be circumvented.
How about restricting access to the emacs binary instead? Maybe make it only executable for members of a certain Unix group (which of course is pointless if multiple people share the same account), or something along those lines. But note that this will not prevent them from installing their own local copy of Emacs.
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
I've read the TRAMP manual and dozens of forums across the web but I couldn't find an answer to this question. I am trying to set up a link in org-mode that transfers a file from a remote server to my local machine (or vice-versa).
According to the manual I have to write something like
/scp:user#host:filepathonremotemachine
and that's it. No specification of where the file should be moved to, which is weird.
I've tried to do it this way and it simply opened the file (as if I was using ssh); tried other combinations also, without any luck.
There is a specific reason for why I am trying to do this with tramp and not a shell:command link. Any help is very welcome
UPDATE
Apparently TRAMP is less useful than what it promises. That leaves me with the shell:command link option. The problem then revolves around avoiding the openssh window that pops out. The closest solution I found was here and it resumes to setting up an ssh-agent. I am not very familiar with this procedure and I would prefer to use the authinfo.gpg authentication method. Do I have this option? Thanks.
Tramp itself offers just alternative implementations of native Emeacs functions. In this sense, it is dumb, as every library, because it doesn't know what the caller wants.
I'm not an org-mode specialist, but could you please show, which kind of link you have in mind? Without any remoteness, just a link which copies a file locally. Replacing local file names with remote ones will be easy then.
I assume, you need something like an external link, evaluating Lisp code. Like
elisp:(copy-file "/path/src" "/path/target")
The following works (for some definition of "works"):
* link to copy a file
[[shell:scp remote.host.com:/path/to/file /tmp][scp]]
But you must have arranged for passwordless login to the remote host beforehand (e.g. ssh-copy-id your public key to the remote): given that, there is no output in the org buffer, no openssh popup, just the standard question from org-mode asking if you really want to execute the shell command and the file is copied quietly to its destination.
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?
I created a TAGS file for emacs in my django project using the following command on my Linux machine
ctags -eR *
I can now jump to a symbol definition using M-. and specifying the symbol name.In my project i have py,html and css files so is there also a way i can make emacs automatically open a file, if i specify the file name ?.
Thank You
I think you are looking for project management. There are few packages to manage project directory in emacs. The best one may be ede. but Its not easy to setup. It does have some learning curve and its limitations.
Thankfully there are many easy ones. like eproject. https://github.com/jrockway/eproject/wiki
anyway you can also check out emacswiki page for more details. http://www.emacswiki.org/ProjectSettings
http://www.emacswiki.org/emacs/find-file-in-tags.el
IDO (Interactive Do) mode does this. If you activate it, C-x C-f searches for files matching what you are typing, interactively. Beware though, it may take some time to get used to it.
[edit] The search is based on files or directories you've recently visited, and you can use M-s to force a search.
From the comments, I figured that you are looking for has nothing to do with tags, you just want a better find-file that makes good automatic guesses for the path given only the file name.
For this, I use the entirely awesome ido-mode: http://emacswiki.org/emacs/InteractivelyDoThings
I often write small perl scripts to solve various problem of to explore perl behavior.
I use templates for .pl files which is nice. it autopopulates the basics into my buffer.
A small annoyance is that whenever I do this, before running it, I have to
chmod ugo+x
Can I get emacs to do this automagically for me (based on the file extension)?
Of the solutions on the page to which Trey has linked, by far the best is:
(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
I've been using this for many years and have almost never needed to make a script executable by hand in that time.
How about the solutions offered on this page, they key off the fact that the file begins with #!. There's also a package that does this, shebang.el (which I happen to use). You could easily change the code to make the condition that the file name extension be .pl, but looking for #! is probably more generic.