]> git.earman.xyz Git - emacsinit.git/commitdiff
Disable transient-mark-mode, bindings for commenting
authorrearman <rearman@r717.net>
Wed, 1 Oct 2025 18:20:43 +0000 (14:20 -0400)
committerrearman <rearman@r717.net>
Wed, 1 Oct 2025 18:20:43 +0000 (14:20 -0400)
init.el
re/re-bindings.el
re/re-editing-defuns.el

diff --git a/init.el b/init.el
index 1c7bb36fe8558bec5c13f2878dd39776f8df9bb4..5ff80bc507178dea8cdd5b6b4f82c2e556457ebb 100644 (file)
--- a/init.el
+++ b/init.el
 ;; 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)
index 33a583b88d5ac16c9b8f1d4cca20afb1423038cc..dbf417b73d3c3217ab672958291b0ab262502445 100644 (file)
@@ -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 "<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
index 082316138568ac89779f300fe1a30d274aa58141..f80b8d40594e784f9ab452f6f6ef2b557781f60e 100644 (file)
@@ -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."