6

Is there a built-in function that does this:

(defun mk-column-at (point)
  "Return column number at POINT."
  (save-excursion
    (goto-char point)
    (current-column)))
2
  • No, there is not to my knowledge -- but such an invention at the c-source-code level sure would be nice. – lawlist Nov 3 '15 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 Nov 3 '15 at 19:16
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, privacy policy and cookie policy

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