Is there a built-in function that does this:

(defun mk-column-at (point)
  "Return column number at POINT."
    (goto-char point)
  • No, there is not to my knowledge -- but such an invention at the c-source-code level sure would be nice.
    – lawlist
    Commented Nov 3, 2015 at 18:36
  • For an alternative approach when point is visible, have a look at the code for the function line-move-visual in simple.el. The presence of certain overlays (e.g., with the after-string property), however, conflict with that approach when point is at the end of the line.
    – lawlist
    Commented Nov 3, 2015 at 19:16

1 Answer 1

  1. "Point" means something in Emacs. It is the buffer position just before the text cursor - the position at which text is self-inserted. It is confusing to name a parameter POINT, since point typically does not correspond to whatever position might be passed to the function as argument. Better to call it POSITION or POS or POSN, following convention, or something else.

  2. Wrt the question, there is no such predefined function, as far as I know. What you write is about as succinct as it gets. I would probably just use the code in the function body, rather than bothering to define a function for this, but what you've done seems reasonable to me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.