What's the font-lock-mode for in emacs? - emacs

I have font-lock mode on by putting (global-font-lock-mode 1) in .emacs. And, with font-lock mode "your program certainly look different" as explained in page 274 of Learning GNU emacs.
What I found was that, with python mode or org mode, when I change the font for that mode, some of the keywords are not shown because of the change in color. I mean, some of the characters(keywords) becomes white, and when the background color is white, those keywords are not seen anymore.
Is this expected behavior? With font-lock mode, am I supposed not to change any font?
What's the good for font-lock mode?
This is the code for changing default code.
;;; http://www.emacswiki.org/emacs/AquamacsFAQ
(set-default-font "-apple-dejavu sans mono-medium-r-normal--0-0-0-0-m-0-mac-roman")
And I used the following options to change a font for specific mode.
http://a.imageshack.us/img823/2772/fontq.png

Is this expected behavior? With font-lock mode, am I supposed not to change any font?
Yes. You have to customize the font faces and colors using customize-face command (change colors starting with "Font Lock"), or use a theme engine like color-theme.
What's the good for font-lock mode?
You can customize and extend font-lock to your need as this is the case for all things in emacs. This is the basic system for syntax highlighting that is used by the majority of the emacs users.
You have to learn how to customize it to your needs (C-h i m Emacs RET m Font Lock RET )

From the emacs help on function font-lock-mode:
Toggle Font Lock mode.
With arg, turn Font Lock mode off if and only if arg is a non-positive
number; if arg is nil, toggle Font Lock mode; anything else turns Font
Lock on.
(Font Lock is also known as "syntax highlighting".)

Related

How to customize colors for Command and Tactic in ProofGeneral when using Coq in Emacs?

