Function: handle-shift-selection

handle-shift-selection is a byte-compiled function defined in simple.el.gz.

Signature

(handle-shift-selection)

Documentation

Activate/deactivate mark depending on invocation thru shift translation.

This function is called by call-interactively when a command with a ^ character in its interactive spec is invoked, before running the command itself.

If shift-select-mode is enabled and the command was invoked through shift translation, set the mark and activate the region temporarily, unless it was already set in this way. See this-command-keys-shift-translated for the meaning of shift translation.

Otherwise, if the region has been activated temporarily, deactivate it, and restore the variable transient-mark-mode(var)/transient-mark-mode(fun) to its earlier value.

View in manual

Probably introduced at or before Emacs version 23.1.

Source Code

;; Defined in /usr/src/emacs/lisp/simple.el.gz
(defun handle-shift-selection ()
  "Activate/deactivate mark depending on invocation thru shift translation.
This function is called by `call-interactively' when a command
with a `^' character in its `interactive' spec is invoked, before
running the command itself.

If `shift-select-mode' is enabled and the command was invoked
through shift translation, set the mark and activate the region
temporarily, unless it was already set in this way.  See
`this-command-keys-shift-translated' for the meaning of shift
translation.

Otherwise, if the region has been activated temporarily,
deactivate it, and restore the variable `transient-mark-mode' to
its earlier value."
  (cond ((and (eq shift-select-mode 'permanent)
              this-command-keys-shift-translated)
         (unless mark-active
           (push-mark nil nil t)))
        ((and shift-select-mode
              this-command-keys-shift-translated)
         (unless (and mark-active
		      (eq (car-safe transient-mark-mode) 'only))
	   (setq-local transient-mark-mode
                       (cons 'only
                             (unless (eq transient-mark-mode 'lambda)
                               transient-mark-mode)))
           (push-mark nil nil t)))
        ((eq (car-safe transient-mark-mode) 'only)
         (setq transient-mark-mode (cdr transient-mark-mode))
         (if (eq transient-mark-mode (default-value 'transient-mark-mode))
             (kill-local-variable 'transient-mark-mode))
         (deactivate-mark))))