0

I am differentiating em-dashes (—) from hypens (-) in emacs using this code in my .emacs:

(let* ((glyph-em-dash (make-glyph-code ?\u002D 'font-lock-function-name-face)) )        
  (aset standard-display-table 8212
    `[,glyph-em-dash ,glyph-em-dash ,glyph-em-dash]))

The issue is that emacs counts these characters as taking up three columns (which they do visually). How can I tell emacs to count the em-dash as only one character when calculating line lengths, etc.?

  • How about using points, instead of columns, to determine the quantity of characters in a given area? Although a character may span more than one column, it will generally be equal to only one point. Alternatively, you can use (current-column) to determine where things are. – lawlist Apr 19 '18 at 5:22
  • @lawllist, how can I get the column number in the mode-line and things which automatically wrap at a certain length to use points instead of columns? Also, when would a character take up more than one point? Do you mean unicode points? (That might actually be a problem for me.) – Infiltrator Apr 19 '18 at 5:36
  • "Point" is the wrong word here. You want to count characters, not columns. Think length of a string (number of chars) versus string-width (number of columns that would be displayed in a buffer). – Drew Apr 19 '18 at 13:42
  • Correct—characters is what I want to count. – Infiltrator Apr 19 '18 at 23:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.