🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.vm.bug
Article #148

Re: inhibit-local-variables on mailboxes again

#148
From: mike-w
Date: Mon, 24 Jun 1991 14:10
123 lines
5878 bytes
>>> On 21 Jun 91 02:28:11 GMT,
>>> "Dan" == Dan_Jacobson@ATT.COM writes:

Dan> That was the problem.  I have it set to t.  With the
Dan> inhibit-local-variables variable, one can either accept all the local
Dan> variables, or be queried, but the capability doesn't exist to ignore
Dan> them, ...

    Here's a modified version of Carl Witty's modified version of
  hack-local-variables (Dan suggested I pass it on).  It supports two
  additional values for inhibit-local-variables:

      'always	means never obey "Local Variables" section, and don't
                bother querying the user.  (I thought that setting this
                value in vm-mode-hooks would solve Dan's problem, but
                unfortunately vm explicitly let-binds
                inhibit-local-variables to t.)

      'query-other
      	      	means only bother querying the user if the file is owned by
      	      	someone else (helps prevent Trojan Horses without getting
      	      	in the way too much).

--- CUT HERE --------------------------------------------------------------
;; Modified by cwitty@csli.Stanford.EDU (Carl Witty) on 12/4/88
;; to show "Local Variables" section of file on screen before
;; asking whether to use them (when inhibit-local-variables set).

;; Mike Williams (mike-w@cs14b.cs.aukuni.ac.nz) - Fri Apr 26 15:08:12 1991 
;; inhibit-local-variables can have the values
;;    nil 		... always set
;;    'query, t		... always query
;;    'query-other	... query if not file's owner
;;    'always		... always inhibit

(provide 'hack-locals)

(defun hack-local-variables (&optional force)
  "Parse, and bind or evaluate as appropriate, any local variables
for current buffer."
  ;; Look for "Local variables:" line in last page.
  (save-excursion
    (goto-char (point-max))
    (search-backward "\n\^L" (max (- (point-max) 3000) (point-min)) 'move)
    (if (and 
	 (let ((case-fold-search t)) (search-forward "Local Variables:" nil t))
	 (or force (not inhibit-local-variables)
	     (and (eq inhibit-local-variables 'query-other) 
		  buffer-file-name
		  (eq (nth 2 (file-attributes (buffer-file-name))) 
		      (user-uid)))
	     (if (eq inhibit-local-variables 'always) nil
	       (save-window-excursion
		 (switch-to-buffer (current-buffer) t)
		 (recenter 0)
		 (y-or-n-p 
		  (format 
		   "Set local variables as specified at end of %s? "
		   (file-name-nondirectory buffer-file-name)))))))
	(let ((continue t)
	      prefix prefixlen suffix beg)
	  ;; The prefix is what comes before "local variables:" in its line.
	  ;; The suffix is what comes after "local variables:" in its line.
	  (skip-chars-forward " \t")
	  (or (eolp)
	      (setq suffix (buffer-substring (point)
					     (progn (end-of-line) (point)))))
	  (goto-char (match-beginning 0))
	  (or (bolp)
	      (setq prefix
		    (buffer-substring (point)
				      (progn (beginning-of-line) (point)))))
	  (if prefix (setq prefixlen (length prefix)
			   prefix (regexp-quote prefix)))
	  (if suffix (setq suffix (regexp-quote suffix)))
	  (while continue
	    ;; Look at next local variable spec.
	    (if selective-display (re-search-forward "[\n\C-m]")
	      (forward-line 1))
	    ;; Skip the prefix, if any.
	    (if prefix
		(if (looking-at prefix)
		    (forward-char prefixlen)
		  (error "Local variables entry is missing the prefix")))
	    ;; Find the variable name; strip whitespace.
	    (skip-chars-forward " \t")
	    (setq beg (point))
	    (skip-chars-forward "^:\n")
	    (if (eolp) (error "Missing colon in local variables entry"))
	    (skip-chars-backward " \t")
	    (let* ((str (buffer-substring beg (point)))
		   (var (read str))
		  val)
	      ;; Setting variable named "end" means end of list.
	      (if (string-equal (downcase str) "end")
		  (setq continue nil)
		;; Otherwise read the variable value.
		(skip-chars-forward "^:")
		(forward-char 1)
		(setq val (read (current-buffer)))
		(skip-chars-backward "\n")
		(skip-chars-forward " \t")
		(or (if suffix (looking-at suffix) (eolp))
		    (error "Local variables entry is terminated incorrectly"))
		;; Set the variable.  "Variables" mode and eval are funny.
		(cond ((eq var 'mode)
		       (funcall (intern (concat (downcase (symbol-name val))
						"-mode"))))
		      ((eq var 'eval)
		       (if (string= (user-login-name) "root")
			   (message "Ignoring `eval:' in file's local variables")
			 (eval val)))
		      (t (make-local-variable var)
			 (set var val))))))))))

;;=== END of hack-locals.el ===============================================
--
    /-------------------- mike-w@cs.aukuni.ac.nz ---------------------\
    | Mike Williams, Computer Science, Auckland University, Aotearoa. |
    \-------------- I have a lovely bunch of coconuts. ---------------/
    Disclaimer: I wasn't even there.
-- 
New administrater uofa.
Technical Details
Message-ID: <MIKE-W.91Jun24101007@cs17.cs.aukuni.ac.nz>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!zaphod.mps.ohio-state.edu!think.com!mintaka!ai-lab!ai.mit.edu!gnulists
References: <DANJ1.91Jun20212507@ihlpz.ATT.COM>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,ecc5f4ef58bbb22,start
X-Google-Attributes: gidfb2f1,public
X-Google-Thread: f6829,b7687d7ff193f1ce
X-Google-Attributes: gidf6829,public
X-Google-ArrivalTime: 1991-06-24 07:10:07 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!zaphod.mps.ohio-state.edu!think.com!mintaka!ai-lab!ai.mit.edu!gnulists
From: mike-w@cs.aukuni.ac.nz
Newsgroups: gnu.emacs.vm.bug,gnu.emacs.bug
Subject: Re: inhibit-local-variables on mailboxes again
Message-ID: <MIKE-W.91Jun24101007@cs17.cs.aukuni.ac.nz>
Date: 24 Jun 91 14:10:07 GMT
References: <DANJ1.91Jun20212507@ihlpz.ATT.COM>
Followup-To: gnu.emacs.vm.bug
Organization: University of Auckland, New Zealand.
Lines: 123
Approved: info-gnu@prep.ai.mit.edu
In-Reply-To: Dan_Jacobson@ATT.COM's message of 21 Jun 91 02:28:11 GMT
Nntp-Posting-Host: cs17.cs.aukuni.ac.nz
X-News-Software: GNUS 3.13
Apparently-To: gnu-emacs-bug@uunet.uu.net