From: rearman Date: Fri, 19 Sep 2025 16:03:52 +0000 (-0400) Subject: Switch to temporary transient-mark-mode setup X-Git-Url: https://git.earman.xyz/?a=commitdiff_plain;h=3566654d14eb4c0d054e42e4b474e9fa16a8ce01;p=emacsinit.git Switch to temporary transient-mark-mode setup Taken from 'https://spwhitton.name/blog/entry/transient-mark-mode/'. Enable transient-mark-mode for various commands, leave it disabled otherwise. --- diff --git a/init.el b/init.el index 7b73115..edc46b9 100644 --- a/init.el +++ b/init.el @@ -29,8 +29,7 @@ (setq-default indicate-empty-lines t mouse-prefer-closest-glyph t - line-move-visual nil - transient-mark-mode nil) + line-move-visual nil) (blink-cursor-mode -1) (column-number-mode t) @@ -130,6 +129,38 @@ :underline t) +;; 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)) + (re/remap-mark-command command)) + ;; Help (setq apropos-do-all t)