From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Stefan Monnier" Newsgroups: gmane.emacs.devel Subject: Re: eval-after-load as a macro (and eval-next-after-load) Date: Tue, 08 Apr 2003 14:17:58 -0400 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <200304081817.h38IHwst029188@rum.cs.yale.edu> References: <200304042030.h34KUEQL008262@rum.cs.yale.edu> <200304062105.h36L55Jn019873@rum.cs.yale.edu> <84y92mslqe.fsf@lucy.is.informatik.uni-duisburg.de> <84brziwhsi.fsf@lucy.is.informatik.uni-duisburg.de> <5xhe99z2q8.fsf@kfs2.cua.dk> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1049826252 20259 80.91.224.249 (8 Apr 2003 18:24:12 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 8 Apr 2003 18:24:12 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Tue Apr 08 20:24:10 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 192xkX-0005CN-00 for ; Tue, 08 Apr 2003 20:23:13 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 192xoe-0000Gz-00 for ; Tue, 08 Apr 2003 20:27:28 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 192xiX-00055f-05 for emacs-devel@quimby.gnus.org; Tue, 08 Apr 2003 14:21:09 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 192xiH-00053p-00 for emacs-devel@gnu.org; Tue, 08 Apr 2003 14:20:53 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 192xh8-0004U9-00 for emacs-devel@gnu.org; Tue, 08 Apr 2003 14:19:43 -0400 Original-Received: from rum.cs.yale.edu ([128.36.229.169]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 192xfa-0003P0-00; Tue, 08 Apr 2003 14:18:06 -0400 Original-Received: from rum.cs.yale.edu (localhost [127.0.0.1]) by rum.cs.yale.edu (8.12.8/8.12.8) with ESMTP id h38IHxx6029190; Tue, 8 Apr 2003 14:17:59 -0400 Original-Received: (from monnier@localhost) by rum.cs.yale.edu (8.12.8/8.12.8/Submit) id h38IHwst029188; Tue, 8 Apr 2003 14:17:58 -0400 X-Mailer: exmh version 2.4 06/23/2000 with nmh-1.0.4 Original-To: storm@cua.dk (Kim F. Storm) Original-cc: rms@gnu.org Original-cc: teirllm@dms.auburn.edu Original-cc: =?iso-8859-1?q?Kai_Gro=DFjohann?= X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:13034 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:13034 > > 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."