;; Transient mark mode temp enabling
(setq transient-mark-mode nil)
-(defun re/remap-mark-command (command &optional map)
- "Remap a mark-* command to temporarily activate Transient Mark mode.
-Taken from https://spwhitton.name/blog/entry/transient-mark-mode/"
- (let* ((cmd (symbol-name command))
- (fun (intern (concat "re/" cmd)))
- (doc (concat "Call `"
- cmd
- "' and temporarily activate Transient Mark mode.")))
- (fset fun `(lambda ()
- ,doc
- (interactive)
- (call-interactively #',command)
- (activate-mark)))
- (if map
- (define-key map (vector 'remap command) fun)
- (global-set-key (vector 'remap command) fun))))
-
-(dolist (command '(mark-beginning-of-buffer
- mark-end-of-buffer
- mark-end-of-sentence
- mark-page
- mark-paragraph
- mark-sexp
- mark-defun
- mark-whole-buffer
- mark-word
- rectangle-mark-mode
- org-mark-element
- org-mark-subtree))
- (re/remap-mark-command command))
+;; (defun re/remap-mark-command (command &optional map)
+;; "Remap a mark-* command to temporarily activate Transient Mark mode.
+;; Taken from https://spwhitton.name/blog/entry/transient-mark-mode/"
+;; (let* ((cmd (symbol-name command))
+;; (fun (intern (concat "re/" cmd)))
+;; (doc (concat "Call `"
+;; cmd
+;; "' and temporarily activate Transient Mark mode.")))
+;; (fset fun `(lambda ()
+;; ,doc
+;; (interactive)
+;; (call-interactively #',command)
+;; (activate-mark)))
+;; (if map
+;; (define-key map (vector 'remap command) fun)
+;; (global-set-key (vector 'remap command) fun))))
+
+;; (dolist (command '(mark-beginning-of-buffer
+;; mark-end-of-buffer
+;; mark-end-of-sentence
+;; mark-page
+;; mark-paragraph
+;; mark-sexp
+;; mark-defun
+;; mark-whole-buffer
+;; mark-word
+;; rectangle-mark-mode
+;; org-mark-element
+;; org-mark-subtree))
+;; (re/remap-mark-command command))
;; Help
(setq apropos-do-all t)
(keymap-global-set "M-j" (lambda () (interactive) (join-line 0))) ; join-line other way
(keymap-global-set "C-z" #'zap-up-to-char)
(keymap-global-set "C-c s" #'sort-lines)
-(keymap-global-set "<remap> <comment-dwim>" #'re/comment-dwim) ; M-;
+(keymap-global-set "M-;" #'comment-or-uncomment-region)
+(keymap-global-set "C-;" #'comment-line)
+(keymap-global-set "C-M-;" #'re/comment-defun)
(keymap-global-set "<remap> <capitalize-word>" #'capitalize-dwim) ; M-c
(keymap-global-set "<remap> <downcase-word>" #'downcase-dwim) ; M-l
(keymap-global-set "<remap> <upcase-word>" #'upcase-dwim) ; M-u
(interactive)
(if (use-region-p)
(comment-or-uncomment-region (region-beginning) (region-end))
- (comment-or-uncomment-region (line-beginning-position)
- (line-end-position))))
+ (comment-line)))
+
+(defun re/comment-defun ()
+ "Mark a defun and comment it out."
+ (interactive)
+ (save-excursion (mark-defun)
+ (comment-region (region-beginning) (region-end))))
(defun re/kill-bword-or-region ()
"Kill region if active, otherwise kill back one word."