in reply to [emacs] automatically indent to comment-column

The following code will also fix the case of # as delimiter for s///.

Example: typing s#a#b##comment leads to

s#a#b# # comment

V0.04

(defun my-indent-for-comment (arg) "DWIM indent-for-comment v0.04" (interactive "p") (cperl-update-syntaxification (point) (point)) (if (and (not (memq (preceding-char) '(?$) )) ;; (memq (preceding-char) '( ?\; ?{ ?\( ?\[ ) ) (memq (get-text-property (point) 'face) '(cperl-my-trailing-spaces-face nil)) (not (get-text-property (point) 'syntax-type)) (looking-at "[[:space:]]*$") ) (cperl-indent-for-comment) (insert "#")) )

checking the "face" may be redundant now...

Cheers Rolf