From xemacs-m  Tue Jun 10 19:17:46 1997
Received: from mercury.Sun.COM (mercury.Sun.COM [192.9.25.1])
	by xemacs.org (8.8.5/8.8.5) with SMTP id TAA05641
	for <xemacs-beta@xemacs.org>; Tue, 10 Jun 1997 19:17:46 -0500 (CDT)
Received: from Corp.Sun.COM ([129.145.35.78]) by mercury.Sun.COM (SMI-8.6/mail.byaddr) with SMTP id RAA18950 for <xemacs-beta@xemacs.org>; Tue, 10 Jun 1997 17:37:15 -0700
Received: from legba.Corp.Sun.COM by Corp.Sun.COM (SMI-8.6/SMI-5.3)
	id RAA02796; Tue, 10 Jun 1997 17:18:15 -0700
Received: by legba.Corp.Sun.COM (SMI-8.6/SMI-SVR4)
	id RAA08636; Tue, 10 Jun 1997 17:18:13 -0700
To: xemacs-beta@xemacs.org
Subject: More del/bs madness :-) [PATCH]
X-Attribution: GDF
Mime-Version: 1.0 (generated by tm-edit 7.108)
Content-Type: multipart/mixed;
 boundary="Multipart_Tue_Jun_10_17:18:13_1997-1"
Content-Transfer-Encoding: 7bit
From: Gary.Foster@Corp.Sun.COM (Gary D. Foster)
Date: 10 Jun 1997 17:18:13 -0700
Message-ID: <bcipvtu9em2.fsf@corp.Sun.COM>
Lines: 150
X-Mailer: Gnus v5.4.56/XEmacs 20.3(beta4)

--Multipart_Tue_Jun_10_17:18:13_1997-1
Content-Type: text/plain; charset=US-ASCII

Ok, ok, I finally admit that the name `backspace-or-delete' is rather
ambiguous and not a good name for this function.  It also loses out
when trying to extrapolate to deleting words, sentences, etc.

So, in light of that, I've tentatively renamed it to
`erase-character', and to celebrate, I'll also throw in `erase-word'
and `erase-sentence' for free.  Feel free to pick on the names if you
can think of better ones.

Patch attached, which defines all this madness, makes the changes, and 
binds the direction-dependant functions `erase-word' to M-delete and
`erase-sentence' to C-x delete.  These keysym sequences should delete
either words or sentences in the direction defined by
delete-erases-forward, just like it does for the bare 'delete keysym.

I've also completely eradicated the last vestiges of
`backspace-or-delete-hook'.

Is everyone *thoroughly* confused now?  I'm becoming convincing that
Hrvoje's statement about having a special place reserved in hell for
us is true... :)

-- Gary F.


--Multipart_Tue_Jun_10_17:18:13_1997-1
Content-Type: text/plain; name="erase.patch"; charset=US-ASCII

--- lisp/prim/keydefs.el.orig	Tue Jun 10 16:02:11 1997
+++ lisp/prim/keydefs.el	Tue Jun 10 17:01:23 1997
@@ -95,7 +95,9 @@
 (define-key global-map "\C-e" 'end-of-line)
 (define-key global-map "\C-f" 'forward-char)
 (define-key global-map "\C-d" 'delete-char)
-(define-key global-map 'delete 'backspace-or-delete)
+(define-key global-map 'delete 'erase-character)
+(define-key global-map [(meta delete)] 'erase-word)
+(define-key global-map [(control x) (delete)] 'erase-sentence)
 
 ;; FSFmacs files.el
 
@@ -271,7 +273,6 @@
 (define-key global-map "\M-f" 'forward-word)
 (define-key global-map "\M-b" 'backward-word)
 (define-key global-map "\M-d" 'kill-word)
-;;(define-key global-map "\M-\177" 'backward-kill-word)
 
 (define-key global-map "\M-<" 'beginning-of-buffer)
 (define-key global-map "\M->" 'end-of-buffer)
--- lisp/prim/simple.el.orig	Tue Jun 10 15:56:31 1997
+++ lisp/prim/simple.el	Tue Jun 10 16:01:31 1997
@@ -359,29 +359,51 @@
   :type 'boolean
   :group 'editing-basics)
 
-(defcustom backspace-or-delete-hook nil
-  "Hook that is run prior to executing the backspace-or-delete function.
-Return a non-nil value to indicate that the editing chore has been
-handled and the backspace-or-delete function will exit without doing
-anything else."
-  :type 'hook)
-  
-(defun backspace-or-delete (arg)
+(defun erase-character (arg)
   "Delete either one character backwards or one character forwards.
 Controlled by the state of `delete-erases-forward' and whether the
 BackSpace keysym even exists on your keyboard.  If you don't have a
 BackSpace keysym, the delete key should always delete one character
 backwards."
   (interactive "*P")
