help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CUA mode, turn off Shift+Curvor Move to Select


From: Xah
Subject: Re: CUA mode, turn off Shift+Curvor Move to Select
Date: Mon, 1 Sep 2008 09:57:24 -0700 (PDT)
User-agent: G2/1.0

Xah wrote: «CUA mode, turn off Shift+Curvor Move to Select»

Thanks Lennart...

I've now solved my problem by attaching a deactivate-mark as a hook to
every command.

See the code below:

;;; --------------------------------------------------
;;; FIX cua-mode

;; prevent cua-mode from going into selection mode when
;; commands with Shift key is used.

(add-hook 'cua-mode-hook
 (lambda ()
   (define-key cua-global-keymap (kbd "M-C") 'ergokeys-cua-scroll-
down)
   (define-key cua-global-keymap (kbd "M-T") 'ergokeys-cua-scroll-up)
   (define-key cua-global-keymap (kbd "M-G") 'ergokeys-backward-
paragraph)
   (define-key cua-global-keymap (kbd "M-R") 'ergokeys-forward-
paragraph)
   (define-key cua-global-keymap (kbd "M-H") 'ergokeys-beginning-of-
buffer)
   (define-key cua-global-keymap (kbd "M-N") 'ergokeys-end-of-buffer)
   (define-key cua-global-keymap (kbd "M-D") 'ergokeys-move-end-of-
line)

   (defun ergokeys-move-end-of-line ()
     "Move cursor to the end of line.
This command is used in cua-mode to prevent it from selection
when this command is bind to a key with Shift."
     (interactive)
     (let ((deactivate-mark t))
       (move-end-of-line)
       )
     )

   (defun ergokeys-beginning-of-buffer ()
     "Move cursor to the beginning of buffer.
Like beginning-of-buffer, it marks the cursor position first,
but does not activate the mark in transient-mark-mode.
This command is used in cua-mode to prevent it from selection
when this command is bind to a key with Shift."
     (interactive)
     (let ((deactivate-mark t))
       (beginning-of-buffer)
       )
     )

   (defun ergokeys-end-of-buffer ()
     "Move cursor to the end of buffer.
Like end-of-buffer, it marks the cursor position first,
but does not activate the mark in transient-mark-mode.
This command is used in cua-mode to prevent it from selection
when this command is bind to a key with Shift."
     (interactive)
     (let ((deactivate-mark t))
       (end-of-buffer)
       )
     )

   (defun ergokeys-forward-paragraph ()
     "Move cursor forward one paragraph.
Used in cua-mode to prevent it from selection
when this command is bind to a key with Shift."
  (interactive)
  (let ((deactivate-mark t))
    (forward-paragraph)
    )
  )

   (defun ergokeys-backward-paragraph ()
     "Move cursor backward one paragraph.
Used in cua-mode to prevent it from selection
when this command is bind to a event with Shift."
     (interactive)
     (let ((deactivate-mark t))
       (backward-paragraph)
       )
     )

   (defun ergokeys-cua-scroll-up ()
     "Page down.
Used in cua-mode to prevent it from selection
when this command is bind to a event with Shift."
     (interactive)
     (let ((deactivate-mark t))
       (cua-scroll-up))
     )

   (defun ergokeys-cua-scroll-down ()
     "Page up.
Used in cua-mode to prevent it from selection
when this command is bind to a event with Shift."
     (interactive)
     (let ((deactivate-mark t))
       (cua-scroll-down))
     )
   )
 )

btw, just curious, is there a way to consolidate the above? i.e.
instead of defun each, simply use some mechanism that attach
deactivate-mark to a list of functions...

  Xah
∑ http://xahlee.org/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]