This question already has answers here:
Emacs: check for no-window-system in .emacs
(2 answers)
Closed 8 years ago.
there are portions of my .emacs file that I would like to behave differently depending if emacs was opened in a terminal (ie, emacs -nw) or in a window. How does one go about detecting this?
In my FSF .emacs, I have code like this:
(if (null window-system)
(global-set-key "\C-h" 'delete-backward-char))
It looks like this works under XEmacs as well, though the preferred XEmacs way is to use the console-type function instead. Do M-x describe-function on console-type for details.
Related
This question already has an answer here:
Why does Ctrl+. not work when I bind it to a command in Emacs?
(1 answer)
Closed 2 years ago.
add a key-binding in emacs init file:
(global-set-key (kbd "C-:") 'avy-goto-char)
for avy-goto-char function.
When I press down Ctrl and :(with Shift pressed), nothing happens.
But when use Meta-x avy-goto-char, the commands list window shows C-: already bound to this function. And this function works well.
And if I replace char : to j (for example), it works fine.
Anyone met this problem before. Please help
Just like phils said, it is used in a terminal
This question already has answers here:
What to do if I cannot find my emacs init file?
(3 answers)
Closed 8 years ago.
Question of curiosity...
Let's assume I have the following files...~/.emacs, ~/.emacs.d/init.el and ~/.emacs.el.
Now, assume that each of these contain separate pieces of code, for example :
~/.emacs
(global-set-key (kbd "<f8>") 'execute-extended-command)
~/.emacs.d/init.el
(global-set-key (kbd "<apps>") 'execute-extended-command)
~/.emacs.el
(global-set-key (kbd "<menu>") 'execute-extended-command)
Notice that all files make separate changes to the execute-extended-command. When emacs is opened, which of these files will be executed? All of them, one of them, or none of them? Is there a special order for which ones are executed first? And, additionally, is it a bad idea to have multiple init files?
Any answer touching these subjects, and any additional information is adequate, I simply want to know what happens in such a scenario.
From the manual:
49.4.4 How Emacs Finds Your Init File
Normally Emacs uses the environment variable HOME (see HOME) to find .emacs; that's what ‘~’ means in a file name. If .emacs is not found inside ~/ (nor .emacs.el), Emacs looks for ~/.emacs.d/init.el (which, like ~/.emacs.el, can be byte-compiled).
So ~/.emacs.d/init.el is only consulted if the other two cannot be found. A quick test shows that, when both are available, ~/.emacs.el is preferred over ~/.emacs.
You should pick one of these locations and use it consistently.
I personally like ~/.emacs.d/init.el because Emacs puts other things in that directory (e.g. custom.el, elpa/) and many Emacs packages load their own configuration files from that directory.
This question already has answers here:
goto-file in Emacs
(2 answers)
Closed 8 years ago.
I am wondering does emacs have a command that opens the file where the cursor points to.
eg: I have a ASCII file with the following text:
source ../scripts/setup.tcl
I would like to have a command that opens the file ../scripts/setup.tcl when my current cursor position is on one of the characters of the file.
(global-set-key (kbd "C-x C-f") 'ffap)
So, this might be a heretical question, but I'm looking for an Emacs mode that handles syntax highlighting of .vimrc files. This particular question has proved pretty hard to Google for the obvious reasons, but it seems extremely likely to me that someone would have written such a mode in the 20+ years of open warfare between the two editors. Any ideas?
Googling does turn up wenbinye's vimrc-mode, a very lightweight generic mode. Here's what I have in my .emacs:
(define-generic-mode 'vimrc-generic-mode
'()
'()
'(("^[\t ]*:?\\(!\\|ab\\|map\\|unmap\\)[^\r\n\"]*\"[^\r\n\"]*\\(\"[^\r\n\"]*\"[^\r\n\"]*\\)*$"
(0 font-lock-warning-face))
("\\(^\\|[\t ]\\)\\(\".*\\)$"
(2 font-lock-comment-face))
("\"\\([^\n\r\"\\]\\|\\.\\)*\""
(0 font-lock-string-face)))
'("/vimrc\\'" "\\.vim\\(rc\\)?\\'")
'((lambda ()
(modify-syntax-entry ?\" ".")))
"Generic mode for Vim configuration files.")
There is a great package for this: https://github.com/mcandre/vimrc-mode
Install by M-x package-install vimrc-mode.
It highlights vimrc files with amazing syntax highlighting automatically when they are opened, or you can invoke it manually via (vimrc-mode).
This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Unable to hide welcome screen in Emacs
Is there a way I can prevent the GNU Emacs buffer from coming up when emacs starts?
I believe this in your ~/.emacs will do that
;; no startup msg
(setq inhibit-startup-message t) ; Disable startup message
The following in your .emacs will do the trick.
(setq inhibit-startup-screen t)