From: rearman Date: Wed, 1 Oct 2025 18:20:43 +0000 (-0400) Subject: Disable transient-mark-mode, bindings for commenting X-Git-Url: https://git.earman.xyz/?a=commitdiff_plain;h=eaf5b718e0309cffc8163d748cfdfcf22962efc3;p=emacsinit.git Disable transient-mark-mode, bindings for commenting --- diff --git a/init.el b/init.el index 1c7bb36..5ff80bc 100644 --- a/init.el +++ b/init.el @@ -138,36 +138,36 @@ ;; 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) diff --git a/re/re-bindings.el b/re/re-bindings.el index 33a583b..dbf417b 100644 --- a/re/re-bindings.el +++ b/re/re-bindings.el @@ -23,7 +23,9 @@ (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 " " #'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 " " #'capitalize-dwim) ; M-c (keymap-global-set " " #'downcase-dwim) ; M-l (keymap-global-set " " #'upcase-dwim) ; M-u diff --git a/re/re-editing-defuns.el b/re/re-editing-defuns.el index 0823161..f80b8d4 100644 --- a/re/re-editing-defuns.el +++ b/re/re-editing-defuns.el @@ -58,8 +58,13 @@ Stolen from https://depp.brause.cc/dotemacs" (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."