X-Git-Url: http://gitweb.michael.orlitzky.com/?p=nagios-mode.git;a=blobdiff_plain;f=nagios-mode.el;fp=nagios-mode.el;h=5dd7274fe7343f91e2e9358af759d0247b0f736a;hp=b9c5faaba8054a478f8418388a4e00acc6954250;hb=2ecf92ea2cab2a75ac0b620a5efb3ab468c7f528;hpb=c6ae78ead8bae7b798c843ed0cffd466e69060e4 diff --git a/nagios-mode.el b/nagios-mode.el index b9c5faa..5dd7274 100644 --- a/nagios-mode.el +++ b/nagios-mode.el @@ -74,33 +74,39 @@ +(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) +)