1

Alignment is not working for me on my Windows machine, but it is on my Centos machine. I want to understand why.

I first noticed the problem when I turned on linum-mode. Here's what it looks like in Centos:

enter image description here

But in Windows, it looks like this:

enter image description here

Then, I tried to follow Understanding of emacs align-regexp, and the following is what I got. In Centos:

enter image description here

But in Windows:

enter image description here

What is wrong with my alignment in Windows? How can I fix it?

yuxuan
  • 781
  • 4
  • 15
  • In a GUI version of Emacs, there is no reason (in my opinion) to use the fringe and the `|` symbol for line-numbers -- choose one or the other (my preference is just the fringe, and set the width accordingly). There is recent activity in this forum regarding right alignment of line-numbers -- there are existing threads on that issue. To the right of the left-fringe, you haven't shown us whether you are using tabs, or spaces, or some other method of alignment (e.g., stretch-glyph/overlay). So, we'd all just be guessing as to what is between the various columns in the picture. – lawlist Dec 08 '15 at 19:11
  • @lawlist But when I turn off the linum mode, I still get wrong align in the fourth picture. Also, all the text begin with no space or tab. – yuxuan Dec 08 '15 at 19:15

1 Answers1

5

Judging from your screenshots, you are using a monospaced font in centos, but a proportional/variable-width font in Windows.

I haven't looked at the source code, but I suspect that the alignment functions are based on the number of characters in the line and not the width of each, individual character. As such, they will line up visually with no problems when you use a monospaced font (because the width is constant), but in general, we would not expect them to line up visually with a variable-width font.

Setting your default font on your Windows machine to use a monospaced font should take care of the visual alignment problems.

Dan
  • 32,584
  • 6
  • 98
  • 168
  • 1
    You are right. `(set-face-attribute 'default nil :height 115 :family "Consolas")` After I add this, it solved. Thank you for your information. – yuxuan Dec 08 '15 at 20:10