emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] master a8a9d33 122/433: Updated file-variables class to handle pr


From: Dmitry Gutov
Subject: [elpa] master a8a9d33 122/433: Updated file-variables class to handle prefixes.
Date: Thu, 15 Mar 2018 19:43:48 -0400 (EDT)

branch: master
commit a8a9d33f3a4a198acb0495d78cd276e23cda1e0c
Author: mas <mas>
Commit: mas <mas>

    Updated file-variables class to handle prefixes.
---
 mmm-sample.el | 35 ++++++++++++++++++++++++-----------
 1 file changed, 24 insertions(+), 11 deletions(-)

diff --git a/mmm-sample.el b/mmm-sample.el
index 337fc1f..21a3ded 100644
--- a/mmm-sample.el
+++ b/mmm-sample.el
@@ -3,7 +3,7 @@
 ;; Copyright (C) 2000 by Michael Abraham Shulman
 
 ;; Author: Michael Abraham Shulman <address@hidden>
-;; Version: $Id: mmm-sample.el,v 1.7 2000/07/23 05:33:24 mas Exp $
+;; Version: $Id: mmm-sample.el,v 1.8 2000/07/24 19:00:22 mas Exp $
 
 ;;{{{ GPL
 
@@ -143,29 +143,38 @@ Usually either `perl-mode' or `cperl-mode'. The default is
 ;; Lisp Mode.  It is a good candidate to put in `mmm-global-classes'.
 
 (defun mmm-file-variables-verify ()
+  ;; It would be nice to cache this somehow, which could be done in a
+  ;; buffer-local variable with markers for positions, but the trick
+  ;; is knowing when to expire the cache.
   (let ((bounds
          (save-excursion
            (save-match-data
              (goto-char (point-max))
              (backward-page)
-             (search-forward "Local Variables:")
-             (cons (point)
-                   (progn (search-forward "End:")
-                          (beginning-of-line)
-                          (point)))))))
-    (and (> (match-beginning 0) (car bounds))
-         (< (match-end 0) (cdr bounds)))))
+             (and (re-search-forward "^\\(.*\\)Local Variables:" nil t)
+                  (list (match-string 1)
+                        (progn (end-of-line) (point))
+                        (and (search-forward
+                              (format "%sEnd:" (match-string 1))
+                              nil t)
+                             (progn (beginning-of-line)
+                                    (point)))))))))
+    (and bounds (caddr bounds)
+         (save-match-data
+           (string-match (format "^%s" (regexp-quote (car bounds)))
+                         (match-string 0)))
+         (> (match-beginning 0) (cadr bounds))
+         (< (match-end 0) (caddr bounds)))))
 
 (defun mmm-file-variables-find-back (bound)
   (forward-sexp)
   (if (> (point) bound)
       nil
-    (looking-at "")
-    t))
+    (looking-at "")))
 
 (mmm-add-classes
  '((file-variables
-    :front "^[a-zA-Z-*]+: "
+    :front ".+:"
     :front-verify mmm-file-variables-verify
     :back mmm-file-variables-find-back
     :submode emacs-lisp-mode
@@ -218,4 +227,8 @@ Usually either `perl-mode' or `cperl-mode'. The default is
 
 (provide 'mmm-sample)
 
+
+;;; Local Variables:
+;;; End:
+
 ;;; mmm-sample.el ends here
\ No newline at end of file



reply via email to

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