Skip to content

avatarwin/new-comment-dwim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 

Repository files navigation

new-comment-dwim.el

About

The standard emacs comment-dwim command can be somewhat disappointing, especially on lisp languages. Comment-dwim's docstring hints at a utopia where pressing M-; can switch between ;; and ;;; forms, along with automatically determining if you're in a comment block, and handling the case of adding comments alongside code.

This attempts to make reality a little closer to that utopia.

Usage

Probably the most useful way to use this is to bind M-; and M-j to the replacement functions, either globally if all you use is lispy languages, or within a mode-hook.

e.g:

(defun my/new-commenting ()
   (local-set-key (kbd "M-;") 'ns/comment-insert)
   (local-set-key (kbd "M-j") 'ns/comment-newline))

(add-hook 'lisp-mode-hook 'my/new-commenting)
(add-hook 'scheme-mode-hook 'my/new-commenting)
(add-hook 'emacs-lisp-mode-hook 'my/new-commenting)

Future

Currently the code is very lisp-centric in a way that makes these functions unusable for non-lisp commenting styles, emacs's comment-dwim doesn't have this limitation, and it would be better if this didn't too.

If a semicolon exists inside code when trying to add an 'end of line' style comment, the functions currently get confused about where the insert point should be (it should insert a semicolon, space and position the cursor for writing a comment at the end of the line; currently it jumps the cursor to the existing semicolons, assuming it to be an existing comment.

License

This code is released under the GPL-3 license, see the file LICENSE for details.

About

An improved 'DWIM' like comment system for lisp based languages

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published