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)))
Drew
  • 75,699
  • 9
  • 109
  • 225
Mark Karpov
  • 4,893
  • 1
  • 24
  • 53
  • No, there is not to my knowledge -- but such an invention at the c-source-code level sure would be nice. – lawlist Nov 03 '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 03 '15 at 19:16

1 Answers1

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.

Drew
  • 75,699
  • 9
  • 109
  • 225