help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Elisp -- Check if a buffer has a valid `Local Variables' block


From: George O'Connor
Subject: Re: Elisp -- Check if a buffer has a valid `Local Variables' block
Date: Tue, 28 Aug 2007 19:29:51 -0000
User-agent: G2/1.0

On Aug 26, 9:56 am, Leo <sdl....@gmail.com> wrote:
> Dear all,
>
> Emacs has some rules regarding the Local Variables block. I wonder if
> there is a function to validate that block or go to that block etc. if
> not could you help me create one?
>
> #v+
> (defun sdl:goto-local-variables ()
>   (interactive)
>   (let (pt pos)
>     (save-excursion
>       (goto-char (point-max))
>       (save-restriction
>         (narrow-to-page)
>         (if (> (- (point-max) (point-min)) 3000)
>             (setq pt (- (point-max) 3000))
>           (setq pt (point-min))))
>       (goto-char pt)
>       (when (re-search-forward ".*Local Variables:\n\\(.*\n\\)*.*End:" nil t)
>         (beginning-of-line 2)
>         (setq pos (point))))
>     (if pos
>         (goto-char pos))))
> #v-
>
> --
> Leo <sdl.web AT gmail.com>                         (GPG Key: 9283AA3F)
>
>          Gnus is one component of the Emacs operating system.

You will have to have the regular expression take into account that
all the lines must begin and end with a begin-pattern and an end-
pattern (usually the empty pattern).  Also, local variables may be set
in the first line of the file using a different syntax.

Please review hack-local-variables in lisp/files.el (or lisp.files.gz)
to see if it it the type of routine you are looking for.




reply via email to

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