The function below should either insert a # if at beginning of the line, and if not, it should go to the end of line and insert a #. Why is this not working (it always goes to the end and inserts a #?
(defun end-of-line-hash ()
(interactive)
(if (beginning-of-line)
(insert "#")
(end-of-line)
(insert "#"))
)
(global-set-key (kbd "#") 'end-of-line-hash)
Function
beginning-of-linemoves the point to the beginning of the line. It probably returnsnil. Try this instead.