Solarized differences between Vim and Emacs [closed]
Asked Answered
P

2

7

I know there is already a plethora of Vim/Emacs and Solarized questions so I am a bit hesitant to add yet another, but I can't seem to find any that address this exact issue.

The problem is that the same file looks very different in Vim than it does in Emacs when both editors are setup to use the solarized-dark theme. And what I can't figure out is whether this is an issue with Solarized or just a fundamental difference between Vim and Emacs.

Here is what I am working with:

In order for Emacs to display the background color properly I have to explicitly set TERM to xterm-16color. However, the colors look exactly the same whether I am running the editors in a terminal or in their respective GUIs (gvim and emacs without the -nw flag).

Here is a screenshot with Vim on the left and Emacs on the right:

enter image description here larger version

Ultimately, I want to get the Emacs colors to look exactly like the Vim colors. Is this possible? If so, is it a matter of tweaking the Emacs version of the color scheme? Or, is this just a fundamental difference between the two editors that can't be change?

Philippine answered 30/11, 2012 at 19:36 Comment(0)
D
4

I don't write in Ruby, but the general way I'd approach the situation from Emacs would be this:

  • Move the point to the word that in your opinion is not painted properly, then M-xcustomize-face This will autofill the minibuffer with the name of the face under point and once you press RET will open a customization buffer, where you can change how the face is rendered. It looks like at least some of the differences can be removed that way.

  • Major editing modes usually associate a face (normally one from font-lock variety) with a certain lexical group in the target language. You would need to investigate what options and how exactly Ruby mode assigns faces to the syntax elements of the language. Probably global adjustments to the face will be too extreme (might influence other modes too), so if you could tweak Ruby mode only to associate different syntax groups with faces w/o modifying faces, it would be a preferred choice.

  • You could investigate the level of decoration. Normally language modes in Emacs use Font Lock mode to paint the text, some modes offer more or less colours, depending on the level. More info here: http://www.gnu.org/software/emacs/manual/html_node/elisp/Levels-of-Font-Lock.html

  • It is also possible that Ruby mode originally doesn't emphasize some characters you wanted to be emphasized (number signs and quotes). If this is not achievable by tweaking the association of syntax elements with faces and neither by decoration level, then you could try adding more keywords to the Font Lock mode, like described here: http://www.gnu.org/software/emacs/manual/html_node/emacs/Font-Lock.html

  • It also looks like you wanted to display whitespace characters in some way http://emacswiki.org/emacs/ShowWhiteSpace#toc7 here's some info on how to do that, it also has info about the margin to show the maximum line length.

  • You can toggle display of line numbers with M-xlinum command.

PS. Also beware of that GUI version and terminal version may have different colouring schemes. The terminal version might use less colours overall and would usually strive for higher contrast, then the GUI one.

Diatribe answered 1/12, 2012 at 0:16 Comment(0)
P
4

With the same Solarized colorscheme, you'll get the same color palette (i.e. set of chosen colors) in both editors. What's still different is how the editors parse the filetype's syntax (i.e. how many different syntax elements are detected), and how the parsed syntax elements are grouped to highlight groups.

Vim (I cannot speak for Emacs) uses filetype-specific syntax groups (e.g. vimCommand) with are then linked to a fixed set of highlight definitions (Statement in this example). The colorscheme provides the colors for those definitions; the conventions can be found at :help group-name (but not every syntax definition necessarily adheres completely to them).

What does this mean for you? You can compare the differences and (in Vim) customize the mapping via :hi link ... commands, but that's a lot of work, for every filetype you use. And it still depends on how the parsing works. I guess you'll eventually decide on one editor or the other; in the meantime, I would not bother too much about the differences.

Petulah answered 30/11, 2012 at 19:55 Comment(0)
D
4

I don't write in Ruby, but the general way I'd approach the situation from Emacs would be this:

  • Move the point to the word that in your opinion is not painted properly, then M-xcustomize-face This will autofill the minibuffer with the name of the face under point and once you press RET will open a customization buffer, where you can change how the face is rendered. It looks like at least some of the differences can be removed that way.

  • Major editing modes usually associate a face (normally one from font-lock variety) with a certain lexical group in the target language. You would need to investigate what options and how exactly Ruby mode assigns faces to the syntax elements of the language. Probably global adjustments to the face will be too extreme (might influence other modes too), so if you could tweak Ruby mode only to associate different syntax groups with faces w/o modifying faces, it would be a preferred choice.

  • You could investigate the level of decoration. Normally language modes in Emacs use Font Lock mode to paint the text, some modes offer more or less colours, depending on the level. More info here: http://www.gnu.org/software/emacs/manual/html_node/elisp/Levels-of-Font-Lock.html

  • It is also possible that Ruby mode originally doesn't emphasize some characters you wanted to be emphasized (number signs and quotes). If this is not achievable by tweaking the association of syntax elements with faces and neither by decoration level, then you could try adding more keywords to the Font Lock mode, like described here: http://www.gnu.org/software/emacs/manual/html_node/emacs/Font-Lock.html

  • It also looks like you wanted to display whitespace characters in some way http://emacswiki.org/emacs/ShowWhiteSpace#toc7 here's some info on how to do that, it also has info about the margin to show the maximum line length.

  • You can toggle display of line numbers with M-xlinum command.

PS. Also beware of that GUI version and terminal version may have different colouring schemes. The terminal version might use less colours overall and would usually strive for higher contrast, then the GUI one.

Diatribe answered 1/12, 2012 at 0:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.