aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/progmodes/cc-cmds.el73
1 files changed, 37 insertions, 36 deletions
diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el
index 70195e4cb56..7b71b83a825 100644
--- a/lisp/progmodes/cc-cmds.el
+++ b/lisp/progmodes/cc-cmds.el
@@ -105,22 +105,13 @@ See `c-toggle-auto-state' and `c-toggle-hungry-state' for details."
105 105
106;; Electric keys 106;; Electric keys
107 107
108;; Note: In XEmacs 20.3 the Delete and BackSpace keysyms have been
109;; separated and "\177" is no longer an alias for both keys. Also,
110;; the variable delete-key-deletes-forward controls in which direction
111;; the Delete keysym deletes characters. The functions
112;; c-electric-delete and c-electric-backspace attempt to deal with
113;; this new functionality. For Emacs 19 and XEmacs 19 backwards
114;; compatibility, the old behavior has moved to c-electric-backspace
115;; and c-backspace-function.
116
117(defun c-electric-backspace (arg) 108(defun c-electric-backspace (arg)
118 "Deletes preceding character or whitespace. 109 "Deletes preceding character or whitespace.
119If `c-hungry-delete-key' is non-nil, as evidenced by the \"/h\" or 110If `c-hungry-delete-key' is non-nil, as evidenced by the \"/h\" or
120\"/ah\" string on the mode line, then all preceding whitespace is 111\"/ah\" string on the mode line, then all preceding whitespace is
121consumed. If however an ARG is supplied, or `c-hungry-delete-key' is 112consumed. If however a prefix argument is supplied, or
122nil, or point is inside a literal then the function in the variable 113`c-hungry-delete-key' is nil, or point is inside a literal then the
123`c-backspace-function' is called. 114function in the variable `c-backspace-function' is called.
124 115
125See also \\[c-electric-delete]." 116See also \\[c-electric-delete]."
126 (interactive "*P") 117 (interactive "*P")
@@ -135,36 +126,46 @@ See also \\[c-electric-delete]."
135 (funcall c-backspace-function 1) 126 (funcall c-backspace-function 1)
136 )))) 127 ))))
137 128
129(defun c-electric-delete-forward (arg)
130 "Deletes following character or whitespace.
131If `c-hungry-delete-key' is non-nil, as evidenced by the \"/h\" or
132\"/ah\" string on the mode line, then all following whitespace is
133consumed. If however a prefix argument is supplied, or
134`c-hungry-delete-key' is nil, or point is inside a literal then the
135function in the variable `c-delete-function' is called."
136 (interactive "*P")
137 (if (or (not c-hungry-delete-key)
138 arg
139 (c-in-literal))
140 (funcall c-delete-function (prefix-numeric-value arg))
141 (let ((here (point)))
142 (skip-chars-forward " \t\n")
143 (if (/= (point) here)
144 (delete-region (point) here)
145 (funcall c-delete-function 1)))))
146
138(defun c-electric-delete (arg) 147(defun c-electric-delete (arg)
139 "Deletes preceding or following character or whitespace. 148 "Deletes preceding or following character or whitespace.
140 149This function either deletes forward as `c-electric-delete-forward' or
141The behavior of this function depends on the variable 150backward as `c-electric-backspace', depending on the configuration:
142`delete-key-deletes-forward'. If this variable is nil (or does not 151
143exist, as in older Emacsen), then this function behaves identical to 152If the function `delete-forward-p' is defined (XEmacs 21) and returns
144\\[c-electric-backspace]. 153non-nil, it deletes forward. Else, if the variable
145 154`delete-key-deletes-forward' is defined (XEmacs 20) and is set to
146If `delete-key-deletes-forward' is non-nil and is supported in your 155non-nil, it deletes forward. Otherwise it deletes backward.
147Emacs, then deletion occurs in the forward direction. So if 156
148`c-hungry-delete-key' is non-nil, as evidenced by the \"/h\" or 157Note: This is the way in XEmacs 20 and later to choose the correct
149\"/ah\" string on the mode line, then all following whitespace is 158action for the [delete] key, whichever key that means. In other
150consumed. If however an ARG is supplied, or `c-hungry-delete-key' is 159flavors this function isn't used, instead it's left to the user to
151nil, or point is inside a literal then the function in the variable 160bind [delete] to either \\[c-electric-delete-forward] or \\[c-electric-backspace] as appropriate
152`c-delete-function' is called." 161\(the keymap `function-key-map' is useful for that). Emacs 21 handles
162that automatically, though."
153 (interactive "*P") 163 (interactive "*P")
154 (if (or (and (fboundp 'delete-forward-p) ;XEmacs 21 164 (if (or (and (fboundp 'delete-forward-p) ;XEmacs 21
155 (delete-forward-p)) 165 (delete-forward-p))
156 (and (boundp 'delete-key-deletes-forward) ;XEmacs 20 166 (and (boundp 'delete-key-deletes-forward) ;XEmacs 20
157 delete-key-deletes-forward)) 167 delete-key-deletes-forward))
158 (if (or (not c-hungry-delete-key) 168 (c-electric-delete-forward arg)
159 arg
160 (c-in-literal))
161 (funcall c-delete-function (prefix-numeric-value arg))
162 (let ((here (point)))
163 (skip-chars-forward " \t\n")
164 (if (/= (point) here)
165 (delete-region (point) here)
166 (funcall c-delete-function 1))))
167 ;; act just like c-electric-backspace
168 (c-electric-backspace arg))) 169 (c-electric-backspace arg)))
169 170
170(defun c-electric-pound (arg) 171(defun c-electric-pound (arg)
@@ -2285,7 +2286,7 @@ Warning: Regexp from `c-comment-prefix-regexp' doesn't match the comment prefix
2285 (save-excursion 2286 (save-excursion
2286 (goto-char (car lit-limits)) 2287 (goto-char (car lit-limits))
2287 (if (looking-at (if (eq lit-type 'c++) 2288 (if (looking-at (if (eq lit-type 'c++)
2288 c-comment-prefix-regexp 2289 c-current-comment-prefix
2289 comment-start-skip)) 2290 comment-start-skip))
2290 (goto-char (match-end 0)) 2291 (goto-char (match-end 0))
2291 (forward-char 2) 2292 (forward-char 2)