unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Stefan Monnier" <monnier+gnu/emacs@rum.cs.yale.edu>
Cc: emacs-devel@gnu.org
Subject: Re: eval-after-load as a macro (and eval-next-after-load)
Date: Tue, 08 Apr 2003 14:17:58 -0400	[thread overview]
Message-ID: <200304081817.h38IHwst029188@rum.cs.yale.edu> (raw)
In-Reply-To: 5xhe99z2q8.fsf@kfs2.cua.dk

> > The usual way to handle this is with hooks.  Does cua mode have
> > a cua-mode-hook?
> 
> It does not, but I can add one.

How about defining it using define-minor-mode ?
Something like the untested patch below.


	Stefan


Index: cua-base.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/emulation/cua-base.el,v
retrieving revision 1.23
diff -u -u -b -r1.23 cua-base.el
--- cua-base.el	31 Mar 2003 21:48:39 -0000	1.23
+++ cua-base.el	8 Apr 2003 18:16:19 -0000
@@ -260,29 +260,6 @@
   :link '(emacs-commentary-link :tag "Commentary" "cua-base.el")
   :link '(emacs-library-link :tag "Lisp File" "cua-base.el"))
 
-;;;###autoload
-(defcustom cua-mode nil
-  "Non-nil means that CUA emulation mode is enabled.
-In CUA mode, shifted movement keys highlight and extend the region.
-When a region is highlighted, the binding of the C-x and C-c keys are
-temporarily changed to work as Motif, MAC or MS-Windows cut and paste.
-Also, insertion commands first delete the region and then insert.
-This mode enables Transient Mark mode and it provides a superset of the
-PC Selection Mode and Delete Selection Modes.
-
-Setting this variable directly does not take effect;
-use either \\[customize] or the function `cua-mode'."
-  :set (lambda (symbol value)
-	 (cua-mode (or value 0)))
-  :initialize 'custom-initialize-default
-  :set-after '(cua-enable-modeline-indications cua-use-hyper-key)
-  :require 'cua-base
-  :link '(emacs-commentary-link "cua-base.el")
-  :version "21.4"
-  :type 'boolean
-  :group 'cua)
-
-
 (defcustom cua-enable-cua-keys t
   "*Enable using C-z, C-x, C-c, and C-v for undo, cut, copy, and paste.
 If the value is t, these mappings are always enabled.  If the value is
@@ -1181,19 +1158,17 @@
 (defvar cua--saved-state nil)
 
 ;;;###autoload
-(defun cua-mode (&optional arg)
+(define-minor-mode cua-mode
   "Toggle CUA key-binding mode.
 When enabled, using shifted movement keys will activate the region (and
 highlight the region using `transient-mark-mode'), and typed text replaces
 the active selection.  C-z, C-x, C-c, and C-v will undo, cut, copy, and
 paste (in addition to the normal emacs bindings)."
-  (interactive "P")
-  (setq cua-mode
-	(cond
-	 ((null arg) (not cua-mode))
-	 ((symbolp arg) t)
-	 (t (> (prefix-numeric-value arg) 0))))
-
+  :global t
+  :set-after '(cua-enable-modeline-indications cua-use-hyper-key)
+  :require 'cua-base
+  :link '(emacs-commentary-link "cua-base.el")
+  :version "21.4"
   (setq mark-even-if-inactive t)
   (setq highlight-nonselected-windows nil)
   (make-variable-buffer-local 'cua--explicit-region-start)
@@ -1235,9 +1210,7 @@
     (setq transient-mark-mode (and cua-mode
 				   (if cua-highlight-region-shift-only
 				       (not cua--explicit-region-start)
-				     t)))
-    (if (interactive-p)
-	(message "CUA mode enabled")))
+				     t))))
    (cua--saved-state
     (setq transient-mark-mode (car cua--saved-state))
     (if (nth 1 cua--saved-state)
@@ -1250,11 +1223,7 @@
 		 (if (and (nth 1 cua--saved-state) (nth 2 cua--saved-state)) " and" "")
 		 (if (nth 2 cua--saved-state) " PC-Selection" "")
 		 (if (or (nth 1 cua--saved-state) (nth 2 cua--saved-state)) " enabled" "")))
-    (setq cua--saved-state nil))
-
-   (t
-    (if (interactive-p)
-	(message "CUA mode disabled")))))
+    (setq cua--saved-state nil))))
 
 (defun cua-debug ()
   "Toggle cua debugging."

  parent reply	other threads:[~2003-04-08 18:17 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-04 20:30 eval-after-load as a macro (and eval-next-after-load) Stefan Monnier
2003-04-05  8:13 ` Richard Stallman
2003-04-06 21:05   ` Stefan Monnier
2003-04-07  9:25     ` Kai Großjohann
2003-04-07  9:33       ` Miles Bader
2003-04-07 12:50       ` Luc Teirlinck
2003-04-07 13:36         ` Kai Großjohann
2003-04-07 19:05           ` Luc Teirlinck
2003-04-07 19:43             ` Kai Großjohann
2003-04-07 20:04               ` Luc Teirlinck
2003-04-07 20:19                 ` Kai Großjohann
2003-04-07 19:35           ` Luc Teirlinck
2003-04-08  2:31           ` Richard Stallman
2003-04-08 10:46             ` Kim F. Storm
2003-04-08 10:21               ` Kai Großjohann
2003-04-08 18:17               ` Stefan Monnier [this message]
2003-04-09 23:41                 ` Kim F. Storm
2003-04-09  1:59               ` Richard Stallman
2003-04-09  2:31                 ` Miles Bader
2003-04-10  0:00                 ` Kim F. Storm
2003-04-10 22:47                   ` Richard Stallman
2003-04-07 17:04     ` Juanma Barranquero
2003-04-07 17:56       ` Stefan Monnier
2003-04-07 19:50         ` Juanma Barranquero
2003-04-08  2:31       ` Richard Stallman
2003-04-13 18:55         ` Juanma Barranquero
2003-04-14  7:10           ` Juanma Barranquero
2003-04-05 15:57 ` Kai Großjohann

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=200304081817.h38IHwst029188@rum.cs.yale.edu \
    --to=monnier+gnu/emacs@rum.cs.yale.edu \
    --cc=emacs-devel@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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).