+(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)
+)