bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

patch: thingatpt.el usage of char-before and char-after


From: Aaron Hawley
Subject: patch: thingatpt.el usage of char-before and char-after
Date: Tue, 16 Oct 2007 10:59:36 -0400

Since char-after and char-before use (point) as their default arguments,
there's no sense specifying it.  Also, I'm pretty confident that
(char-after (1- (point))) is equivalent to (char-before).  I noticed
these in thingatpt.el.  Below is a patch that makes these
simplifications to the library's code.

ChangeLog entry:

2007-10-16  Aaron Hawley  <address@hidden>

        * thingatpt.el (end-of-sexp, beginning-of-sexp)
        (forward-same-syntax): char-before and char-after use (point) as
        default argument.
        (forward-same-syntax): char-before is syntactic sugar
        for (char-after (1- (point))).

--- orig/lisp/thingatpt.el
+++ mod/lisp/thingatpt.el
@@ -165,7 +165,7 @@
       (nth 3 (parse-partial-sexp (point) orig)))))
 
 (defun end-of-sexp ()
-  (let ((char-syntax (char-syntax (char-after (point)))))
+  (let ((char-syntax (char-syntax (char-after))))
     (if (or (eq char-syntax ?\))
            (and (eq char-syntax ?\") (in-string-p)))
        (forward-char 1)
@@ -174,7 +174,7 @@
 (put 'sexp 'end-op 'end-of-sexp)
 
 (defun beginning-of-sexp ()
-  (let ((char-syntax (char-syntax (char-before (point)))))
+  (let ((char-syntax (char-syntax (char-before))))
     (if (or (eq char-syntax ?\()
            (and (eq char-syntax ?\") (in-string-p)))
        (forward-char -1)
@@ -374,10 +374,10 @@
   (interactive "p")
   (while (< arg 0)
     (skip-syntax-backward
-     (char-to-string (char-syntax (char-after (1- (point))))))
+     (char-to-string (char-syntax (char-before))))
     (setq arg (1+ arg)))
   (while (> arg 0)
-    (skip-syntax-forward (char-to-string (char-syntax (char-after
(point)))))
+    (skip-syntax-forward (char-to-string (char-syntax (char-after))))
     (setq arg (1- arg))))
 
 ;;  Aliases

-- 
 National Gardening Association
 1100 Dorset Street, South Burlington, VT 05403 
 Email: address@hidden - Web: www.garden.org/
--






reply via email to

[Prev in Thread] Current Thread [Next in Thread]