;;; siren-toggle-comments.el --- jimeh's Emacs Siren: toggle-comments ;;; Commentary: ;; Allows to toggle comments for current line or selected region. Shamelessly ;; ripped from textmate.el: https://github.com/defunkt/textmate.el ;;; Code: (defmacro allow-line-as-region-for-function (orig-function) `(defun ,(intern (concat (symbol-name orig-function) "-or-line")) () ,(format "Like `%s', but acts on the current line if mark is not active." orig-function) (interactive) (if mark-active (call-interactively (function ,orig-function)) (save-excursion ;; define a region (temporarily) -- so any C-u prefixes etc. are preserved. (beginning-of-line) (set-mark (point)) (end-of-line) (call-interactively (function ,orig-function)))))) (unless (fboundp 'comment-or-uncomment-region-or-line) (allow-line-as-region-for-function comment-or-uncomment-region)) (global-set-key (kbd "C-c /") 'comment-or-uncomment-region-or-line) (global-set-key (kbd "C-c C-/") 'comment-or-uncomment-region-or-line) (provide 'siren-toggle-comments) ;;; siren-toggle-comments.el ends here