1

The basic problem I have is that mark-mode works like a toggle button. Every time you call set-mark-command, "C-Space" you get in or get out of mark mode. I could bind any key combo to

(defun foo () "" (progn (set-mark-command) (left-word)))

but the next time I call foo my selection would be deselected.

Is there a function that only enters the selection mode instead of toggling it? Then i could select text more freely which I really need since I am annotating a large text corpus.

1 Answers1

2

I'm not sure I understand your question correctly, but here are a few thoughts on this:

1) If the shift-select-mode variable is set to t, all combinations of Shift and a command moving point will temporarily activate the region and extend it:

  • S-C-<right>: extend the region by one word on the right
  • S-<right>: extend the region by one char on the right

You can set shift-select-mode using either the customize infrastructure :

M-xcustomize-variableRETshift-select-modeRET

or in your init file:

(setq shift-select-mode t)

2) Starting from you sample code, you could write a command activating the region and extending it in the following way:

(defun foo ()
  ""
  (interactive) ;; this is a command (i.e. can be interactively used)

  (when (not (region-active-p))  ;; if the region is not active...
    (push-mark (point) t t))     ;; ... set the mark and activate it

  (backward-word))               ;; move point

;; Bind the command to a key
(global-set-key (kbd "C-S-<left>") 'foo)