]> code.delx.au - gnu-emacs-elpa/commitdiff
Don't use looking-back
authorArtur Malabarba <bruce.connor.am@gmail.com>
Mon, 15 Jun 2015 09:44:23 +0000 (10:44 +0100)
committerArtur Malabarba <bruce.connor.am@gmail.com>
Mon, 15 Jun 2015 09:44:23 +0000 (10:44 +0100)
sotlisp.el

index d9d249228103cfd0985071ec46a5ae5dc3e4ab30..d1a34b93a3993d8ca5e7928bc1cdcede8c8b29de 100644 (file)
       (bound-and-true-p paredit-mode)
       (bound-and-true-p smartparens-mode)))
 
+(defun sotlisp--looking-back (regexp)
+  (string-match
+   (concat regexp "\\'")
+   (buffer-substring (line-beginning-position) (point))))
+
 (defun sotlisp--function-form-p ()
   "Non-nil if point is at the start of a sexp.
 Specially, avoids matching inside argument lists."
   (and (eq (char-before) ?\()
-       (not (looking-back "(\\(defun\\s-+.*\\|lambda\\s-+\\)("))
+       (not (sotlisp--looking-back "(\\(defun\\s-+.*\\|lambda\\s-+\\)("))
        (not (string-match (rx (syntax symbol)) (string last-command-event)))))
 
 (defun sotlisp--function-quote-p ()
   "Non-nil if point is at a sharp-quote."
-  (looking-back "#'"))
+  (ignore-errors
+    (save-excursion
+      (forward-char -2)
+      (looking-at-p "#'"))))
 
 (defun sotlisp--function-p ()
   "Non-nil if point is at reasonable place for a function name.