unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Xah <xahlee@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: CUA mode, turn off Shift+Curvor Move to Select
Date: Mon, 1 Sep 2008 09:57:24 -0700 (PDT)	[thread overview]
Message-ID: <f28e45d9-6311-4fba-926b-175d2164dd52@k36g2000pri.googlegroups.com> (raw)
In-Reply-To: mailman.18024.1220139310.18990.help-gnu-emacs@gnu.org

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/

  parent reply	other threads:[~2008-09-01 16:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-30 12:51 CUA mode, turn off Shift+Curvor Move to Select Xah
2008-08-30 14:00 ` Lennart Borgman (gmail)
     [not found] ` <mailman.17996.1220104836.18990.help-gnu-emacs@gnu.org>
2008-08-30 21:34   ` Xah
2008-08-30 23:35     ` Lennart Borgman (gmail)
     [not found]     ` <mailman.18024.1220139310.18990.help-gnu-emacs@gnu.org>
2008-09-01 16:57       ` Xah [this message]
2008-09-01 21:03         ` Lennart Borgman (gmail)
     [not found]         ` <mailman.18147.1220303028.18990.help-gnu-emacs@gnu.org>
2008-09-02  2:13           ` Xah
2008-09-02  9:43             ` Lennart Borgman (gmail)
     [not found]             ` <mailman.18190.1220348616.18990.help-gnu-emacs@gnu.org>
2008-09-02 12:58               ` Xah
2008-09-02 16:12                 ` Lennart Borgman (gmail)
     [not found]                 ` <mailman.18209.1220371931.18990.help-gnu-emacs@gnu.org>
2008-09-04 20:20                   ` Xah
2008-09-04 22:30                     ` Lennart Borgman (gmail)
     [not found]                     ` <mailman.18466.1220567455.18990.help-gnu-emacs@gnu.org>
2008-09-05 16:22                       ` Xah

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f28e45d9-6311-4fba-926b-175d2164dd52@k36g2000pri.googlegroups.com \
    --to=xahlee@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).