I'm working on a utility that communicates with an external process using line and column positions in the current file.
I have configured Haskell mode to use compose-region
to display certain parts of the syntax in Unicode, which can replace multiple characters with a single one (ie turning ->
into →
). Unfortunately, this means that the line and column position in the buffer no longer correspond to their position in the underlying file, but instead map to the position in the buffer, counting the composed region as a single character.
Here's the code I currently use to get the line and column:
(list (line-number-at-pos) (current-column))
How can I get the position ignoring these composed characters, in terms of the underlying file?
(point)
instead of columns and perhaps consider using overlays instead.(save-excursion (goto-char (point-min)) (while (re-search-forward "->" nil t) (overlay-put (make-overlay (match-beginning 0) (match-end 0)) 'display "→")))
– lawlist May 13 '15 at 4:45haskell-mode
, so it's a bit harder to change it to use overlays, although it might be worth a look. Also, I'd need to convert(point)
to lines and columns to work with the external tool. (I guess I could change it to support that style of position info, but it's also mostly outside of my purview.) – Tikhon Jelvis May 13 '15 at 4:55