I want to color some specific command and tactic into different color, e.g. I want "Print" and "Locate" command to be gray, and "induction" to be some special color different from other tactics.
Is this possible in ProofGeneral? If it is not configurable in ProofGeneral, then is it possible to configure it via some Emacs mechanism ?
PS: I have checked the manual of ProofGeneral, but cannot find any related option.
As far as I know, this is not possible in ProofGeneral. However, you can customize the colour of keywords by changing their face in emacs.
To do this, move the cursor to the word you want to change and then press M-x and enter customize-face, which will bring you to the customization window.
To add keywords to the ProofGeneral minor mode, you may want to have a look at https://www.gnu.org/software/emacs/manual/html_node/elisp/Customizing-Keywords.html
This adds the induction keyword with the font-lock warning face
(add-hook 'coq-mode-hook
(lambda ()
(font-lock-add-keywords nil
'(("\\<\\(induction\\):" 1 font-lock-warning-face prepend)))))

How can I adjust Emacs "Spc" mode?

I have a window whose mode line at the bottom says "(Text Spc Fill)", probably as a default for *.txt filenames. "Spc" seems to be a minor mode which attempts to preserve English text by, for example, collapsing two spaces to one after a word is removed. However, I don't want that in this buffer.
So, how can I turn off this minor mode?
I don't know the actual name of the mode. I tried M-x spc-mode and M-x space-mode, and I looked through a few help pages.
More generally, is there an easy way to get the list of modes which are active in the current buffer? Or to find out about a mode given its mode-line abbreviation? (These can be unpredictable; for example, M-x visual-line-mode corresponds to (WordWrap).)
This is Aquamacs, Emacs version 23.3.50.1.
To answer your second question, the command describe-mode (C-hm) will list
your major mode, along with
some documentation (usually including keybindings), and
all of the minor modes that are active
You might be surprised how many minor modes are active in a typical setup. Not all active modes have an "indicator."
in your .emacs file add the line
(remove-hook 'text-mode-hook 'turn-on-auto-fill)
Source

Font Families for Emacs

If I do M-x customize-face RET default I can adjust the default face (font) in Emacs.
There are several options, all of them explained in the documentation. Many of these options can be selected from a menu when you select/click on Value Menu, but not the Font Family.
How can I see a list of the fonts that I can use in Font Family in Emacs?
Type the following in the *scratch* buffer, and press C-j at the end of it:
(font-family-list)
You may need to expand the result to see all of them, by hitting enter on the ... at the end.
If you are using Emacs 23.1 or later on the X Window System, the following fc-list command can list font families available on your system for Emacs (or any application using fontconfig):
$ fc-list : family

How does Emacs select which minor modes to list in the mode line?

I plan to customize mode line in Emacs in near future, and i don't understand the algorithm behind listing minor modes in the mode line.
In section «1.3 The Mode Line» of Emacs manual it says: «MINOR is a list of some of the enabled "minor modes"»
While in section «23.2 Minor Modes» it says: «Most buffer-local minor modes say in the mode line when they are enabled»
However i have ErgoEmacs minor mode listed, which is global. Can somebody explain the mechanism behind this and preferably point at various elisp sources responsible for that?
You can change what is displayed for a specific minor mode by doing something like the following
(setcar (cdr (assq 'yas/minor-mode minor-mode-alist)) " ¥")
which will display " ¥" for yasnippet mode. I do this a lot, especially for modes that I often use since it shortens my mode-line considerably.
This is specified for each individual mode, by the mode's own definition.
If you read on to section 23.3.3 - Defining Minor Modes:
The string LIGHTER says what to display in the mode line when the mode is enabled; if it is `nil', the mode is not displayed in the mode line.
See:
M-: (info "(elisp) Defining Minor Modes") RET
C-hf define-minor-mode RET
See also http://www.emacswiki.org/emacs/DelightedModes which facilitates easy customisation of the mode line display for both major and minor modes.

Altering the font size for the Emacs minibuffer separately from default emacs?

I've been attempting to alter the font / face for the emacs minibuffer separately from emacs default fonts, but without much luck.
Specifically, I'm interested in making the minibuffer font size larger for use with the emacs MULE as, with my current font setting or if I'm using emacs on a "netbook" screen, sometimes the character selection options in the MULE are a bit small.
Options easily accessed within emacs are the minibuffer-prompt & minibuffer-prompt-properties, but these are only for command prompts and not the regular minibuffer text.
There seem to be a number of minibuffer variables listed in emacs for creating minibuffer frames, or getting contents from minibuffer windows, etc.. but these do not pertain to altering the minibuffer face. Is it even possible to alter the minibuffer face separately from the default emacs?
An interesting option is the oneonone emacs http://www.emacswiki.org/emacs/OneOnOneEmacs project. But could the dedicated minibuffer frame be altered? Also before I alter my current emacs set-up that drastically, I'd hope to be able to just alter fonts first or create my own alterable minibuffer frame, etc...
Any help and/or creative ideas would be greatly appreciated.
You can add customization to the minibuffer through the minibuffer-setup-hook. In there, you can do some face remapping like so:
(add-hook 'minibuffer-setup-hook 'my-minibuffer-setup)
(defun my-minibuffer-setup ()
(set (make-local-variable 'face-remapping-alist)
'((default :height 2.0))))
Change the body of the my-minibuffer-setup as desired. The above doubles the height of the default face.
Yes, you can easily customize the properties of a standalone minibuffer frame, including its default face and font.
You can customize the OneOnOneEmacs user option 1on1-minibuffer-frame-alist. (Or you can customize the standard option minibuffer-frame-alist -- its frame parameter values are used as defaults by 1on1-minibuffer-frame-alist.)
The font frame parameter is the one that controls the font (duh). So you would customize option 1on1-minibuffer-frame-alist, changing its setting for the font.
Alternatively, you can just set 1on1-minibuffer-frame-font to the font you want -- it is used as the default value for the font setting by 1on1-minibuffer-frame-alist whenever there is no explicit font setting in minibuffer-frame-alist. For example:
(setq 1on1-minibuffer-frame-font
"-*-Lucida Console-normal-r-*-*-14-112-96-96-c-*-iso8859-1")
If you do not want to use a standalone minibuffer frame then see Trey's answer.