Does anyone know if I can find an emacs color syntax configuration which resembles eclipse's syntax coloring? Thank you for any suggestion.
I'm not sure what Eclipse looks like, but you might want to check out Color Theme There are lots of color themes included with it and you can easily create you own if you don't like any you see.
I think you want font-lock. The emacs name for syntax coloring. I get it with the mode (Java mode, C# mode, cc-mode, etc).
I have in my .emacs:
;; for fontification in emacs progmodes:
(load "font-lock")
(setq font-lock-maximum-decoration t)
;; turn on font-lock globally
(global-font-lock-mode 1 'ON)
And then it just works, for all the various prog modes.
Emacs with C# http://www.freeimagehosting.net/uploads/6be39f23a3.jpg
Try this... http://jasonm23.github.com/emacs-theme-editor/
It will customize most of the standard font-lock parameters (keywords, functions, constants, vars, etc....)
You can paste in an existing theme and edit it, if you have something almost right.
There's a few samples on http://jasonm23.github.com
You might also like the code theme generator at http://inspiration.sweyla.com/code/
I use the same .xemacs/init.el file for both Emacs and Xemacs.
In order for it to work, I use the following:
; turn on faces
(font-lock-mode 1)
;; Turn on font-lock mode for Emacs
(cond ((not running-xemacs)
(global-font-lock-mode t)
))
Also you might need to add modes for various files. For example:
(setq auto-mode-alist (mapcar 'purecopy
'(("\\.c$" . c-mode)
("\\.cc$" . c-mode)
("\\.cxx$" . c++-mode)
("\\.htm$" . html-mode)
("\\.java$" . java-mode))))
Note there is also a Go mode for emacs which supports color highlighting. URL for Go-mode for Emacs
Related
I have files with a .new extension that contain LaTeX code (they are the output of a program that does things on the original .tex source).
In order to check them I need that they have the LaTeX syntax highlighted and that they can be opened in read-only mode to avoid introducing errors. So I put these lines in my .emacs:
(setq auto-mode-alist
(append '(("\\.new\\'" . read-only-mode)
("\\.new\\'" . latex-mode))
auto-mode-alist))
But it does not work as expected because only the first mode is applied. How can I force emacs to apply both read-only-mode and latex-mode to the same file extension?
An easy solution is to associate your file extension with a custom derived major mode:
(define-derived-mode read-only-latex-mode latex-mode "LaTeX"
"Major mode for viewing files of input for LaTeX."
(read-only-mode 1))
(add-to-list 'auto-mode-alist '("\\.new\\'" . read-only-latex-mode))
The new read-only-latex-mode does everything that latex-mode does (including running latex-mode-hook if you're already using that), but it additionally enables read-only-mode after all of the parent mode's actions have taken place.
Any other code which cares about the major mode being latex-mode should already be testing that using the standard approach of (derived-mode-p 'latex-mode) which is still true for this new mode; so in principle this approach should Just Work.
Not sure I can really provide an answer, but here's some things to consider:
read-only-mode is a minor mode, while
auto-mode-alist is meant to turn on major modes. For major modes, it makes sense that you can have only one.
You can put something like -*- buffer-read-only: t; -*- on your first line in the file (possibly behind some comments or shebangs, depending on the file type) which would turn on read-only-mode. Maybe automate this using auto-insert-alist and match the .new filename pattern.
There's some good suggestions over at https://www.reddit.com/r/emacs/comments/jqxgiz/how_can_i_make_some_files_automatically_readonly/ , namely try file local variables and use find-file-hook
Hope some of that helps.
I'm trying to use coq with ProofGeneral, but the built-in Verilog mode shadows *.v filetype recognition. Can I somehow disable it and let ProofGeneral remap them to its coq mode?
You are going to have to override the binding in auto-mode-alist in your .emacs or whatnot.
This SO post does something similar with VHDL:
How do I turn off vhdl-mode in emacs?
Also, I googled for "auto-mode-alist remove" and found this link. Copy/Pasting the important bit:
;; Remove all annoying modes from auto mode lists
(defun replace-alist-mode (alist oldmode newmode)
(dolist (aitem alist)
(if (eq (cdr aitem) oldmode)
(setcdr aitem newmode))))
;; not sure what mode you want here. You could default to 'fundamental-mode
(replace-alist-mode auto-mode-alist 'verilog-mode 'proof-general-mode)
I'm not familiar with ProofGeneral, but if I understand your question correctly, you need to modify the auto-mode-alist variable to associate the correct major with files with the .v extension. So, you need to add something like this to your .emacs file:
(add-to-list 'auto-mode-alist '("\\.v$" . proof-general-coq-mode))
The following line worked:
(setq auto-mode-alist (remove (rassoc 'verilog-mode auto-mode-alist) auto-mode-alist))
That might be an XY-problem.
I got the same problem today, firstly, I tried the same thing as you, I add following into my ~/.spacemacs under dotspacemacs/user-init:
(setq auto-mode-alist (remove (rassoc 'verilog-mode auto-mode-alist) auto-mode-alist))
And then the mode becomes fundamental, and then I realized that the real reason is that the spacemacs coq layer isn't installed automatically, and you need a lot of effort to install it and it's dependencies well.
Following is my summarize about the installation steps after I successfully run Coq up on Emacs: https://gist.github.com/luochen1990/68e5e38496b79790e70d82814bdfc69a
Hope this helpful :)
I just got fixme-mode.el, and loaded it. It works just fine on C, Lisp and other languages. But it doesn't work on Javascript.
(defcustom fixme-modes '(erlang-mode java-mode c-mode emacs-lisp-mode jde-mode
scheme-mode python-mode ruby-mode cperl-mode
slime-mode common-lisp-mode c++-mode d-mode
js2-mode haskell-mode tuareg-mode lua-mode
pascal-mode fortran-mode prolog-mode asm-mode
csharp-mode sml-mode javascript-mode html-mode)
"The modes which fixme should apply to"
:group 'fixme-mode)
I even added javascript-mode and html-mode to the list, but it still doesn't work.
Is there a way I can make it work for all modes? Is there like an "emacs-mode" that includes all others? If not, why isn't it working on .js files?
Thank you!
if you are emacs emacs inbuilt javascript mode (I guess you are using that) that is js-mode not javascript-mode
add this .emacs file(~/.emacs.d/init.el)
(add-to-list 'fixme-modes 'js-mode)
Generally you don't edit defcustom directly in the source code. .emacs is the one for your customizations
UPDATE:
To make fixme-mode to be available for all buffers we should define a global-minor-mode
(defun turn-on-fixme-mode ()
(fixme-mode 1))
(define-global-minor-mode global-fixme-mode
fixme-mode turn-on-fixme-mode
:group 'fixme-mode)
now call global-fixme-mode
I'm an Emacs user with no skills with regards to configuring the editor. After I upgraded from haskell-mode 2.4 to 2.7, I've noticed two changes:
Indentation is different somehow, in a way I don't quite like. I can't quite put my finger on what it is.
More importantly: If I have cua-mode enabled and highlight a block of text, backspace/delete does not delete the entire block, just the previous/next character from my marker.
I see that haskell-mode 2.7 uses the minor mode haskell-indentation-mode by default, while 2.4's behaviour has been preserved in the form of haskell-indent-mode. If I first turn off the former, and then on the latter, the behaviour I want is restored (i.e. indentation feels like before, and backspace/delete deletes highlighted blocks).
I can't, however, get this to happen automatically whenever I open a file with a .hs suffix. I've tried various things resembling
(remove-hook 'haskell-mode-hook 'turn-on-haskell-indentation-mode)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indent-mode)
and the likes of it, but I either end up with the standard mode or with plain haskell-mode without indent and doc.
Any ideas?
Solution (thanks to nominolo):
(remove-hook 'haskell-mode-hook 'turn-on-haskell-indent)
(remove-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
(add-hook 'haskell-mode-hook 'my-haskell-mode-hook)
(defun my-haskell-mode-hook ()
(haskell-indentation-mode -1) ;; turn off, just to be sure
(haskell-indent-mode 1) ;; turn on indent-mode
)
The best way to configure such things is by writing a custom hook:
(add-hook 'haskell-mode-hook 'my-haskell-mode-hook)
(defun my-haskell-mode-hook ()
(haskell-indentation-mode -1) ;; turn off, just to be sure
(haskell-indent-mode 1) ;; turn on indent-mode
;; further customisations go here. For example:
(setq locale-coding-system 'utf-8 )
(flyspell-prog-mode) ;; spell-checking in comments and strings
;; etc.
)
You could also stick an anonymous function in there, but having a named function is easier if you want to experiment with some settings. Just redefining the function (and re-opening a Haskell file) will give you the new behaviour.
In vim, I can run set bg=dark and then vim will adjust all syntax highlighting to work on a terminal with a dark background (whether or not the background actually is dark, vim will assume that it is).
How do I tell emacs to assume that the background is either dark or light?
I've used the invert-face function in the past:
(invert-face 'default)
Or:
M-x invert-face <RET> default
I think the best approach to use is to use ColorTheme. Other options to customize the frame colors you can find here. I can't think about a single command, however you can start emacs with --reverse-video.
M-x set-variable <RET> frame-background-mode <RET> dark
see also the bottom of https://www.gnu.org/software/emacs/manual/html_node/elisp/Defining-Faces.html
Write this at the end of your ~/.emacs file :
;; dark mode
(when (display-graphic-p)
(invert-face 'default)
)
(set-variable 'frame-background-mode 'dark)
Note: The "when" sentence is there to avoid to invert colors in no-window mode (I presume your terminal has already a black background).
The alect-themes package for Emacs 24 provides light, dark, and black themes, and can be installed either manually or using MELPA.
To install alect-themes using MELPA and select alect-dark (from ~/emacs.d/init.d):
(when (>= emacs-major-version 24)
(require 'package)
(add-to-list 'package-archives
'("melpa-stable" . "http://melpa-stable.milkbox.net/packages/"))
(package-initialize)
(load-theme 'alect-dark)
)
There are quite a few color theme packages in MELPA, so if alect-themes doesn't meet your needs, experiment with some of the others.