How to disable AUCTeX highlighting? - emacs

I'm trying to use GNU Emacs 26.3 + AUCTeX 12.2.3 and it seems to work, but the colors it shows in the source code are very annoying, specially in amsmath environment such as align, because it uses only one color for the whole block. I would like to ignore auctex highlighting so the code looks the same as before installing auctex package, this is something like this: source code before AUCTeX
I deleted some strings like "align" from "Font Latex Math Environments" so it doesn't use the font locking for math environments, and now it looks like normal text: current source code
It's better that one color, yes, but there are several commands that doesn't highlight and I would like them to. (Not highlighted commands occurs outside the align too). Another option would be adding a generic alphabetic string next to \ as a keyword so it would be highlighted but I also don't know how to achieve this.

Related

How to set a monopaced font in code-blocks?

My standard font is a proportional one. When I edit markdown files I would like to have all sections that are indented by 4 or more spaces be shown in a monospaced font.
I do not use any special markdown mode. Therefore I would be ok if I had to to switch that behavior manually on for the current buffer. Although, my own mode for *.md-files would be need of course, but I have no idea how to do that (and is beyond the scope if this question).
The modes that are active for me are:
Enabled minor modes: Abbrev Auto-Composition
Auto-Compression Auto-Encryption Blink-Cursor
Column-Highlight Column-Number Desktop-Save File-Name-Shadow
Flyspell Font-Lock Global-Font-Lock Icomplete Line-Number
Menu-Bar Mouse-Wheel Shell-Dirtrack Show-Paren
Tooltip Transient-Mark
Yes, you do need a mode that highlights markdown code. (Try M-x package-install RET markdown-mode+ RET) If you have font-locking enabled (I suspect you have), the mode that you end up probably gives syntax highlighting for markdown.
Now, syntax highlighting is just alterations to font and color used. Once you have it on, you can customize the font face used for code by navigating over a code block and issuing M-x customize-face. My markdown mode has code blocks under markdown-pre-face; the face under cursor will be selected by default for you.
I prepared some screenshots to show the workflow. Determining what emacs allows for font family or foundry is bit of a dark magic, and I leave it to google to find out more about it. On linux systems there used to be an ugly little helper called xfontsel where you can preview different font families and foundries.
You can experiment without saving anything first by applying the changes without saving; when things look fine, you can "apply and save" in the customize mode.
I'm going to partially disagree with the argument that you can do what you are after. You can only partially do what you are after and it is a bit of a hack.
Basically, you can set different fonts for different faces. So, provided the text you want to display in a fixed width font has a different face definition, then you can change the font from a proportional font to a fixed width font. At least, that is the theory.
Unfortunately, the results tend to be less than you would hope.
The problem is that most modes do not define faces for all possible characters. Faces tend to only be used to make something stand out and that tends to mean something which is special in the mode - a heading, a bit of syntax etc.
The problem will be witht he 'default face - the face used when no other face is specified. The default face is not mode specific. If you set default face to a monospace font, that font will be used in all modes, not just in 'plain' characters within markdown mode. If any of your fonts in markdown mode are proportional, you will find that alignment in indentation will not look consistent. Depending on how you structure your buffer contents, this may or may not be an issue.
Personally, I gave up on using a proportioanl font as the default font under emacs a long time ago and have settled instead on using a fixed width font as the default and then defining proportional fonts for some speial purposes, such as org-mode headers.
some things you could try which might work, would be
File local variables for setting fonts just in markdown filtes. I've not tried this, but you may be able to use file local variables. You would probably want to create a markdown template which sets this up in new markdown filtes.
Make the face variables buffer local. You might be able to define a markdown-mode hook function which makes the face variables buffer local and sets them to a fixed width font.
Face definitions can use inheritance, so theoretically, if all the faces used inherit from default face and you do a file local variable or buffer local variable to set the default face, then all other faces should inherit that definition, so you shouldn't have to do it for every font in the buffer.

How to change default face for embolden text in Emacs?

I do love thin fonts, so I have following customisation in my .emacs:
(set-frame-font "NK57 Monospace-14:weight=light" t)
This works as expected, however this does not tells Emacs that it should render embolden text with lighter weight too, e.g. to use medium instead of regular weight, so there is dramatically difference in weights, see picture below.
How can I tweak this?
Well, it is possible to customise default bold face using customize-face command as was mentioned by lawlist (i.e. Easy Customization).
However, this is not enough in most cases, because of some packages or themes could introduce another customisations, which overrides default one (e.g. font-lock-function-name-face, font-lock-keyword-face) and could be found in face customisation menu too.