-  (unless (run-hook-with-args 'backspace-or-delete-hook arg)
-    (if zmacs-region-active-p
-	(kill-region (point) (mark))
-      (if (and delete-erases-forward
-	       (or (eq 'tty (device-type))
-		   (x-keysym-on-keyboard-p "BackSpace")))
-	  (delete-char (prefix-numeric-value arg))
-	(delete-backward-char (prefix-numeric-value arg))))))
+  (if zmacs-region-active-p
+      (kill-region (point) (mark))
+    (if (and delete-erases-forward
+	     (or (eq 'tty (device-type))
+		 (x-keysym-on-keyboard-p "BackSpace")))
+	(delete-char (prefix-numeric-value arg))
+      (delete-backward-char (prefix-numeric-value arg)))))
+
+(defun erase-word (arg)
+  "Delete either one word backwards or one word forwards.
+Controlled by the state of `delete-erases-forward' and whether the
+BackSpace keysym even exists on your keyboard.  If you don't have a
+BackSpace keysym, the delete key should always delete one character
+backwards."
+  (interactive "*P")
+  (if zmacs-region-active-p
+      (kill-region (point) (mark))
+    (if (and delete-erases-forward
+	     (or (eq 'tty (device-type))
+		 (x-keysym-on-keyboard-p "BackSpace")))
+	(kill-word (prefix-numeric-value arg))
+      (backward-kill-word (prefix-numeric-value arg)))))
 
+(defun erase-sentence (arg)
+    "Delete either one sentence backwards or one sentence forwards.
+Controlled by the state of `delete-erases-forward' and whether the
+BackSpace keysym even exists on your keyboard.  If you don't have a
+BackSpace keysym, the delete key should always delete one character
+backwards."
+  (interactive "*P")
+  (if zmacs-region-active-p
+      (kill-region (point) (mark))
+    (if (and delete-erases-forward
+	     (or (eq 'tty (device-type))
+		 (x-keysym-on-keyboard-p "BackSpace")))
+	(kill-sentence (prefix-numeric-value arg))
+      (backward-kill-sentence (prefix-numeric-value arg)))))
+  
 (defun zap-to-char (arg char)
   "Kill up to and including ARG'th occurrence of CHAR.
 Goes backward if ARG is negative; error if CHAR not found."
--- lisp/modes/cc-mode.el.orig	Tue Jun 10 16:21:38 1997
+++ lisp/modes/cc-mode.el	Tue Jun 10 16:22:07 1997
@@ -481,8 +481,8 @@
 This hook gets called after a line is indented by the mode."
   :type 'hook
   :group 'cc-indent)
-(defcustom c-delete-function (if (fboundp 'backspace-or-delete)
-				 'backspace-or-delete
+(defcustom c-delete-function (if (fboundp 'erase-character)
+				 'erase-character
 			       'backward-delete-char-untabify)
   "*Function called by `c-electric-delete' when deleting characters."
   :type 'function
--- lisp/modes/cperl-mode.el.orig	Tue Jun 10 16:21:48 1997
+++ lisp/modes/cperl-mode.el	Tue Jun 10 16:22:37 1997
@@ -1560,8 +1560,8 @@
 	(setq p (point))
 	(skip-chars-backward " \t\n")
 	(delete-region (point) p))
-    (if (fboundp 'backspace-or-delete)
-	(backspace-or-delete (prefix-numeric-value arg))
+    (if (fboundp 'erase-character)
+	(erase-character (prefix-numeric-value arg))
       (backward-delete-char-untabify (prefix-numeric-value arg)))))
 
 (defun cperl-inside-parens-p ()

--Multipart_Tue_Jun_10_17:18:13_1997-1--

