Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
I configure and install emacs but i don't know how to compile a c program.
please give me full info.
Take a look at the following docs containing information on running your compiler from emacs:
http://www.gnu.org/software/emacs/manual/html_node/emacs/Compilation.html
http://www.slac.stanford.edu/comp/unix/gnu-info/emacs_26.html
As already answered the compile command triggers a build which automatically routes errors to a buffer.
M-x compile
The default behavior is to run make in the directory that the file you are editing is in.
make -k
The -k means keep going on errors and make as many targets as you can. You can edit the command line at this stage.
There are two issues you might have with this setup. Firstly if your source file is not in the directory the makefile is in, then you need to set the default directory file variable. You can do this by adding a line like this at the top of the source file.
// -*- mode: C++; default-directory: "c:/somewhere/yourmakefiledirectory/" -*-
Another issue is if you don't want a makefile. This happens if you have a simple program containing one, or only a few, cpp files, and you just want to quickly compile them.
You can do this by setting the compile-command file variable. Now when you run the compile command, this will show up as the default way to build you program, rather than make.
// -*- compile-command: "g++ -lpsapi -mwindows windowsprogram.cpp -g -o windowsprogram.exe"; -*-
Once you've compiled and possibly got some errors you can run the commands next-error and previous-error to move up and down the source file viewing them. I didn't like the default keys, and I tend to use this setup.
(global-set-key [f5] 'compile)
(global-set-key [f7] 'previous-error)
(global-set-key [f8] 'next-error)
More tips like this on my blog.
M-x compile will by default run make. You will need to have the appropriate compiler installed, and a makefile setup to do this, though. Once this is done you can use C-x ` to go to the next error.
There are a couple of ways actually. The simplest is to create a make file and place it in the same directory as your source. Then use M-x(Alt-x) to compile it. The other way is to launch a shell from within emacs using M-x eshell. The third way is to go and write a script using elisp if you are familiar with it.
Related
I have emacs24 and emacs25 on my machine. I want to use spacemacs with emacs24 and keep emacs25...well...as emacs. When I install spacemacs my ~/.emacs and ~/.emacs.d are changed. Both emacs start using spacemacs, which I do not want. Is there a way to have a spacemacs and an emacs at the same time. Tried looking for a solution and came across a solution to keep separate config files. But how to make emacs look for a specific config file. By the way if you still haven't guessed...I'm a noob.
At one level, this is quite easy to do. However, at another, there can be some
complications, depending on what you really want to do.
Emacs supports a command line switch -l to tell emacs where to find the config
file. So, from a very simple perspective, you could just create two wrapper
scripts my-spacemacs.sh and my-plainemacs.sh and inside them have the scripts
call emacs with a specific -l /path/to/config. You can pass $* to pick up other
command line arguments if you want.
The potential problem with this approach is that emacs will still use .emacs.d
to store all sorts of other information, including possibly elpa packages and
this could cause problems. To be safer, it is better to keep things completely
separate.
If you don't need to run both versions at the same time, the easy solution is to
have to separate directories, such as ~/.spacemacs-emacs.d and ~/plain-emacs.d
and then have a sym link called .emacs.d which points to whichever of the
versions you want to run. The two main problems with this approach is that you
need to reset the symbolic link whenever you want to change emacs flavors and
this won't work if you want to run both versions at the same time.
I guess we really need to know about your actual use case - why do you need two
different configurations? Knowing this could help identify a better approach.
As an example, I use org mode and babel to manage my emacs config. I have a
number of different versions and a simple script which I can run to generate
whichever init.el file I want from the different org files. I have a minimal.org
file, which has the most minimal emacs configuration I can bare and I have my
standard init.org which generates my working init.el and then I have an
experimental.org which is used to generate an init.el file which I use for
experimenting with new configurations or packages. It is trivial to switch
configurations, but I never need to run two different configurations at the same
time.
I often like to check out some of the other pre-cooked emacs setups, like
spacemacs, prelude, etc. for these, I just grab the current git version and use
a symbolic link to point .emacs.d at the root fo the git repo I want to
experiment with.
you can also use the following approach:
create a directory ~/spacemacs.
extract/copy the spacemacs .emacs.d into ~/spacemacs (so that it is ~/spacemacs/.emacs.d).
create a desktop link called Spacemacs (or menu entry) and enter the following command:
HOME=$HOME/spacemacs emacs
You can also start spacemacs from the shell with this command.
This way, you can run vanilla emacs and spacemacs simultaneously, each with its own configuration directory and elpa repository. The only disadvantage might be that you need to change a directory level upward to reach your real home directory, not the „fake” one set via the variable.
btw, this is how I run several emacs versions and configurations, as needed for diverse stuff.
The best solution seems to be using chemacs: https://github.com/plexus/chemacs
I very often open Racket in bash shell, however in order for it to support xrepl, I need to execute (require xrepl) command first.
Is there any way to start racket and execute command above automatically?
See Installing XREPL, especially the part I bolded below:
To use XREPL, start racket and enter (require xrepl). You will know that it works when the prompt changes to a ->, and, if you’re working on a capable terminal, you will now have readline editing. You can also start racket and ask for XREPL to be loaded using command-line arguments:
racket -il xrepl
If you want to enable XREPL automatically, add this expression to your Racket initialization file. An easy way to do the necessary editing is to enter ,install!, which will inspect and edit your initialization file (it will describe the change and ask for your permission). Alternatively, you can edit the file directly: on Unix, it is ~/.racketrc, and for other platforms evaluate (find-system-path 'init-file) to see where it is.
So I've finally decided to learn Lisp. I'm reading Practical Common Lisp and I'm using Lispbox (not the one the book recommends - it's no longer available, but it seems this is suitable nonetheless).
So far in my career I have managed to avoid wresting with emacs, but I guess that part of my life is over :-) Actually, I'm kind of excited - this is a brand new world.
When saving .lisp files, the out-of-the-box setup dumps these files into the lispbox-0.7 folder (which is also the LISPBOX_HOME env.var). My math teacher taught me, "If you don't know what you're doing, at least do it neatly." So I want to at least keep my work in a nice tidy folder. I can specify the full path on saving/loading. But can I tell (lispbox|emacs|whatever) to use a different folder by default?
If it matters: I will likely use the Windows version more often, but I also have a setup on Ubuntu.
I have looked at this and this and this. I tried adding these to the .emacs file (one at a time):
(setq default-directory "C:/Work/lisp/")
(cd "C:/Work/lisp/")
To open the .emacs file I used C-x C-f~/.emacs
If I try changing the LispBox shortcut's "Start in" property, it fails to load at all.
M-xcd c:/work/lisp does work, but I have to do it every time I launch LispBox
What I'm doing in the meantime: I've created a separate lisp folder beside the lispbox-0.7 folder. That way I can prepend ../lisp/ before any filename. This isn't so bad, especially with the tab auto-complete.
Found it!
The reason modifying .emacs wasn't working is because of the lispbox.bat file. It has this line:
%EMACS% --no-init-file --no-site-file --eval=%TO_EVAL%
So took out the two "no" parameters, leaving this...
%EMACS% --eval=%TO_EVAL%
...and it worked.
This worried me, though. Why would the default not want to load the .emacs file? I guess once I understand all of this better I'll have an answer. Until then, I restored the above, the changed this line...
set TO_EVAL="(progn (load \"lispbox\") (slime))"
...to this...
set TO_EVAL="(progn (load \"lispbox\") (slime) (cd \"C:/work/lisp/\"))"
Now I'm happy.
I know nothing about Lisp Box, and not all of what you describe is clear to me. But here goes.
It sounds like you are looking for a way to make c:/work/lisp the default directory when you start Emacs. For that, using an MS Windows shortcut, putting that folder in the Start in field does indeed accomplish that. But you speak of a LispBox shortcut's Start in. If by that you just mean an Emacs shortcut, then it should work.
But of course you need to use Windows syntax for the folder - not c:/work/lisp, but c:\work\lisp.
Is that what the problem was?
The Windows shortcut is a Windows thing. Emacs is different: it accepts / as a folder separator.
Tip: If that solves your problem, you might also want to start Emacs in Dired mode on that same folder, that is, if that folder is the one you will use a lot. To do that, add that folder at the end of the command line - again, using Windows syntax, but between double-quotes:
c:\your\path\to\runemacs.exe "c:\work\lisp"
Try starting lispbox.bat from the directory you want to save files to. For example, from the OS command prompt:
cd c:\work\lisp
path-to-bat-file\lispbox.bat
You can also cd to c:\work\lisp in listbox.bat before it executes Emacs. For Linux it looks like this in lispbox.sh:
#!/bin/bash
if [ "${0:0:2}" = "./" ]; then
export LISPBOX_HOME=`pwd`/../../..
else
export LISPBOX_HOME=`dirname $0`/../../..
fi
cd ~/work/lisp
export SBCL_HOME=${LISPBOX_HOME}/sbcl-1.0.42/lib/sbcl
exec ${LISPBOX_HOME}/Emacs.app/Contents/MacOS/Emacs --no-init-file --no-site-file --eval='(progn (load "lispbox") (slime))'
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm trying to disable the 'r' and 'o' commands in vim so people who use it can't open other files from within vim.
I tried to use the cmap r <Nop> and cmap o <Nop>, which work but have an undesirable side-effect... those 2 letters can never be used in vim command line nor when searching for something...
If you try to search for the word, "word" the search line displays: /wd.
So is there another way to disable opening files from with vimrc ?
If you really want to secure Vim (and not just provide a superficial appearance of certain disallowed features), you have to remove those features from the source code and compile (and test!) a limited version of Vim. (Or maybe you can use a operating-system wrapper that sandboxes the Vim process and filters certain system calls, but I don't know any such thing.)
Any Vimscript obstruction can be circumvented: Your remappings can be undone via :cunmap, any more elaborate protection in Vimscript can be stopped by pressing <C-c> at the right time.
You can launch Vim with a flag:
$ vim -R (readonly)
$ vim -Z (restricted)
$ vim -m (no writing)
$ vim -M (no text modification)
But none of those will block :e or :r or any of the myriad of similar commands. And… the ~/.vimrc could probably be edited with nano or whatever to remove any eventual command anyway.
What about completely sandboxing Vim or its user?
What about explaining why you would want that?
If you want to allow editing of a specific file with root permissions, without allowing commands or editing of other files (as you've now indicated in a separate comment), why don't you do this as outlined in man 8 sudoedit:
Temporary copies are made of the files to be edited
with the owner set to the invoking user.
The editor specified by the policy is run to edit the
temporary files. The sudoers policy uses the
SUDO_EDITOR, VISUAL and EDITOR environment variables
(in that order). If none of SUDO_EDITOR, VISUAL or
EDITOR are set, the first program listed in the editor
sudoers(5) option is used.
If they have been modified, the temporary files are
copied back to their original location and the
temporary versions are removed.
It is much safer to launch the editor in the user's context, not root context. (Plus, the user get's his Vim settings, not the unmaintained ones from the root account!) Just the sync back of the edited temp file must be done with root priviledges; with the help of sudo, all of this can be implemented in a few lines of shell script.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
Icicles (v.22.0) installed from elpa (package-list-packages)
Emacs version
$ emacs --version
GNU Emacs 24.0.90.1
Output on emacs start
Warning (initialization): An error occurred while loading `/home/exu/.emacs.d/init.el':
Symbol's function definition is void: hexrgb-canonicalize-defined-colors
To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file. Start Emacs with
the `--debug-init' option to view a complete error backtrace.
Debug init below:
Link to GIST error dump
You should not get such an error. Sorry for your trouble. The error message is saying that something tried to call function hexrgb-canonicalize-defined-colors but it was never defined. It was not defined no doubt because you do not have file hexrgb.el in your load-path. That's OK, but in that case, it should never be called.
hexrgb.el is an optional file for using Icicles (but it is recommended) -- see optional Icicles libraries.
Follow up by email, if you can -- that's easiest: M-x icicle-send-bug-report. Let me know what Icicles files you have etc. Preferably, test by starting from emacs -Q (no init file). Set debug-on-error to t, add the Icicles files to your load-path, M-x-load-library icicles, etc.
For debugging, use only the source Icicles files (*.el, not byte-compiled, *.elc). Remove any byte-compiled Icicles files from your load-path. Thx -- Drew