Third hunk adjusted to avoid conflict with current Emacs trunk. --- emacs-24.4/lisp/simple.el +++ emacs-24.4/lisp/simple.el @@ -4391,6 +4391,22 @@ (declare-function x-selection-exists-p "xselect.c" (&optional selection terminal)) +(defcustom dynamic-cursor t + "If non-nil, `cursor-type' is set dynamically to reflect `mark-active'." + :type 'boolean + :version "25.1" + :group 'editing-basics) + +;; Auto-disable to avoid conflict if cursor-type set in init file. +;; Use emacs-startup-hook instead of after-init-hook in case +;; cursor-type set in some file loaded as command line option. +(defun maybe-disable--dynamic-cursor () + (unless (eq (default-value 'cursor-type) + (eval (car (get 'cursor-type 'standard-value)))) + (setq dynamic-cursor nil))) + +(add-hook 'emacs-startup-hook #'maybe-disable--dynamic-cursor) + (defun deactivate-mark (&optional force) "Deactivate the mark. If Transient Mark mode is disabled, this function normally does @@ -4430,6 +4446,7 @@ ((eq transient-mark-mode 'lambda) (setq transient-mark-mode nil))) (setq mark-active nil) + (if dynamic-cursor (setq cursor-type t)) (run-hooks 'deactivate-mark-hook) (redisplay--update-region-highlight (selected-window)))) @@ -4445,3 +4462,4 @@ + (if dynamic-cursor (setq cursor-type 'bar)) (run-hooks 'activate-mark-hook)))) (defun set-mark (pos)