Article View: gnu.emacs.help
Article #189006Re: modifying auto-mode-alist
From: Silver
Date: Sat, 18 May 1991 17:22
Date: Sat, 18 May 1991 17:22
25 lines
1702 bytes
1702 bytes
> [I get the error "Attempt to modify read-only object" when I attempt to
> modify a cdr in auto-mode-alist.]
This is because the object exists in purespace in the dumped binary, which is
probably read-only. Mumbo-jumbo. This particular variable should be
user-mungeable. As a quick fix, consider putting the following code in
site-init.el (or near the top of your .emacs if you aren't admin).
;; Make sure auto-mode-alist is modifiable.
(setq auto-mode-alist (copy-alist auto-mode-alist))
;; Function to update auto-modes.
(defun auto-mode-update (pattern function)
"Set the auto-mode function for filename regexp FILENAME-PATTERN to
function MODE-FUNCTION. An auto-mode need not previously be defined for
FILENAME-PATTERN. Returns the cons entry in auto-mode-alist."
(interactive "sPattern: \nCFunction: ")
(let ((entry (assoc pattern auto-mode-alist)))
(if entry
(setcdr entry function)
(progn (setq entry (cons pattern function))
(setq auto-mode-alist (cons entry auto-mode-alist))))
entry))
Regards, [Ag]
Technical Details
Message-ID:
<May.18.13.22.11.1991.2403@paul.rutgers.edu>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!stanford.edu!rutgers!aramis.rutgers.edu!paul.rutgers.edu!gaynorReferences:
<1991May4.182621.2544@athena.mit.edu> <1991May18.061322.28404@newross.Princeton.EDU>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103b8b,80ffebd709a40a03 X-Google-Attributes: gid103b8b,public X-Google-ArrivalTime: 1991-05-18 14:05:19 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!stanford.edu!rutgers!aramis.rutgers.edu!paul.rutgers.edu!gaynor From: gaynor@paul.rutgers.edu (Silver) Newsgroups: gnu.emacs.help Subject: Re: modifying auto-mode-alist Message-ID: <May.18.13.22.11.1991.2403@paul.rutgers.edu> Date: 18 May 91 17:22:11 GMT References: <1991May4.182621.2544@athena.mit.edu> <1991May18.061322.28404@newross.Princeton.EDU> Organization: Rutgers Univ., New Brunswick, N.J. Lines: 25