 ;;    Smart Mark
 ;;  Tweaking `region-extract-function'
 ;;  Mouse Copy
+;;  Commenting
 ;;  Bindings
 
 ;;; Coding System

;; Time-stamp: <2016-07-19 16:11:29 kmodi>

;; Functions related to editing text in the buffer
;; Contents:

         ;; and the selected region will be MOVED to the point location.
         ("<S-s-down-mouse-1>" . mouse-drag-secondary-moving)))

;;; Commenting
;; http://stackoverflow.com/questions/9688748/emacs-comment-uncomment-current-line
;; http://endlessparentheses.com/implementing-comment-line.html
(defun endless/comment-line-or-region (n)
  "Comment or uncomment current line and proceed to the next line.
 With positive prefix, apply to N lines including current one.
 With negative prefix, apply to -N lines above.
 If region is active, apply to active region instead."
  (interactive "p")
  (if (use-region-p)
      (comment-or-uncomment-region
       (region-beginning) (region-end))
    (let ((range
           (list (line-beginning-position)
                 (goto-char (line-end-position n)))))
      (comment-or-uncomment-region
       (apply #'min range)
       (apply #'max range)))
    (forward-line 1)
    (back-to-indentation)))

;;; Bindings
(bind-keys
 :map modi-mode-map
