Hi, Jerry.
On Sun, Mar 03, 2013 at 06:44:40PM -0700, Jerry James wrote:
On Sun, Mar 3, 2013 at 3:37 PM, Alan Mackenzie <acm(a)muc.de>
wrote:
> Question: since these "last-command-event"s are always printable
> characters, would it be OK just to use `last-command-char' here?
Yes, I think it would be okay. I'm happy to test a patch for
you, if
you like.
Thanks! Here's the patch. Please make sure you recompile cc-defs.el
before the other two, since it contains a new macro.
diff -r bb7cfcb66461 cc-align.el
--- a/cc-align.el Sat Feb 02 11:23:32 2013 +0000
+++ b/cc-align.el Mon Mar 04 12:51:49 2013 +0000
@@ -1298,7 +1298,7 @@
exactly the old newline insertion behavior."
;; newline only after semicolon, but only if that semicolon is not
;; inside a parenthesis list (e.g. a for loop statement)
- (if (not (eq last-command-event ?\;))
+ (if (not (eq (c-last-command-char) ?\;))
nil ; continue checking
(if (condition-case nil
(save-excursion
@@ -1315,7 +1315,7 @@
inserted, and the following line is not blank, no newline is inserted.
Otherwise, no determination is made."
(save-excursion
- (if (and (= last-command-event ?\;)
+ (if (and (= (c-last-command-char) ?\;)
;;(/= (point-max)
;; (save-excursion (skip-syntax-forward " ") (point))
(zerop (forward-line 1))
@@ -1335,7 +1335,7 @@
(if (c-safe (up-list -1) t)
(c-point 'bol)
-1))))
- (if (and (eq last-command-event ?\;)
+ (if (and (eq (c-last-command-char) ?\;)
(eq (car (car syntax)) 'inclass)
(eq (car (car (cdr syntax))) 'topmost-intro)
(= (c-point 'bol) bol))
diff -r bb7cfcb66461 cc-cmds.el
--- a/cc-cmds.el Sat Feb 02 11:23:32 2013 +0000
+++ b/cc-cmds.el Mon Mar 04 12:51:49 2013 +0000
@@ -477,7 +477,7 @@
(bolp (bolp)))
(beginning-of-line)
(delete-horizontal-space)
- (insert last-command-event)
+ (insert (c-last-command-char))
(and (not bolp)
(goto-char (- (point-max) pos)))
)))
@@ -739,7 +739,7 @@
;; `}': clean up empty defun braces
(when (c-save-buffer-state ()
(and (memq 'empty-defun-braces c-cleanup-list)
- (eq last-command-event ?\})
+ (eq (c-last-command-char) ?\})
(c-intersect-lists '(defun-close class-close inline-close)
syntax)
(progn
@@ -755,14 +755,14 @@
;; `}': compact to a one-liner defun?
(save-match-data
(when
- (and (eq last-command-event ?\})
+ (and (eq (c-last-command-char) ?\})
(memq 'one-liner-defun c-cleanup-list)
(c-intersect-lists '(defun-close) syntax)
(c-try-one-liner))
(setq here (- (point-max) pos))))
;; `{': clean up brace-else-brace and brace-elseif-brace
- (when (eq last-command-event ?\{)
+ (when (eq (c-last-command-char) ?\{)
(cond
((and (memq 'brace-else-brace c-cleanup-list)
(re-search-backward
@@ -816,7 +816,7 @@
))))
;; blink the paren
- (and (eq last-command-event ?\})
+ (and (eq (c-last-command-char) ?\})
(not executing-kbd-macro)
old-blink-paren
(save-excursion
@@ -853,7 +853,7 @@
(when (and (not arg)
(eq literal 'c)
(memq 'comment-close-slash c-cleanup-list)
- (eq last-command-event ?/)
+ (eq (c-last-command-char) ?/)
(looking-at (concat "[ \t]*\\("
(regexp-quote comment-end) "\\)?$"))
; (eq c-block-comment-ender "*/") ; C-style comments ALWAYS end in */
@@ -869,7 +869,7 @@
(setq indentp (and (not arg)
c-syntactic-indentation
c-electric-flag
- (eq last-command-event ?/)
+ (eq (c-last-command-char) ?/)
(eq (char-before) (if literal ?* ?/))))
(self-insert-command (prefix-numeric-value arg))
(if indentp
@@ -950,10 +950,10 @@
(let ((pos (- (point-max) (point))))
(if (c-save-buffer-state ()
(and (or (and
- (eq last-command-event ?,)
+ (eq (c-last-command-char) ?,)
(memq 'list-close-comma c-cleanup-list))
(and
- (eq last-command-event ?\;)
+ (eq (c-last-command-char) ?\;)
(memq 'defun-close-semi c-cleanup-list)))
(progn
(forward-char -1)
@@ -1110,7 +1110,7 @@
;; Indent the line if appropriate.
(when (and c-electric-flag c-syntactic-indentation c-recognize-<>-arglists)
(setq found-delim
- (if (eq last-command-event ?<)
+ (if (eq (c-last-command-char) ?<)
;; If a <, basically see if it's got "template" before it .....
(or (and (progn
(backward-char)
@@ -1204,7 +1204,7 @@
;; clean up brace-elseif-brace
(when
(and (memq 'brace-elseif-brace c-cleanup-list)
- (eq last-command-event ?\()
+ (eq (c-last-command-char) ?\()
(re-search-backward
(concat "}"
"\\([ \t\n]\\|\\\\\n\\)*"
@@ -1222,7 +1222,7 @@
;; clean up brace-catch-brace
(when
(and (memq 'brace-catch-brace c-cleanup-list)
- (eq last-command-event ?\()
+ (eq (c-last-command-char) ?\()
(re-search-backward
(concat "}"
"\\([ \t\n]\\|\\\\\n\\)*"
@@ -1243,7 +1243,7 @@
;; space-before-funcall clean-up?
((and (memq 'space-before-funcall c-cleanup-list)
- (eq last-command-event ?\()
+ (eq (c-last-command-char) ?\()
(save-excursion
(backward-char)
(skip-chars-backward " \t")
@@ -1261,7 +1261,7 @@
;; compact-empty-funcall clean-up?
((c-save-buffer-state ()
(and (memq 'compact-empty-funcall c-cleanup-list)
- (eq last-command-event ?\))
+ (eq (c-last-command-char) ?\))
(save-excursion
(c-safe (backward-char 2))
(when (looking-at "()")
@@ -1290,7 +1290,7 @@
(when (c-save-buffer-state ()
(and c-electric-flag
c-syntactic-indentation
- (not (eq last-command-event ?_))
+ (not (eq (c-last-command-char) ?_))
(= (save-excursion
(skip-syntax-backward "w")
(point))
diff -r bb7cfcb66461 cc-defs.el
--- a/cc-defs.el Sat Feb 02 11:23:32 2013 +0000
+++ b/cc-defs.el Mon Mar 04 12:51:49 2013 +0000
@@ -391,6 +391,13 @@
`(int-to-char ,integer)
integer))
+(defmacro c-last-command-char ()
+ ;; The last character just typed. Note that `last-command-event' exists in
+ ;; both Emacs and XEmacs, but with confusingly different meanings.
+ (if (featurep 'xemacs)
+ 'last-command-char
+ 'last-command-event))
+
(defmacro c-sentence-end ()
;; Get the regular expression `sentence-end'.
(if (cc-bytecomp-fboundp 'sentence-end)
--
Alan Mackenzie (Nuremberg, Germany).
_______________________________________________
XEmacs-Beta mailing list
XEmacs-Beta(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-beta