Customizing the Emacs Monokai Theme to have a more Sublime Text 2 look

I am using Emacs Prelude. I didn't find most of the custom themes comfortable. I really liked Sublime Text 2's Monokai theme, so I installed the Monokai theme ported for Emacs. Though it is more or less similar to Sublime Text 2's Monokai, there are some differences which I want to correct, so as get my Emacs Monokai more close to Sublime's Monokai.
For example I don't want every Python keyword to be the bold pinkish. I would be prefer keywords like class,def to have a blue color than the pink ones and I would prefer the function arguments to have an orange color.
The Emacs Monokai theme seems to color the variable name to an orange color, which I don't want. How do I implement this? I checked the monokai-theme.el file, but I don't know what variable to edit and what variable to add to give the features in color changes I mentioned above.
I suppose you're referring to this version of Monokai?
You'll be able to make some of your changes, but without doing a huge amount of work some of them won't be feasible. This theme uses font-lock to identify many of the things to be coloured, and font-lock identifies all Python keywords the same way.
Have a look through the various font-lock variables in that file. This will give you a good idea of what you can easily change. For example, if you want to change variables from orange to something else, change
'(font-lock-variable-name-face
(:foreground monokai-orange))
to use one of the other monokai- colour variables, or define your own.
If you're trying to figure out how a particular character is recognized by Emacs, move your cursor over that character and do C-u C-x = (C-u M-x what-cursor-position). This will show, among other things, the face for that character.

how to freely format comments in cc-mode

I'm quite new to cc-mode and I'd like to configure it to allow me to freely format and use tabs in multiline comments. This is important to me because I want to use cog.py in my source file and need to be able to format the python source in the comment correctly. I'd be ok with comments not beeing autoindented at all, however I'd like to keep auto indenting the rest of the source code.
Example:
...
/*
[[[cog
import cog
for x in ['a','b','c']:
>cog.outl(x)
]]]
*/
...
In the line marked with > I'd like to press TAB to indent the line. cc-mode simply does nothing at all if i do so. I could use spaces there (which is inconvenient) but every (semi-)automatic re-indentation of this block would cause the spaces to vanish and therefore the python code to be incorrectly indented (which is what happens if i happen to press tab somewhere on this line after indenting it with spaces).
I tried to start emacs without my .init to be sure this is default behavior and not modified by my configuration so far. I've done google searches and read the documentation of the cc-mode variables / functions I stumbled upon (cc-mode online docs) while searching for a solution (i.e. c-indent-comments-syntactically-p, c-indent-command, c-tab-always-indent,...) but none of these seemed to solve my question.
EDIT1:
Thanks to abo-abo's idea of a "multi-major-mode" setup i've stumbled upon mmm-mode and have set up automatic switching to python mode for a cog section, which fixes most of my problems.
The only remaining problem is reindenting the whole file or a region containing a cog section. Can I somehow tell cc-mode to not change anything in comments while reindenting the file? mmm-mode + that would be a perfect solution for me.
You can use M-i to force a tab indent on the lines that you want, so you can use it to indent your comments.
You can also change your comments to use // instead. Just select your python code snippet, and do M-x comment-region:
// def foo(x):
// print 'hi'
Then the autoindent won't mess up your indentation.

How do I modify text while keeping the original fontification?

I'm writing a mode which is actually a glorified markdown reader. It's a read-only mode however, and though I'd like to change the faces for bold, italics, and links, I'd love to remove the decorations surrounding those faces. However, when I do so, I lose the fontification. Is there anyway to modify fontified-text to something that no longer matches any of the syntax regexes and still keep the fontification?
Org-mode does this for its link markup. I'm not a mode writer (yet), but Org-mode would be the first place I'd look for code that demonstrates how to do this. Oddly, it doesn't do it for any of its fontification: italic, bold, and underline all retain their markup.
Specifically, the code to hide the link markup is on line 4612 of org.el in version 7.01 of org-mode:
(if org-descriptive-links (add-to-invisibility-spec '(org-link)))
where add-to-invisibility-spec is actually supplied by a built in elisp file subr.el, and allows specific types of markup to be hidden. That would be the approach I would take, especially if the buffer is read-only.