mirror of
https://github.com/jimeh/.emacs.d.git
synced 2026-02-19 13:46:41 +00:00
- Split large modules into smaller parts (e.g. siren-text-manipulation) - Organize modules into high level groups: - completion - core - editor - languages - linting - misc - navigation - projects - spelling - text-editing - version-control - windows - workspaces
33 lines
1.1 KiB
EmacsLisp
33 lines
1.1 KiB
EmacsLisp
;;; 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
|