summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/bytecomp.el
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2007-04-11 03:59:20 +0000
committerGlenn Morris <rgm@gnu.org>2007-04-11 03:59:20 +0000
commita746fb658bd9f3ae6bcccf84dc6c431c48ffe995 (patch)
treefcfe920aeea9f182c4524c6bad791a2be603e7e4 /lisp/emacs-lisp/bytecomp.el
parent6f7e29f1d2e5c71de825072c83803fd0640e8d84 (diff)
downloademacs-a746fb658bd9f3ae6bcccf84dc6c431c48ffe995.tar.gz
Markus Triska <markus.triska at gmx.at>:
(byte-compile-char-before): Improve numeric argument case. (byte-compile-backward-char, byte-compile-backward-word): New functions, performing rewriting previously done in byte-opt.el. Fix their "Fixme" item (restriction to numeric arguments).
Diffstat (limited to 'lisp/emacs-lisp/bytecomp.el')
-rw-r--r--lisp/emacs-lisp/bytecomp.el31
1 files changed, 27 insertions, 4 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index de749e1d0c8..f1761c125ac 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -3149,6 +3149,8 @@ That command is designed for interactive use only" fn))
;; more complicated compiler macros
(byte-defop-compiler char-before)
+(byte-defop-compiler backward-char)
+(byte-defop-compiler backward-word)
(byte-defop-compiler list)
(byte-defop-compiler concat)
(byte-defop-compiler fset)
@@ -3162,10 +3164,31 @@ That command is designed for interactive use only" fn))
(defun byte-compile-char-before (form)
(cond ((= 2 (length form))
- (byte-compile-form `(char-after (1- ,(nth 1 form)))))
- ((= 1 (length form))
- (byte-compile-form '(char-after (1- (point)))))
- (t (byte-compile-subr-wrong-args form "0-1"))))
+ (byte-compile-form (list 'char-after (if (numberp (nth 1 form))
+ (1- (nth 1 form))
+ `(1- ,(nth 1 form))))))
+ ((= 1 (length form))
+ (byte-compile-form '(char-after (1- (point)))))
+ (t (byte-compile-subr-wrong-args form "0-1"))))
+
+;; backward-... ==> forward-... with negated argument.
+(defun byte-compile-backward-char (form)
+ (cond ((= 2 (length form))
+ (byte-compile-form (list 'forward-char (if (numberp (nth 1 form))
+ (- (nth 1 form))
+ `(- ,(nth 1 form))))))
+ ((= 1 (length form))
+ (byte-compile-form '(forward-char -1)))
+ (t (byte-compile-subr-wrong-args form "0-1"))))
+
+(defun byte-compile-backward-word (form)
+ (cond ((= 2 (length form))
+ (byte-compile-form (list 'forward-word (if (numberp (nth 1 form))
+ (- (nth 1 form))
+ `(- ,(nth 1 form))))))
+ ((= 1 (length form))
+ (byte-compile-form '(forward-word -1)))
+ (t (byte-compile-subr-wrong-args form "0-1"))))
(defun byte-compile-list (form)
(let ((count (length (cdr form))))