There is a built-in eolp function. (editing: but that was not what you were trying to achieve, was it.)
Here is my version of the function (although you will have to test it in more detail than me):
(defun end-of-line-p () "true if there is only [ \t] between point and end of line" (interactive) (let ( (point-initial (point)) ; save point for returning (result t) ) (move-end-of-line nil) ; move point to end of line (skip-chars-backward " \t" (point-min)) ; skip backwards over whitespace (if (> (point) point-initial) (setq result nil) ) (goto-char point-initial) ; restore where we were result ) )
source share