all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Elisp -- Check if a buffer has a valid `Local Variables' block
@ 2007-08-26 15:56 Leo
  2007-09-03 14:27 ` Kevin Rodgers
  0 siblings, 1 reply; 3+ messages in thread
From: Leo @ 2007-08-26 15:56 UTC (permalink / raw)
  To: help-gnu-emacs

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Elisp -- Check if a buffer has a valid `Local Variables' block
  2007-08-26 15:56 Elisp -- Check if a buffer has a valid `Local Variables' block Leo
@ 2007-09-03 14:27 ` Kevin Rodgers
  2007-09-03 14:55   ` Leo
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Rodgers @ 2007-09-03 14:27 UTC (permalink / raw)
  To: help-gnu-emacs

Leo 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))))

(condition-case nil
     (progn (hack-local-variables t) t)
   (error nil))

-- 
Kevin Rodgers
Denver, Colorado, USA

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Elisp -- Check if a buffer has a valid `Local Variables' block
  2007-09-03 14:27 ` Kevin Rodgers
@ 2007-09-03 14:55   ` Leo
  0 siblings, 0 replies; 3+ messages in thread
From: Leo @ 2007-09-03 14:55 UTC (permalink / raw)
  To: help-gnu-emacs

On 2007-09-03 15:27 +0100, Kevin Rodgers wrote:
> Leo 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))))
>
> (condition-case nil
>     (progn (hack-local-variables t) t)
>   (error nil))

This looks neat. Thanks.

-- 
Leo <sdl.web AT gmail.com>                (GPG Key: 9283AA3F)

      Gnus is one component of the Emacs operating system.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-09-03 14:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-26 15:56 Elisp -- Check if a buffer has a valid `Local Variables' block Leo
2007-09-03 14:27 ` Kevin Rodgers
2007-09-03 14:55   ` Leo

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.