branch: elpa/nasm-mode commit 96a06c05cc45f68c41da7e966f3aac6bc5950ad3 Author: Lassi Kortela <la...@lassi.io> Commit: Lassi Kortela <la...@lassi.io>
Support M-; (comment-dwim function) --- nasm-mode.el | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/nasm-mode.el b/nasm-mode.el index db6c081..af5f08f 100644 --- a/nasm-mode.el +++ b/nasm-mode.el @@ -677,6 +677,15 @@ is not immediately after a mnemonic; otherwise, we insert a tab." (end (progn (back-to-indentation) (point)))) (and (<= start point) (<= point end))))) +(defun nasm-comment-indent () + "Compute desired indentation for comment on the current line." + comment-column) + +(defun nasm-insert-comment () + "Insert a comment if the current line doesn’t contain one." + (let ((comment-insert-comment-function nil)) + (comment-indent))) + (defun nasm-comment (&optional arg) "Begin or edit a comment with context-sensitive placement. @@ -740,6 +749,8 @@ With a prefix arg, kill the comment on the current line with (setf font-lock-defaults '(nasm-font-lock-keywords nil :case-fold) indent-line-function #'nasm-indent-line comment-start ";" + comment-indent-function 'nasm-comment-indent + comment-insert-comment-function 'nasm-insert-comment imenu-generic-expression nasm-imenu-generic-expression)) (provide 'nasm-mode)