summaryrefslogtreecommitdiffstats
path: root/ext/emacs
diff options
context:
space:
mode:
authorRuss Allbery <rra@debian.org>2008-05-02 12:54:35 -0700
committerLuke Kanies <luke@madstop.com>2008-05-12 16:48:17 -0500
commit9bf21a65bb05c7135cc7e4b46a59cb110fd40b5f (patch)
treea1b2ee43142c53d750cdc8cee47c0f9af1e17aaa /ext/emacs
parent20e60b111687c286737c981b13edfaac23e7b1a6 (diff)
downloadpuppet-9bf21a65bb05c7135cc7e4b46a59cb110fd40b5f.tar.gz
puppet-9bf21a65bb05c7135cc7e4b46a59cb110fd40b5f.tar.xz
puppet-9bf21a65bb05c7135cc7e4b46a59cb110fd40b5f.zip
Use our own count-matches for Emacs 21 compatibility
Replace count-matches with a puppet-count-matches function that does the same as the Emacs 22 count-matches. The Emacs 21 count-matches is different and not useful for our purposes.
Diffstat (limited to 'ext/emacs')
-rw-r--r--ext/emacs/puppet-mode.el11
1 files changed, 10 insertions, 1 deletions
diff --git a/ext/emacs/puppet-mode.el b/ext/emacs/puppet-mode.el
index 0a7ee1a5f..56a2b3acc 100644
--- a/ext/emacs/puppet-mode.el
+++ b/ext/emacs/puppet-mode.el
@@ -56,6 +56,15 @@
"*Indentation column of comments."
:type 'integer :group 'puppet)
+(defun puppet-count-matches (re start end)
+ "The same as Emacs 22 count-matches, for portability to other versions
+of Emacs."
+ (save-excursion
+ (let ((n 0))
+ (goto-char start)
+ (while (re-search-forward re end t) (setq n (1+ n)))
+ n)))
+
(defun puppet-comment-line-p ()
"Return non-nil iff this line is a comment."
(save-excursion
@@ -77,7 +86,7 @@ that array, else return nil."
;; ### steps, baby steps. A more robust strategy might be
;; ### to walk backwards by sexps, until hit a wall, then
;; ### inspect the nature of that wall.
- (if (= (count-matches "\\]" apoint opoint) 0)
+ (if (= (puppet-count-matches "\\]" apoint opoint) 0)
apoint))))))
(defun puppet-in-include ()