]> gitweb.michael.orlitzky.com - nagios-mode.git/blobdiff - nagios-mode.el
Simplify the nagios-in-block function and eliminate some byte-compiler warnings as...
[nagios-mode.git] / nagios-mode.el
index b9c5faaba8054a478f8418388a4e00acc6954250..5dd7274fe7343f91e2e9358af759d0247b0f736a 100644 (file)
 
 
 
+(defun last-opening-brace()
+  ;; Get the position of the last opening brace, with
+  ;; respect to the current point.
+  (save-excursion
+    (let ((lob (re-search-backward "{" nil t)))
+      (if lob
+         lob
+         -1)
+    )
+  )
+)
+
+(defun last-closing-brace()
+  ;; Get the position of the last closing brace, with
+  ;; respect to the current point.
+  (save-excursion
+    (let ((lcb (re-search-backward "}" nil t)))
+      (if lcb
+         lcb
+         -1)
+    )
+  )
+)
+
 (defun nagios-in-block()
   "Determine if the point is inside of a {} block."
 
-  (setq pos (point))
-
-  ;; Get the position of the last opening and closing braces, with
-  ;; respect to the current point
-  (setq last-opening-brace (re-search-backward "{" nil t))
-  (goto-char pos)
-  
-  (setq last-closing-brace (re-search-backward "}" nil t))
-  (goto-char pos)
-
-  ;; If either is nil (not found) just set it to -1, so the comparison
-  ;; doesn't die.
-  (if (not last-opening-brace)
-      (setq last-opening-brace -1))
-  
-  (if (not last-closing-brace)
-      (setq last-closing-brace -1))
-
   ;; If the last brace seen in the buffer is an opening brace, we're
   ;; in a block. Otherwise, we aren't.
-  (if (>= last-closing-brace last-opening-brace)
+  (if (>= (last-closing-brace) (last-opening-brace))
       nil
-    t)
-  )
+      t)
+)